Skip to content

feat(desktop): 输入框推荐提示词,回复结束后预测下一句并支持 Tab 填入 - #1965

Open
Shinku-Chen wants to merge 122 commits into
makecindy:mainfrom
Shinku-Chen:cindy/auto-hffm9o
Open

feat(desktop): 输入框推荐提示词,回复结束后预测下一句并支持 Tab 填入#1965
Shinku-Chen wants to merge 122 commits into
makecindy:mainfrom
Shinku-Chen:cindy/auto-hffm9o

Conversation

@Shinku-Chen

@Shinku-Chen Shinku-Chen commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

一轮回复结束、输入框为空时,向 provider 发一次轻量 one-shot 预测用户下一句想输入什么,以 placeholder 形态展示;按 Tab 一键填入。设置 →「小技巧」里可关闭(默认开启)。

不新造模型调用通路:复用会话标题 one-shot 那套 provider / 凭证 / model routing(同一个最经济模型),所以不额外配 endpoint、不引入新的外发面。

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:无(用户直接提出)
  • 本 PR 包含:
    • 新增 maker:predict-prompt IPC + maker-ipc/promptPrediction.ts(取最近 3 轮 user/assistant 作素材,截断后走 one-shot)
    • 采纳 main 的 title-one-shot.ts 命名与 TitleOneShotResult 结构化返回,并重新加回可选 OneShotOpts
    • ChatInput:turn 结束检测、推荐展示、Tab 填入
    • usePromptRecommendationPreference hook(模块级内存 SoT + listeners + storage 跨窗口同步)
    • makerChatStore: pendingTaskWake 加入 SessionChatLightState,纳入 isAgentBusy 计算
    • 设置开关(默认开启)+ zh-CN / en / ja / ko 文案
    • 顺带修发送后光标丢失
    • 合并冲突解决、恢复 host-capability 插件入口路径、修复 review P1
  • 明确不包含:
    • 不做失败兜底文案。预测失败/无已连接 provider/超时一律静默
    • 推荐不落库、不进 device-link、不参与发送内容
    • 未改 mobile、未改 system prompt、未动 DB schema
  • 用户可见变化:
    1. 回复结束且输入框为空 → placeholder 变成预测的下一句,Tab 填入
    2. 设置 →「小技巧」多一个「输入框推荐提示词」开关
    3. 回车/点击发送后光标留在输入框
  • 是否存在 breaking change:无

UI 变化

image

改动两处:输入框 placeholder 位置的推荐词,设置里新增一行开关 cell。

  • 引用的设计规范:DESIGN.md §1 视觉与氛围、§2 颜色令牌。无新视觉语言,输入框推荐词以 placeholder 形态复用现有输入框样式,设置开关 cell 复用现有设置列表行组件。

怎么验证的

自动验证

pnpm --filter desktop run --if-present typecheck
结果:通过

pnpm check:i18n-glossary
结果:通过

pnpm check:dco
结果:通过

# 本次改动直接波及的测试
titleOneShot / authAdaptersImportPurity / autoTitleIpcBoundary / regenerateSessionTitle
结果:4 files / 97 tests 全通过

# composer / ChatInput 相关渲染层
chatInputSessionFocus / chatInputModelSelectorRouting / chatInputListContinuation 等
结果:5 files / 29 tests 全通过

# store 相关
makerChatStoreTaskUpdates / makerQueueState
结果:2 files / 60 tests 全通过

# useCCAgentChat
useCCAgentChatHiddenFreeze
结果:1 file / 6 tests 全通过

# plan-mode 回归
planModeRosterDelay / planModeComposerCommand / slashCommandRosterState
结果:3 files / 10 tests 全通过

手工验证

在 dev 模式下反复走通了主流程:发消息 → 等回复结束 → placeholder 变推荐词 → Tab 填入 → 发送。

未执行的验证

  1. pnpm test:unit 未完整跑绿。desktop 和 cindy-tools 的 TEST_COLLECT_FAILED 为基线问题,与本次改动无关。
  2. Light / Dark 未做实机目检。颜色走语义 token、light/dark 均有定义。
  3. 未在 Windows 验证。焦点改动只在 macOS 上验过。
  4. 未验 device-link 远端会话下的预测与焦点还原。

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:新增一条按 turn 触发的付费模型调用

