Skip to content

feat(tui): show the session's workspace in the F1 session list - #361

Open
Miaoranmmm wants to merge 1 commit into
openJiuwen-ai:mainfrom
Miaoranmmm:feat/workspace-f1-column
Open

Miaoranmmm wants to merge 1 commit into
openJiuwen-ai:mainfrom
Miaoranmmm:feat/workspace-f1-column

Conversation

@Miaoranmmm

@Miaoranmmm Miaoranmmm commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Paired: GitHub #361 ↔ GitCode !256

Part of #144. Builds on #328 (workspace backend).

What type of PR is this?
/kind feature


What

#328 records which workspace each session belongs to, but the F1 session list does not show it. This PR adds a Workspace column to the Chat tab of the F1 session list.

  • Shown when workspaces exist. With at least one workspace in the registry, the column is always shown, first. Each session shows its workspace name, or Unspecified (localized) when it has none. With no workspaces, or when the registry cannot be read, the table is the same as on main; an unreadable registry is reported once per opening as a warning. The Workflow tab has no Workspace column.
  • The running session shows the workspace it is in now, even when the registry on disk records another one (or none) for it.
  • One read per opening. The registry is read once, in a thread, alongside the session listing; paging, search and sorting use that read. Opening F1 again reads it again.
  • Search and sort. The search covers the full workspace name, also when the cell is shortened, and the search placeholder mentions workspaces when the column is shown; being longer, it is cut off earlier than main's (at 130 columns the English one ends at "titles,"). The header sorts by name, ignoring case, ascending first.
  • Width. The column is as wide as its longest name, up to 16 cells; longer names end in … and the tooltip shows the full name. When the columns do not fit, the column takes the cells it needs from Directory (down to 14 cells, elided in the middle) and then Title (down to 20). One cell is always kept free for the vertical scrollbar, so the scrollbar appearing or disappearing does not change the widths (a search can still change them, since it changes which names are measured); with a short list this falls back to scrolling one column earlier than strictly needed. If they still do not fit, as at 80 columns, the other columns keep their usual widths and the table scrolls sideways, as on main. A resize recomputes only the borrowed widths and updates only the columns whose width changed: no table rebuild, and the cursor, vertical scroll position and sort stay. A resize made while another screen (such as the delete confirmation) is on top is applied when the browser is shown again. As on main, when a resize adds the horizontal scrollbar, a cursor on the last visible row can end up under it.
  • Tooltip. Search matches are highlighted in the row tooltip too, so a match hidden by a shortened Workspace or Directory cell is still visible there. This applies to every F1 list, with or without workspaces.
  • Resume while sending. When resuming a session chosen in F1 is skipped because a submit is still in flight, the status bar shows the "still sending" notice instead of nothing.

