Skip to content

feat(desktop): 添加项目与任务快速切换 - #3650

Open
lizzjin wants to merge 5 commits into
makecindy:mainfrom
lizzjin:codex/issue-3458
Open

feat(desktop): 添加项目与任务快速切换#3650
lizzjin wants to merge 5 commits into
makecindy:mainfrom
lizzjin:codex/issue-3458

Conversation

@lizzjin

@lizzjin lizzjin commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

新增项目与任务快速切换入口,减少在侧栏中查找和展开项目的操作。使用 Ctrl+K / Cmd+K 打开后,可按项目名称或任务标题搜索,通过方向键、Enter 或鼠标直接切换,并定位到侧栏中的目标。

Closes #3458

变更类型

  • feat 新功能
  • fix 缺陷修复

范围

  • 支持项目名称、别名与任务标题的混合匹配,按匹配程度、活跃时间和稳定标识排序。
  • 覆盖本地、SSH 项目以及已连接设备中的任务,包含已归档和侧栏当前未加载的历史任务。
  • 打开时自动聚焦,关闭时恢复焦点;支持输入法组合输入、快捷键自定义和草稿保留。
  • 选中结果后切换项目或任务,并临时展开、定位侧栏目标,保留原有筛选和归档状态。
  • 新增只读、分页的任务元数据目录 IPC;使用来源限定标识处理远端任务,兼容旧版或离线设备。
  • 补齐五种语言文案,并修正搜索输入框圆角裁切光标的问题。
  • 排除已失效的近期空目录,保留真实任务所属的本地、SSH 与设备项目。
  • 补齐 WebView 快速切换快捷键的 Main → preload → 主界面转发,遵循当前有效绑定、录制态和交互锁。
  • 修复 exec E2E 的测试隔离:关闭该 fixture 不需要的插件运行时,避免后台 marketplace 下载子进程占用临时目录而使清理超时;不修改生产启动、插件兼容或测试超时。
  • 快速切换只临时展开目标项目,不再改写侧栏折叠偏好;普通与置顶项目一致,保留手动折叠及全部展开/折叠行为。
  • Breaking change:无。

UI 变化

引用的设计规范:docs/design-rules/DESIGN.md §3 Typography Rules、§4 Inputs & Forms / Dialog & Modal、§10 Theme System、§14.2 Focus Management、§15.11 Input Caret。弹窗使用规定的字号、间距和圆角,颜色与焦点样式使用主题语义 token;输入框继承全局光标颜色,圆角由外层容器承载,保证光标完整显示。

以下为真实 Desktop 运行截图:Windows x64,Electron 41.10.3,2026-08-30;分别使用 Cindy Light 与 Cindy Dark。截图对应本 PR 提交 533084c696ebad92bf1bda2fe8ff370e29218f5c 中的界面代码。

Cindy Light Cindy Dark
Windows Cindy Light:快速切换弹窗与完整输入光标 Windows Cindy Dark:快速切换弹窗与完整输入光标

怎么验证的

原功能提交的自动验证

  • pnpm test:unit:related:通过,覆盖 Desktop、Mobile 和 device-link 的相关单测门禁。
  • pnpm --filter desktop run --if-present typecheck:通过。
  • pnpm --filter @cindy/device-link build:通过。
  • pnpm --filter desktop exec vitest run src/renderer/__tests__/quickSwitcherDialog.test.tsx:20 项通过。
  • pnpm check:i18npnpm check:i18n-glossary:通过。
  • pnpm check:dco:通过。
  • 专项测试覆盖真实 SQLite 分页目录、IPC 参数与来源校验、匹配排序、输入法、快速连续按键、异步过期响应及侧栏定位。