影响与回滚

  • 影响范围:Desktop 输入框、设置「小技巧」区、makerChatStore LightState。
  • 回滚 / 降级方式:git revert,无 migration、无持久化状态、无协议变更。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名
  • UI 改动已在「UI 变化」注明引用的设计规范章节
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档(未新增/修改 docs)
  • 已确认测试结果或说明未执行原因

Review 反馈处理(第五十六轮)

# 来源 问题 处理
1 chatgpt-codex-connector P1: drain 后 workingDir 未重读,切换项目后预测包含过期路径 修复:drain 后资格复核 SELECT 增加 workingDir: sessions.workingDir,预测时用 latestSessionRow.workingDir。Commit: 2ad1f14
2 chatgpt-codex-connector P1: 默认 provider 会话(provider_id 为 NULL)预测被 beforeDispatch 静默跳过 修复:row.providerId != null && 时才拦截,DB 无显式 provider 不存在 TOCTOU 风险。Commit: 2bda7f2
3 chatgpt-codex-connector P2: 多窗口飞行中预测不共享,后台窗口赢得竞态时聚焦窗口不显示推荐 同意,建议后续 PR 加 per-session Promise 缓存。不阻塞当前 PR 合并。
4 chatgpt-codex-connector P2: zh-TW updateAll 对象内重复 key 导致静默值覆盖 修复:移除重复 key(collapseDiff / permissionChanged / rereview 等),保留去重后的 key 集合。Commit: 2ad1f14
5 MagicLizi P1: dispatchSend 依赖数组缺 slashCommandsReady / mergedCommands,形成 stale closure 修复:slashCommandsReady 和 mergedCommands 已加回 useCallback 依赖数组(ChatInput.tsx:5258-5259),/plan 命令在 roster 延迟加载后仍可正确生效。Commit: ce49212
6 greptile-apps P1: SSH 归属不会重处理交接 - remoteHostId 解析后 effect 不重跑,pendingHostCapabilityGhostId 残留 修复:effect 依赖数组补 remoteHostId,SSH 归属解析后 effect 重跑并清理交接状态。Commit: 34b4385

基线同步

  • 2026-08-14:合并 latest upstream/main(211 commits),解决 auto-merge 冲突。Typecheck 与 related unit tests 通过(2 个基线失败与 PR 无关:ghostInstallReceipt 2 个,在 upstream/main 亦复现)。新增:修复 greptile P1(SSH 归属 handoff 依赖数组缺 remoteHostId,Commit: 34b4385)。

Review 反馈处理(第五十七轮)

# 来源 问题 处理
1 chatgpt-codex-connector P1: 显式 provider 需验证仍连接 — 用户断开/登出显式 provider 时 connected-provider rail 已不含该 provider 修复:beforeDispatch 显式 provider 分支新增 listConnectedProvidersForAgent 复核。Commit: d5d8d62
2 chatgpt-codex-connector P1: 默认 provider rail 断开时 fail-closed — providers 为空时原条件仍放行 修复:providers.length === 0 时 fail-closed 中止。Commit: d5d8d62
3 chatgpt-codex-connector P1: 默认 provider 比对用 nativeDefaultSourceId 而非 providers[0] — Claude Code 优先 XD 而非 Anthropic 时 rail 顺序不匹配 修复:默认 provider 比对改用 nativeDefaultSourceId(providers, agentKind) 匹配 generateTitleViaProviderResult 的解析口径。Commit: 9fdb0d6
4 greptile-apps P1: SSH 归属仍未清理交接 — remoteHostId 已解析为 SSH 而 dlDeviceId 未解析时,pendingHostCapabilityGhostId 残留 修复:dlDeviceId === undefined 分支增加 !remoteHostIdRef.current 条件,SSH 会话直接清除 pendingHostCapabilityGhostId。Commit: 9fdb0d6

🤖 Generated with Claude Code

