Archived chats no longer show inside folders
The unfiled list has filtered archived chats since archiving existed (api/pages.py). The folder branch went through the ORM relationship, which filters nothing, so an archived chat kept appearing as long as it was filed -- and the "Empty" check read the same unfiltered list, so a folder holding only archived chats would have claimed to be empty while listing them. Fixed on the model rather than in the template, as `Folder.visible_chats`. The loop and the empty check now cannot disagree, because there is one list and the template binds it once. Ordering matches the unfiled list: pinned first, then most recently touched. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -314,6 +314,28 @@ def test_deleting_a_folder_keeps_the_chats_inside_it(client: TestClient, db, reg
|
||||
assert chat.folder_id is None
|
||||
|
||||
|
||||
def test_an_archived_chat_inside_a_folder_is_not_listed(
|
||||
client: TestClient, db, registered, make_chat
|
||||
):
|
||||
"""Regression: the unfiled list has always filtered archived chats, but the
|
||||
folder branch went through the ORM relationship and filtered nothing, so an
|
||||
archived chat kept showing as long as it was filed."""
|
||||
_add_connection(db)
|
||||
client.post("/api/folders", data={"name": "Quests"})
|
||||
folder = db.scalar(select(Folder))
|
||||
|
||||
chat_id = make_chat()
|
||||
client.patch(f"/api/chats/{chat_id}", data={"folder_id": folder.id, "title": "Mount Doom"})
|
||||
chat = db.get(Chat, chat_id)
|
||||
chat.archived = True
|
||||
db.commit()
|
||||
|
||||
page = client.get("/chat").text
|
||||
assert "Mount Doom" not in page
|
||||
# And the folder must say so, rather than claiming to hold something.
|
||||
assert "Empty" in page
|
||||
|
||||
|
||||
def test_a_folder_cannot_be_moved_inside_itself(client: TestClient, db, registered):
|
||||
client.post("/api/folders", data={"name": "Outer"})
|
||||
folder = db.scalar(select(Folder))
|
||||
|
||||
Reference in New Issue
Block a user