前两条评审修复验证

  • 定向运行 quickSwitcher、quickSwitcherDialog、webview-security、browserShortcutBridge、appShortcuts、csp 和 codexExecFunctionAdapter.e2e 七个测试文件:139 项通过。
  • 覆盖失效空目录过滤与真实项目保留、三平台默认键和自定义绑定、旧绑定冲突让路、当前 WebView 宿主转发、输入法与重复按键、实际 preload 白名单及事件剥离、弹窗聚焦与订阅清理。
  • 首次门禁在 codexExecFunctionAdapter.e2e.test.ts 的 afterEach 清理阶段超时,定位为测试 app-server 的后台插件下载。修复后定向 E2E 保留真实 commandExecution,诊断中不再出现 Git 下载子进程,临时目录清理约 115ms。
  • 对修复后的最终快照重新运行 pnpm test:unit:related:通过,Desktop 374.8s、Mobile 26.8s、device-link 1.2s;未跳过或放宽原断言、未提高测试超时。
  • pnpm --filter desktop run --if-present typecheckpnpm --filter @cindy/device-link build:通过。device-link 的 --if-present typecheck 没有对应脚本,不计为类型检查证据,类型验证来自 build 中的 tsc。
  • 本轮没有重新启动实机验证 WebView 入口,也没有新增 macOS / Linux 实机或 Light / Dark 目检;下方手工验收和截图属于原功能提交。本轮未修改布局、样式、颜色或文案。

P2:语音快捷键冲突修复验证

  • WebView 转发与 Renderer 共用语音键位转换,将当前语音绑定传入有效快捷键表;Ctrl/Cmd+K 被语音占用时不再拦截按键或打开快速切换器。改绑或清除立即生效,Fn 与纯修饰键保留原生路径。
  • 定向运行 webview-security、appShortcutConflict、AppShortcutStore、VoiceInputDataStore 四个测试文件:78 项通过;覆盖三平台绑定冲突、运行时变更与清空、原生键不冲突、外部让位不落盘和快捷键快照隔离。
  • 最终快照的 pnpm test:unit:related 通过:Desktop 371.3s、Mobile 27.6s、device-link 1.1s。
  • pnpm --filter desktop run --if-present typecheckpnpm --filter @cindy/device-link run build 通过;device-link 无 typecheck script,其 --if-present typecheck 为无操作,实际类型验证来自 build 中的 tsc。
  • 未重新进行实机、macOS/Linux 或 Light/Dark 目检;未改布局、样式、文案、持久化格式或 WebView 权限。按键路径仅读取快捷键,不复制语音历史或词典。

P1:快速切换临时展开修复验证

  • 移除快速切换路径的持久化 collapse.expand(),仅在 quickFocus 有效期间投影目标项目为展开;结束临时定位后读取原折叠记录,手动操作仍按用户意图保存。普通项目、置顶项目及折叠提醒使用同一显示状态。
  • 先用真实折叠存储和快速切换状态稳定复现目标折叠记录被删除,再修复转绿。新增 11 项行为回归;定向运行临时展开、owner 隔离、侧栏定位、快速切换弹窗、置顶项目接线与折叠提醒六个文件,64 项通过。
  • 首轮相关门禁唯一失败为折叠提醒源码契约仍引用旧显示变量。同步并补强普通/置顶项目可见状态断言后,重新冻结并完整运行 pnpm test:unit:related:通过,Desktop 368.6s、Mobile 28.1s、device-link 1.2s;未跳过或放宽原测试。
  • pnpm --filter desktop run --if-present typecheckpnpm --filter @cindy/device-link run build 通过;device-link 无 typecheck script,--if-present typecheck 为无操作,实际类型验证来自 build 中的 tsc。提交前再次预检通过,并核对最终快照的验证凭据一致。
  • 引用 docs/design-rules/DESIGN.md §10 Theme System / Light-Dark Dual-Mode Delivery Gate、§14.2 Focus Management。未改布局、样式、颜色、文案、存储格式或 IPC/权限边界;未重新进行实机、macOS/Linux 或 Light/Dark 目检,原截图不代表本轮已目检。