@Shinku-Chen
Shinku-Chen requested a review from zqchris as a code owner August 6, 2026 14:53
Copilot AI lite review requested due to automatic review settings August 6, 2026 14:53
@Shinku-Chen
Shinku-Chen requested a review from a team as a code owner August 6, 2026 14:53
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 为桌面端会话加入回复结束后的下一句提示预测、Tab 填入和偏好设置,并复用现有 one-shot provider 路由。

  • 新增受信 IPC、数据库素材读取、provider 派发前资格复核及输出约束
  • 在 ChatInput 中加入预测触发、会话/轮次失效与发送后焦点恢复
  • 扩展聊天 light state,以桥接后台任务终态到 wake turn 启动之间的 busy 状态
  • 新增设置开关、本地化文案及相关回归测试

Confidence Score: 4/5

该 PR 在多个 wake 型后台任务同时等待后续 turn 时仍可能提前结束 busy 状态并触发额外付费预测,修复后再合并更安全。

pendingTaskWake 是所有后台任务共享的布尔状态,而任一 wake turn 启动都会将其清除;存在第二个任务仍等待 wake turn 时,第一个 wake turn 结束会暴露虚假的完成空窗。

Files Needing Attention: apps/desktop/src/renderer/lib/makerChatStore.ts, apps/desktop/src/renderer/hooks/useCCAgentChat.ts

Important Files Changed

Filename Overview
apps/desktop/src/main/maker-ipc/promptPrediction.ts 新增基于数据库上下文的 one-shot 推荐生成,并在付费派发前复核会话、provider、远程归属和工作目录。
apps/desktop/src/main/maker-ipc/title.ts 注册受信的预测 IPC,校验请求并在读取素材前后执行会话资格检查和同会话并发去重。
apps/desktop/src/renderer/components/new-chat/ChatInput.tsx 集成推荐触发、Tab 采纳、会话及轮次失效、能力芯片归属修复和发送后焦点恢复。
apps/desktop/src/renderer/lib/makerChatStore.ts 将 wake 桥接状态纳入 light state,但共享布尔标记无法同时表示多个等待 wake turn 的后台任务。
apps/desktop/src/renderer/hooks/useCCAgentChat.ts pendingTaskWake 纳入本地会话 busy 计算,消费 store 提供的 wake 桥接状态。
apps/desktop/src/renderer/hooks/usePromptRecommendationPreference.ts 新增默认开启、支持同进程订阅和 storage 跨窗口同步的推荐偏好状态。
apps/desktop/src/main/maker-host/title-one-shot.ts 扩展 one-shot 通路以支持派发前异步复核、系统提示和预测场景的 token、校验及截断参数。

Sequence Diagram

sequenceDiagram
  participant Main as Main turn
  participant T1 as Wake task A
  participant T2 as Wake task B
  participant Store as makerChatStore
  participant Input as ChatInput
  Main->>Store: Done
  T1->>Store: terminal
  Store->>Store: "pendingTaskWake = true"
  T2->>Store: terminal
  Store->>Store: pendingTaskWake remains true
  T1->>Store: wake turn starts
  Store->>Store: "pendingTaskWake = false"
  T1->>Store: wake turn ends
  Store-->>Input: "busy = false"
  Input->>Input: trigger premature prediction
  T2->>Store: wake turn starts later
Loading
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/renderer/lib/makerChatStore.ts:5859-5869
**多任务 Wake 桥接提前清除**

如果两个 wake 型 `local_agent``local_workflow` 任务在主轮结束附近先后进入终态,两个任务会共享同一个 `pendingTaskWake` 布尔标记,而第一个 wake turn 启动时会无条件清除该标记。第一个 wake turn 结束后,第二个任务尚未启动的空窗因此被识别为会话完成,导致 ChatInput 使用不完整上下文发起额外付费预测,并产生 spinner 闪烁。

---

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

Reviews (118): Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." | Re-trigger Greptile

Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated
Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated

@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: ef98c0d809

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated
Comment thread apps/desktop/src/main/maker-ipc/title.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

本 PR 为 Desktop 新增“输入框推荐提示词”能力:在一轮 AI 回复结束且输入框为空时,主进程通过复用既有 title one-shot provider 通路做一次轻量预测,将预测的下一句以输入框 overlay/placeholder 形式展示,并支持按 Tab 一键填入;同时在设置「小技巧」中提供开关(默认开启)。