Code

  • screens/sessions/presenter.py: new workspace column and WorkspaceNames (one resolved read: names by session, the Unspecified label, whether any workspace exists). The Workflow tab picks the chat columns it shares by key, so adding a chat column does not shift it.
  • screens/sessions/screen.py: reads the names once (_read_workspace_names), lays out the columns (_column_layout) and refits the borrowed widths on resize and screen resume (_fit_workspace_column, which sets DataTable column widths directly; added to the Textual-privates list in AGENTS.md). SessionsScreen takes workspaces (the state store's registry) and current_workspace_name.
  • util/formatting.py: elide_end cuts at whole graphemes, using iter_cell_graphemes and take_cells, which move from widgets/task_summary.py (its private _graphemes and _take_cells) to formatting.py unchanged; take_cells adds a fast path for printable ASCII.
  • service/workspaces/registry.py: the workspaces.unspecified label (UNSPECIFIED).
  • screens/main/screen.py: _restore_session_or_flash, used by the F1 restore path.
  • Docs: sessions.md (en, zh-Hans) mentions the column, horizontal scrolling and searching by workspace name.

Decisions

  • User 2026-11-26: when the Workspace column is shown and the columns do not fit, borrow from Directory (at least 14 cells, elided in the middle) and then Title (at least 20 cells); if that is still not enough, keep every column at its original width and scroll horizontally. The Workspace column is always shown first when workspaces exist (「没有必要啊,main上没有workspace,本来就是新加了一列」); without workspaces the table matches main. The shortened existing columns and horizontal scrolling on narrow screens are not a regression.
  • User 2026-11-25: on an 80×24 screen the F1 search placeholder may be cut off; this is an accepted space trade-off of adding workspaces.
  • User 2026-11-27: keep the longer placeholder wording even though it is cut off earlier than main's at medium widths; search itself is unchanged.

Linked Closing Issues:

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: 4351415245aa0852985b037f8ee5b8578297eb30

变更摘要

本 PR 为 TUI 的 F1 会话列表(Chat 标签页)新增首列 Workspace,把 #​328 记录的会话与工作区归属关系展示出来。核心是在 presenter.py 中新增 workspace 列与 WorkspaceNames 快照模型,在 screen.py 中于打开浏览器时一次性(线程内)读取工作区注册表并据此完成列宽布局、搜索、排序与 tooltip 展示,同时在 util/formatting.py 中补充 elide_end 并把字形/单元切分工具从 widgets/task_summary.py 上移。运行中会话使用当前生效的工作区名覆盖磁盘记录;无工作区或注册表不可读时表格与 main 保持一致。此外,F1 恢复请求因仍在发送而被跳过时,状态栏会给出提示。

主要改动

  • 新增 Workspace 列与解析模型: presenter.py 新增 WorkspaceNames(by_session、unspecified、has_workspaces)与 workspace_display,COLUMNS 首位加入 workspace 列;WORKFLOW_COLUMNS 改为通过 _COLUMNS_BY_KEY 按 key 引用共享列,并在 _chat_search_cells、chat_match、rank_search_matches、build_session_rows 等入口透传该快照,使展示、搜索与排序共用同一份解析结果。
  • 一次性读取与运行中会话覆盖: SessionsScreen 新增 workspaces 与 current_workspace_name 参数,_read_workspace_names 在 asyncio.to_thread 中读取注册表快照并与会话列表加载并行执行;无工作区时不启用列,读取失败时每次打开只提示一次 warning,运行中会话的工作区名直接覆盖磁盘记录。
  • 列宽布局与增量重排: _column_layout 在存在工作区时始终显示首列,宽度取最长名称(上限 16 单元),列宽不足时先向 directory(不低于 14,中间省略)再向 title(不低于 20)借用,仍不够则保持原宽并横向滚动;_fit_workspace_column 在 on_resize / on_screen_resume 时仅更新宽度变化的列,不重建表格,保留光标、滚动位置与排序。
  • 单元格省略、搜索占位与 tooltip 高亮: 新增 elide_end、iter_cell_graphemes、take_cells 到 util/formatting.py(task_summary.py 改为复用,take_cells 增加纯 ASCII 快速路径),_cell_text 按列宽对 workspace 末尾省略、directory 中部省略;有工作区时切换为含 workspace 的 tui.sessions.search_placeholder.workspace 占位文案,_row_tooltip 对被截断工作区补充完整名称并对整段 tooltip 做搜索词高亮。
  • 文案与恢复提示: registry.py 新增 UNSPECIFIED 标签,chrys.pot / zh-Hans 增加 tui.sessions.column.workspace、tui.sessions.search_placeholder.workspace、tui.sessions.tooltip.workspace、workspaces.unspecified;main/screen.py 新增 _restore_session_or_flash,在恢复被 RestoreRequest.SKIPPED 且仍在提交时调用 flash_submit_still_sending,view_adapter.py 向会话浏览器传入工作区注册表与当前工作区名。

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

head_sha: 4351415245aa0852985b037f8ee5b8578297eb30

代码审查

✅ 未发现问题

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: 4351415245aa0852985b037f8ee5b8578297eb30

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: f16669c4222507f78cf067a5195ee851f4fc3b1d

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: 1ce2ae7ccfbbcc3eeb533bff6dbd38a52ec84704

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Experience Feedback]: 引入[项目]功能

1 participant