Fix the rail picker going nameless — my own regression from the row rework

Giving each project row a widget left the QListWidgetItem with no text, and
project_choices() read exactly that. So the rail's picker listed every project
as a bare "📁 " with nothing after it, and the more projects there were the more
identical blanks you got. Reported after creating a second one.

Setting the text back on the item is not the fix: with a transparent row widget
on top, the name paints twice, one string ghosting the other — visible in a
render. project_choices() now reads list_projects(), the same source the list
is built from, so the picker no longer depends on how a row happens to be drawn.

check_project_screen creates a project and requires project_choices() to return
non-empty names and the picker to show each of them. Pointing it back at
item.text() fails it.

22/22 checkers pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nam Pham Dinh Thanh
2026-08-18 15:20:34 +09:00
co-authored by Claude Opus 5
parent 9393fc1748
commit 300c10711e
2 changed files with 32 additions and 4 deletions
+12 -4
View File
@@ -532,6 +532,8 @@ class WorkspaceTab(QWidget):
row_to_select = 0
for i, p in enumerate(list_projects()):
chats, tasks = counts.get(p.project_id, (0, 0))
# No text on the item: the row widget paints the name, and setting
# both drew it twice, one string ghosting the other.
item = QListWidgetItem()
item.setData(Qt.UserRole, p.project_id)
if p.description:
@@ -622,10 +624,16 @@ class WorkspaceTab(QWidget):
# ---- rail integration -------------------------------------------------
def project_choices(self):
"""(name, project_id) for the rail picker, in the list's own order."""
return [(self.project_list.item(i).text(),
self.project_list.item(i).data(Qt.UserRole))
for i in range(self.project_list.count())]
"""(name, project_id) for the rail picker, in the list's own order.
Read from the store, which is what the list is built from — reading
item.text() coupled the picker to how a row happens to be drawn, and
when rows became widgets the picker went blank: every project showed
as a bare folder glyph with no name.
"""
from ..core.projects import list_projects
return [(p.name, p.project_id) for p in list_projects()]
def selected_project_id(self) -> str:
return self._selected_id()