Changes:

  • 新增 maker:predict-prompt IPC 与主进程 promptPrediction 逻辑,复用 provider one-shot(原 title one-shot)通路并可覆盖 maxTokens/输出约束。
  • Renderer 侧 ChatInput 增加 turn 结束检测、推荐展示与 Tab 填入,并修复发送后焦点丢失。
  • 设置页新增开关 cell,并补齐 zh-CN/en/ja/ko 文案与相应样式支持。

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
apps/desktop/src/renderer/vite-env.d.ts 为 renderer 侧补充 electronAPI.maker.predictNextPrompt 类型声明
apps/desktop/src/renderer/styles/globals.css 推荐 overlay 生效时禁用原生 placeholder 的 CSS 规则
apps/desktop/src/renderer/i18n/locales/zh-CN/common.json 新增设置项文案(中文)
apps/desktop/src/renderer/i18n/locales/en/common.json 新增设置项文案(英文)
apps/desktop/src/renderer/i18n/locales/ja/common.json 新增设置项文案(日文)
apps/desktop/src/renderer/i18n/locales/ko/common.json 新增设置项文案(韩文)
apps/desktop/src/renderer/components/settings/TipsSection.tsx 设置页「小技巧」新增“输入框推荐提示词”开关
apps/desktop/src/renderer/components/new-chat/ChatInput.tsx turn 结束触发预测、overlay 展示、Tab 填入、发送后焦点还原等 UI/交互改动
apps/desktop/src/preload/preload.ts 在 preload bridge 中暴露 maker:predict-prompt invoke
apps/desktop/src/main/maker-ipc/channels.ts 新增 IPC channel 常量 MAKER_INVOKE.PREDICT_PROMPT
apps/desktop/src/main/maker-ipc/title.ts 注册新 IPC handler、增加 payload 运行期校验并接入 prompt prediction
apps/desktop/src/main/maker-ipc/promptPrediction.ts 新增 prompt prediction 的上下文抽取、prompt 构建与 one-shot 调用编排
apps/desktop/src/main/maker-host/provider-one-shot.ts title-one-shot 重命名并参数化为通用 one-shot(支持 opts 覆盖)
apps/desktop/src/main/maker-host/model-discovery/anthropic.ts 文档注释随重命名更新引用
apps/desktop/src/main/maker-host/active-catalog.ts 文档注释随重命名更新引用
apps/desktop/src/main/maker-ipc/tests/regenerateSessionTitle.test.ts 测试随 one-shot 重命名更新 mock/import
apps/desktop/src/main/maker-ipc/tests/autoTitleIpcBoundary.test.ts 测试随 one-shot 重命名更新 mock
apps/desktop/src/main/maker-host/tests/titleOneShot.test.ts 测试随 one-shot 重命名与导出更新
apps/desktop/src/main/maker-host/tests/authAdaptersImportPurity.test.ts 测试注释随重命名更新
Suppressed comments (1)

apps/desktop/src/main/maker-host/provider-one-shot.ts:550

  • provider-one-shot 已不再是“仅标题”用途(prompt prediction 也复用),但日志文案仍大量使用 title oneShot ...(包括 done/failed/rejected 等)。这会让线上排查难以区分到底是标题链路还是其它 one-shot 调用触发的日志。

建议把日志前缀文案统一改为更通用的 provider oneShot/oneShot,或在日志字段里显式记录调用场景(title vs prediction)。


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated
Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts
Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts
Comment thread apps/desktop/src/renderer/components/settings/TipsSection.tsx Outdated
Copilot AI review requested due to automatic review settings August 6, 2026 15:16
Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated

@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: 08548a4d22

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
Comment thread apps/desktop/src/main/maker-ipc/title.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated no new comments.

Suppressed comments (4)