最新 P2 与 Linux CI 修复验证

  • 目录的消息存在性查询不再过滤 rewind_at,与 sessions:list/get 的物理消息口径一致;userSendAt 为空且全部消息已 rewind 的旧任务或导入任务仍归入项目,可按项目名搜索。保持索引存在性查询,不读取消息正文、不统计完整历史。
  • Linux CI 失败来自测试未区分已有平台策略:Windows/macOS 保留快捷键快照隔离和清除断言,Linux 单独验证快捷键保持禁用及重载行为;未修改语音生产逻辑。
  • 先复现项目搜索返回 0 条及 Linux 分支返回 null 的失败,再修复。定向运行 quickSwitcher 数据库查询、sessionListMessageCount、项目分组/搜索、VoiceInputDataStore 和 voiceInputData 六个测试文件,94 项通过。
  • 最终快照的 pnpm test:unit:related 通过:Desktop 396.9s、Mobile 35.7s、device-link 1.2s。pnpm --filter desktop run --if-present typecheckpnpm --filter @cindy/device-link run build 通过;device-link 无 typecheck script,其 --if-present typecheck 为无操作,类型证据来自 build 中的 tsc。发布前预检和同快照测试凭据再次核对通过。
  • Windows 扩展定向验证曾在线程池中发生原生进程崩溃;改用仓库为 Windows 选择的 forks 池后,同一范围及最终门禁通过。没有跳过断言、放宽超时或修改测试调度。
  • 本轮平台策略分支在 Windows 本机模拟验证,尚未原生 Linux/macOS 或实机 UI 验证;新提交的远端 CI 结果以检查状态为准。未改 schema、migration、用户数据格式、权限边界、布局、样式或文案;原截图不代表本轮已目检。回滚本次提交只恢复目录读取口径及测试,不涉及数据迁移。

手工验证

在 Windows 的隔离 Desktop 实例中,以本地模式完成快捷键打开、搜索匹配、键盘与鼠标选择、项目与归档任务跳转、关闭后焦点与草稿保留、侧栏展开定位及快捷键修改验收。

在 Cindy Light / Cindy Dark 两种主题下检查了真实弹窗、自动聚焦和完整输入光标,截图见上方。

风险

风险分类

  • SQLite 读取
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 跨平台差异

影响与回滚

  • 影响范围:Desktop 快速切换弹窗、侧栏临时定位、快捷键注册,以及 device-link 的只读目录调用白名单。
  • 数据与权限:目录只读取任务元数据,沿用现有本地和已连接设备的授权边界;选择任务前重新校验来源及可访问状态。数据库结构和现有用户数据格式保持兼容。
  • WebView 转发复用现有宿主通道和 preload 白名单,不开放新的 guest IPC 权限;事件不暴露给 renderer,按当前宿主与有效绑定处理,重复信号不关闭弹窗,卸载时释放订阅。E2E 修复仅作用于独立临时 CODEX_HOME,不触及用户配置与已装插件。
  • 兼容与降级:旧版、不支持目录接口或离线的设备显示结果不完整提示,本地结果仍可使用;Windows / Linux 与 macOS 通过现有快捷键系统映射 Ctrl / Cmd。
  • 回滚方式:回退本 PR 提交即可移除入口和新增目录接口;现有任务、草稿与侧栏持久偏好保持原样。

提交前检查

  • 已 review 完整 diff
  • 提交带有与作者一致的 DCO Signed-off-by 签名
  • UI 改动已注明设计规范章节并附实机截图
  • 提交内容已检查,凭证、令牌和授权文件均未进入变更
  • 已核对自动验证和手工验收结果

支持按项目名称和任务标题搜索、键盘切换及侧栏定位,包含已归档历史任务和已连接设备来源。
补齐分页元数据目录、交互与边界测试,以及浅色和深色实机截图。

Signed-off-by: lizzjin <lizzjin37@gmail.com>
@lizzjin
lizzjin requested a review from a team as a code owner August 30, 2026 15:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T16:42:45.042983Z bee3f02 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

新增 Desktop 项目与任务快速切换器,支持本地及连接设备目录搜索、快捷键导航、侧栏定位和历史任务分页读取。

  • 增加受校验的只读任务目录 IPC、预加载桥接及 device-link 白名单
  • 增加项目与任务的模糊匹配、来源隔离、排序和选择前复核
  • 增加临时侧栏展开/聚焦状态以及五种语言文案
  • 补充数据库、IPC、搜索、交互、远程来源和侧栏定位测试

Confidence Score: 4/5

合并前应修复失效近期目录仍作为可选项目展示的问题,否则用户会遇到必然失败的快速切换结果。

快速切换项目构建忽略 recentWorkdirs 的 exists 状态,而选择路径明确拒绝同一失效目录,造成搜索结果与可执行操作不一致。

Files Needing Attention: apps/desktop/src/renderer/features/cc-agent/lib/quickSwitcher.ts

Important Files Changed