apps/desktop/src/renderer/components/new-chat/ChatInput.tsx:5905

  • showRecommendationOverlay 没有受 recommendationEnabled 控制:用户在设置里关闭开关后,如果当前已经有推荐词,overlay 仍会继续显示(直到输入/下一轮 turn 才消失),与“切换立即生效”不一致。建议把开关纳入可见判据。
  // 推荐 overlay 的唯一可见判据:有推荐词 + 输入框空 + 不在语音态。
  const showRecommendationOverlay = !!recommendedPrompt && !hasMessage && !voiceInput.isBusy;
  const hasVoiceDraftText = voiceInput.draftText.trim().length > 0;

apps/desktop/src/renderer/components/settings/TipsSection.tsx:17

  • useState 在本文件中未使用,会导致 TS/ESLint 的 unused import 报错。建议移除该 import。
import { useState } from 'react';
import { useTranslation } from 'react-i18next';

apps/desktop/src/renderer/components/new-chat/ChatInput.tsx:963

  • 关闭“输入框推荐提示词”开关时,当前组件仍保留 recommendedPrompt/showRecommendationRef 的状态;如果用户很快再打开开关,旧推荐可能会重新出现。建议在 recommendationEnabled 变为 false 时同步清空推荐相关状态,避免状态残留。

This issue also appears on line 5903 of the same file.

  const recommendedPromptRef = useRef<string | null>(null);
  recommendedPromptRef.current = recommendedPrompt;
  const showRecommendationRef = useRef(false);
  const resolvedPlaceholder = placeholder ?? t('newChat.chatInput.defaultPlaceholder');

apps/desktop/src/main/maker-ipc/promptPrediction.ts:123

  • PromptPredictionParams 暴露了 workingDir,且 IPC 层也会解析/截断该字段,但 generatePromptPrediction 全程未使用它来构建 prompt 或路由参数,导致 IPC 契约与实际行为不一致、并增加后续维护成本。建议要么删掉该字段(同步更新 preload/vite-env/title.ts 的 request 解析),要么明确把它纳入 prompt(同时评估是否会把本地路径外发)。
export interface PromptPredictionParams {
  sessionId: string;
  agentKind: AgentKind;
  messages: SlimMessage[];
  workingDir?: string;
}

Copilot AI review requested due to automatic review settings August 6, 2026 15:35

@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: 3dc2ccc290

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated
Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated no new comments.

Suppressed comments (4)

apps/desktop/src/main/maker-host/provider-one-shot.ts:604

  • runProviderOneShot 已被复用于非标题场景,但失败日志仍写 "title oneShot",建议改为更通用的日志前缀以避免误导。
    apps/desktop/src/main/maker-host/provider-one-shot.ts:587
  • runProviderOneShot 已被 prompt prediction 复用,但该日志仍写 "title oneShot",会让排查与用量统计难以区分标题与其它 one-shot 场景。建议改为更通用的日志前缀(如 "provider oneShot" / "oneShot")。

This issue also appears in the following locations of the same file:

  • line 597
  • line 604
    apps/desktop/src/main/maker-host/provider-one-shot.ts:597
  • runProviderOneShot 已被 prompt prediction 复用,但成功日志仍写 "title oneShot",会让排查与用量统计难以区分标题与其它 one-shot 场景。建议改为更通用的日志前缀(如 "provider oneShot" / "oneShot")。
    apps/desktop/src/renderer/components/settings/TipsSection.tsx:17
  • useState 在该组件中未使用,建议移除以避免无意义的依赖与潜在的 noUnusedLocals/noUnusedParameters 报错。
import { useState } from 'react';
import { useTranslation } from 'react-i18next';

Copilot AI review requested due to automatic review settings August 6, 2026 15:46
Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx

@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: 96294011e4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) labels Aug 6, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

本 PR 触发了维护者确认门(product: 新功能 feat + 命中 UI 路径)。

新增输入框推荐提示词与 Tab 填入能力,属于新产品交互功能。已开启讨论 issue 待维护者确认。

维护者在 PR 上 Approve 即放行;需要修改请 Request Changes。

讨论 issue:#1974

Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated

@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: 71131c6b95

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-ipc/title.ts Outdated
Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings August 6, 2026 16:34
- beforeDispatch 回调新增 providerId 参数,由 generateTitleViaProviderResult
  传入已解析的 providerId(凭证解析口径)