Filename Overview
apps/desktop/src/renderer/features/cc-agent/QuickSwitcher.tsx 实现目录聚合、异步失效保护、来源复核、导航与完整的弹窗键盘交互。
apps/desktop/src/renderer/features/cc-agent/lib/quickSwitcher.ts 实现项目构建及模糊排序,但会把 exists=false 的近期目录暴露为无法打开的项目结果。
apps/desktop/src/main/localDb/quickSwitcher.ts 以稳定游标分页读取可见任务元数据,并排除已删除任务和 worker。
apps/desktop/src/main/localDb/ipc/search.ts 新目录 IPC 对本地发送方、device-link 调用、游标和错误信息进行了边界处理。
apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx 增加快速切换目标的临时过滤覆盖、历史任务注入、项目展开和侧栏定位。
packages/device-link/src/allowlist.ts 将只读分页目录通道加入默认拒绝的远程调用白名单。

Sequence Diagram

sequenceDiagram
  participant U as 用户
  participant R as QuickSwitcher
  participant P as Preload
  participant M as Desktop Main
  participant D as 本地或远程数据库
  U->>R: Ctrl/Cmd+K 并输入查询
  R->>P: 请求分页任务目录
  P->>M: local-db:conversations:catalog
  M->>M: 校验发送方、来源和游标
  M->>D: 读取任务元数据
  D-->>M: 分页目录
  M-->>R: 项目与任务候选
  U->>R: 选择结果
  R->>D: 按明确来源重新读取目标
  R->>R: 切换路由并临时展开侧栏
Loading
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/renderer/features/cc-agent/lib/quickSwitcher.ts:62-64
**失效目录仍可被选择**`recentWorkdirs.list` 返回目录已删除、迁移、无权访问或网络盘断开而 `exists=false` 的条目时,这里仍将其加入可搜索的空项目列表;选择逻辑随后必然拒绝该目录,导致用户点击正常展示的结果后只能收到“任务或目录已不存在”。

```suggestion
  for (const dir of recent) {
    if (!dir.exists) continue;
    const workingDir = normalizeWorkingDir(dir.path);
    if (!workingDir) continue;
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(desktop): 添加项目与任务快速切换" | Re-trigger Greptile

Comment thread apps/desktop/src/renderer/features/cc-agent/lib/quickSwitcher.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 533084c696

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/features/cc-agent/QuickSwitcher.tsx
过滤失效的近期空目录,保留真实任务与远端项目。
通过现有受限通道转发 WebView 快速切换快捷键,沿用有效绑定、交互锁和焦点恢复规则。
补充目录、跨平台按键、preload 过滤与弹窗回归测试。
隔离 exec E2E 的插件运行时,避免后台下载子进程占用临时目录导致清理超时。

Signed-off-by: lizzjin <lizzjin37@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b00646b55

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/webview-security.ts Outdated
Main 使用与 Renderer 相同的语音键位转换和外部让位组合。
实时读取当前语音快捷键,改绑或清除后立即更新,避免按键路径复制词典和历史。
补充三平台冲突、改绑、清空和原生快捷键回归测试。

Signed-off-by: lizzjin <lizzjin37@gmail.com>
@MagicLizi MagicLizi added touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:large-diff 改动量较大(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) touches:security 改动碰到安全边界(review-pr 自动维护,仅展示) labels Aug 30, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

这条 PR 需要维护者确认后才能合并:新产品交互(项目/任务快速切换),并触及 preload/webview 安全边界和核心路径。

请维护者在 PR 上 Approve;若要改,请 Request Changes。讨论 issue:#3654

@MagicLizi MagicLizi added the awaiting-discussion 等待维护者讨论(review-pr) label Aug 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2baddf65dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@lizzjin 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

快速切换只投影目标项目的展开状态,不再调用持久化 expand。
普通与置顶项目共用临时状态,手动折叠及全部展开/折叠仍保留显式偏好。
补充导航恢复、重新挂载、账号隔离与手动操作回归,并同步折叠提醒接线测试。

Signed-off-by: lizzjin <lizzjin37@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bee3f02ca5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/localDb/quickSwitcher.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@lizzjin 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/localDb/quickSwitcher.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

目录消息存在性判断包含 rewind 记录,保持物理消息分组口径。
补充旧任务和导入任务的项目搜索回归,并分别验证三平台语音快捷键策略。

Signed-off-by: lizzjin <lizzjin37@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:large-diff 改动量较大(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) touches:security 改动碰到安全边界(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

增加 Ctrl+K 模糊搜索以快速定位会话和项目

2 participants