- promptPrediction.ts 的 beforeDispatch 改为用已解析的 providerId 与当前 DB
  值比对,不再比较两次 DB 读,避免会话在 provider 解析后、派发前被切换时
  两次 DB 读都返回新值导致比对通过,但凭证已用旧 provider 解析的 TOCTOU 漏洞
- 同步更新 titleOneShot.test.ts 的 beforeDispatch 调用断言

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.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: 79694cd2fb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-ipc/title.ts Outdated

@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: 3e6ffbbf36

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts Outdated

@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: 422b131b43

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-ipc/title.ts
Comment thread apps/desktop/src/renderer/i18n/locales/zh-TW/common.json Outdated
Shinku-Chen and others added 2 commits August 14, 2026 17:24
beforeDispatch 用 row.providerId !== resolvedProviderId 比对时,
DB 中 provider_id 为 null(未显式设置)的会话,resolvedProviderId
为默认 provider(如 "xd"),null !== "xd" 恒为 true,导致所有
未显式设 provider 的会话预测被静默跳过,Tab 推荐提示词不出现。

修复:row.providerId 为 null/undefined 时跳过比对——
默认 provider 不存在 TOCTOU 风险,无需拦截。

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.com>
- promptPrediction: drain 后资格复核新增 workingDir 字段,用最新值
  替代 drain 前的 sessionRow.workingDir,避免切换项目后预测 prompt
  包含过期路径
- zh-TW/common.json: 移除 updateAll 对象内重复 key(collapseDiff /
  permissionChanged / rereview / reviewDiff / reviewOutdated /
  approve / skip),消除 JSON 重复键导致的静默值覆盖

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.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: 2ad1f149c9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated
Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts
Comment thread apps/desktop/src/renderer/lib/makerChatStore.ts Outdated
- 保留 PR 分支的参数化 maxTokens 与 messages(含 systemPrompt 支持)
- 合入 upstream 新增的 thinking: TITLE_GATEWAY_THINKING 网关配置

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.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: a519dad8d2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts Outdated
Shinku-Chen and others added 2 commits August 14, 2026 18:48
remoteDeviceId 参数类型为 string | undefined,deviceLinkDeviceId 为 string | null | undefined,
合并 main 后新增的 syncSessionDraftModelPrefs 调用直接传 deviceLinkDeviceId 导致 CI typecheck 失败。

Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- ChatInput: 在 effect 依赖中加入 deviceLinkDeviceId,确保归属解析后
  Host capability 芯片 handoff 能重试
- promptPrediction: beforeDispatch 紧前复查 workingDir,防止工作目录
  切换后外发过期本地路径
- promptPrediction: 默认 provider 为 null 时重新计算当前有效默认
  provider 与 resolvedProviderId 比对,防止默认 provider 变更后路由
  到过期 provider/账号
- makerChatStore: Stop 后 turnStoppedByUser 为 true 时跳过跨 turn
  wake 桥接,防止被中断的 wake 任务完成后误设桥接导致会话卡住

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.com>
@Shinku-Chen

Copy link
Copy Markdown
Contributor Author

最新 commit (e5124b241) 修复了 4 个 P1 TOCTOU 竞态问题

Review Thread 修复
ChatInput Host handoff 归属解析后重试 effect 依赖加入 deviceLinkDeviceId,归属解析后重跑
promptPrediction 复查 workingDir beforeDispatch SELECT 新增 workingDir 并比对
makerChatStore Stop 后不桥接 wake mainTurnDoneNotCrossed 加入 !turnStoppedByUser 前置条件
promptPrediction 默认 provider 变更重算 provider_id 为 null 时重新计算当前默认 provider 比对

所有 4 个 thread 已回复并 resolve。

@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: ce492129c6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts
Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts Outdated
@Shinku-Chen

Copy link
Copy Markdown
Contributor Author

MagicLizi 的 P1 反馈(dispatchSend 依赖数组缺 slashCommandsReady / mergedCommands 导致 stale closure)已在最新 commit 中修复:slashCommandsReadymergedCommands 已加回 dispatchSend 的 useCallback 依赖数组(ChatInput.tsx:5258-5259)。请重新审查。

@Shinku-Chen

Copy link
Copy Markdown
Contributor Author

@MagicLizi 已修复:最新 commit ce49212 已将 slashCommandsReadymergedCommands 加回 dispatchSenduseCallback 依赖数组(第 5258-5259 行),消除 stale closure 风险。请重新审查。

- 显式 provider: 新增已连接列表复核,用户在凭证解析后断开/登出显式 provider 时
  fail-closed 中止,避免用过期凭证外发付费调用
- 默认 provider: providers.length === 0 时同样 fail-closed,避免默认 provider
  rail 全部断开后仍用过期凭证派发

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.com>
Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx Outdated
@Shinku-Chen

Copy link
Copy Markdown
Contributor Author

审查状态更新

MagicLizi 的 CHANGES_REQUESTED 中 唯一的 P1 已在当前 HEAD 修复:

  • P1: dispatchSend 依赖数组缺 slashCommandsReady / mergedCommands → stale closure
    • 修复 commit: 2da7f861bfix(desktop): dispatchSend 依赖数组补齐 slash 命令就绪项
    • slashCommandsReady 在 line 5258,mergedCommands 在 line 5259
    • 回归测试已补:planModeRosterDelay.test.ts

当前状态

  • ✅ 132 条 review thread 全部 resolve
  • ✅ CI 全部通过(DCO, client-ci, pr-design-basis, Greptile)
  • ✅ MERGEABLE,无合并冲突
  • ⚠️ 等待 MagicLizi 重新审查(P1 修复后尚未 re-review)

请 MagicLizi 重新审查此 PR。P1 已修复,所有 review thread 已 resolve。

🤖 Generated with Claude Code

Shinku-Chen and others added 3 commits August 14, 2026 22:15
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.com>
当 remoteHostId 独立解析为 SSH 远程主机而 deviceLinkDeviceId 保持
undefined 时,effect 不会重新执行,导致 pendingHostCapabilityGhostId
残留。在依赖数组中补 remoteHostId,确保 SSH 归属解析后重处理交接。

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.com>
Comment thread apps/desktop/src/renderer/components/new-chat/ChatInput.tsx

@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: 34b4385d03

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-ipc/promptPrediction.ts Outdated
- promptPrediction: 默认 provider 比对使用 nativeDefaultSourceId 而非
  providers[0],匹配 generateTitleViaProviderResult 的解析口径,避免
  Claude Code + Anthropic 优先于 XD 时因 rail 顺序不匹配而静默丢弃推荐
- ChatInput: SSH 会话(remoteHostId 已解析)时即使 dlDeviceId 未解析也
  清除 pendingHostCapabilityGhostId,避免残留芯片在后续依赖变化时延迟
  插入已失效的 Host capability

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Shinku <17696928+Shinku-Chen@users.noreply.github.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: 9fdb0d670b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// 但 connected-provider rail 已不含该 provider,继续派发会用过期凭证
// 外发付费调用。按 fail-closed 中止。
const providers = await listConnectedProvidersForAgent(agentKind);
if (!providers.some((p) => p.id === resolvedProviderId)) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Recheck credential identity before dispatch

Fresh evidence in this revision is that the final hook now verifies only that the same provider id is still connected. If the user logs out and back into the same provider, switches ChatGPT workspace/account, or rotates the XD/Claude credential while the one-shot is between credential read and this hook, the rail still contains resolvedProviderId, so this returns true even though generateTitleViaProviderResult will dispatch with the token/key/account captured before the change. Compare a credential/account fingerprint (for example Codex accountId or a key/OAuth generation) or resolve credentials only after this final eligibility check, otherwise the latest transcript can still be sent to the previous account.

AGENTS.md reference: AGENTS.md:L36-L37

Useful? React with 👍 / 👎.

@Shinku-Chen Shinku-Chen left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

该 P1 已在当前 HEAD (9fdb0d6) 中修复:slashCommandsReadymergedCommands 已加回 dispatchSend 的 useCallback 依赖数组(第 5261-5262 行)。review 提交时基于的中间 commit 已过时,当前代码不存在 stale closure 问题。请重新审查。

Comment on lines +5859 to +5869
pendingTaskWake: isTurnStart ? false :
(isTurnComplete && state.pendingTaskWake && !state.agentStatus.isRunning && !state.pendingTaskWakeDuringTurn) ? false :
state.pendingTaskWake,
// 跨主 turn 标记:主 turn 自己的 Done 越过(标记仍为 true 时到达的首个 Done)后,
// 标记使命已尽、立即退休。否则 wake turn 失败(从未 isRunning:true、无 isTurnStart)
// 时,终态 Done 会因 !pendingTaskWakeDuringTurn 恒为 false 而永远无法清除
// pendingTaskWake,会话永久卡在 running/Stop 态。退休只清标记、不清桥接:
// 桥接(pendingTaskWake)仍存活,直到 wake turn 真正启动或失败。
pendingTaskWakeDuringTurn: isTurnStart ? false :
(isTurnComplete && state.pendingTaskWakeDuringTurn) ? false :
state.pendingTaskWakeDuringTurn,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 多任务 Wake 桥接提前清除

如果两个 wake 型 local_agentlocal_workflow 任务在主轮结束附近先后进入终态,两个任务会共享同一个 pendingTaskWake 布尔标记,而第一个 wake turn 启动时会无条件清除该标记。第一个 wake turn 结束后,第二个任务尚未启动的空窗因此被识别为会话完成,导致 ChatInput 使用不完整上下文发起额外付费预测,并产生 spinner 闪烁。

Context Used: 使用和PR描述相同的语言进行评论 (source)

Knowledge Base Used: Desktop Renderer Chat UI

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/lib/makerChatStore.ts
Line: 5859-5869

Comment:
**多任务 Wake 桥接提前清除**

如果两个 wake 型 `local_agent``local_workflow` 任务在主轮结束附近先后进入终态,两个任务会共享同一个 `pendingTaskWake` 布尔标记,而第一个 wake turn 启动时会无条件清除该标记。第一个 wake turn 结束后,第二个任务尚未启动的空窗因此被识别为会话完成,导致 ChatInput 使用不完整上下文发起额外付费预测,并产生 spinner 闪烁。

**Context Used:** 使用和PR描述相同的语言进行评论 ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

**Knowledge Base Used:** [Desktop Renderer Chat UI](https://app.greptile.com/xindong/-/custom-context/knowledge-base/makecindy/cindy/-/docs/desktop-renderer-chat-ui.md)

---

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

@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: 1ce60278db

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// 断开/登出该显式 provider 时,DB providerId 仍等于 resolvedProviderId,
// 但 connected-provider rail 已不含该 provider,继续派发会用过期凭证
// 外发付费调用。按 fail-closed 中止。
const providers = await listConnectedProvidersForAgent(agentKind);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 将会话资格复核移到最后一个 await 之后

这一版的新证据是完整 DB 复查后仍会在这里(默认 provider 分支同样如此)等待异步的 listConnectedProvidersForAgent();该调用会实时读取凭证连接态并允许副作用,因此等待期间用户仍可能删除会话、切换 agent/provider、修改工作目录或把会话转为远程/review。后续只比较此前缓存的 row,这些变化不会被发现,请求仍会携带旧转写和路径发往已解析的 provider;应先完成 provider rail 读取,再做一次无后续 await 的最终 DB 复核。

AGENTS.md reference: AGENTS.md:L30-L31

Useful? React with 👍 / 👎.

Comment on lines 328 to +330
const body: Record<string, unknown> = {
model: modelId,
instructions: CODEX_TITLE_INSTRUCTIONS,
instructions: effectiveInstructions,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 为 Codex Responses 设置输出 token 上限

当会话使用 OpenAI/Codex provider 时,推荐调用走这个 Responses 请求体,但新增的 OneShotOpts.maxTokens = 96 没有传入 fetchCodexTitle,body 也缺少该协议支持的 max_output_tokens,所以声明的轻量输出上限只对 Anthropic/Gateway 生效。若模型产生 reasoning 或未遵守短输出指令,请求会一直生成到服务端默认上限或 8 秒超时;事后的 140 字截断无法挽回费用和延迟,应把 maxTokens 同样写入 Responses body。

Useful? React with 👍 / 👎.

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

Labels

touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants