feat(desktop): 输入框推荐提示词,回复结束后预测下一句并支持 Tab 填入 - #1965
Conversation
|
| 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
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
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
Pull request overview
本 PR 为 Desktop 新增“输入框推荐提示词”能力:在一轮 AI 回复结束且输入框为空时,主进程通过复用既有 title one-shot provider 通路做一次轻量预测,将预测的下一句以输入框 overlay/placeholder 形式展示,并支持按 Tab 一键填入;同时在设置「小技巧」中提供开关(默认开启)。
Changes:
- 新增
maker:predict-promptIPC 与主进程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.
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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:587runProviderOneShot已被 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:17useState在该组件中未使用,建议移除以避免无意义的依赖与潜在的 noUnusedLocals/noUnusedParameters 报错。
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
3dc2ccc to
9629401
Compare
There was a problem hiding this comment.
💡 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".
|
本 PR 触发了维护者确认门(product: 新功能 feat + 命中 UI 路径)。 新增输入框推荐提示词与 Tab 填入能力,属于新产品交互功能。已开启讨论 issue 待维护者确认。 维护者在 PR 上 Approve 即放行;需要修改请 Request Changes。 讨论 issue:#1974 |
There was a problem hiding this comment.
💡 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".
- 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>
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
💡 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".
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>
There was a problem hiding this comment.
💡 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".
- 保留 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>
There was a problem hiding this comment.
💡 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".
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>
最新 commit (e5124b241) 修复了 4 个 P1 TOCTOU 竞态问题
所有 4 个 thread 已回复并 resolve。 |
There was a problem hiding this comment.
💡 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".
|
MagicLizi 的 P1 反馈(dispatchSend 依赖数组缺 slashCommandsReady / mergedCommands 导致 stale closure)已在最新 commit 中修复: |
|
@MagicLizi 已修复:最新 commit ce49212 已将 |
- 显式 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>
审查状态更新MagicLizi 的 CHANGES_REQUESTED 中 唯一的 P1 已在当前 HEAD 修复:
当前状态:
请 MagicLizi 重新审查此 PR。P1 已修复,所有 review thread 已 resolve。 🤖 Generated with Claude Code |
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>
There was a problem hiding this comment.
💡 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".
- 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>
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
该 P1 已在当前 HEAD (9fdb0d6) 中修复:slashCommandsReady 和 mergedCommands 已加回 dispatchSend 的 useCallback 依赖数组(第 5261-5262 行)。review 提交时基于的中间 commit 已过时,当前代码不存在 stale closure 问题。请重新审查。
| 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, |
There was a problem hiding this comment.
如果两个 wake 型 local_agent 或 local_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.There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
这一版的新证据是完整 DB 复查后仍会在这里(默认 provider 分支同样如此)等待异步的 listConnectedProvidersForAgent();该调用会实时读取凭证连接态并允许副作用,因此等待期间用户仍可能删除会话、切换 agent/provider、修改工作目录或把会话转为远程/review。后续只比较此前缓存的 row,这些变化不会被发现,请求仍会携带旧转写和路径发往已解析的 provider;应先完成 provider rail 读取,再做一次无后续 await 的最终 DB 复核。
AGENTS.md reference: AGENTS.md:L30-L31
Useful? React with 👍 / 👎.
| const body: Record<string, unknown> = { | ||
| model: modelId, | ||
| instructions: CODEX_TITLE_INSTRUCTIONS, | ||
| instructions: effectiveInstructions, |
There was a problem hiding this comment.
为 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 👍 / 👎.
这次改了什么
摘要
一轮回复结束、输入框为空时,向 provider 发一次轻量 one-shot 预测用户下一句想输入什么,以 placeholder 形态展示;按 Tab 一键填入。设置 →「小技巧」里可关闭(默认开启)。
不新造模型调用通路:复用会话标题 one-shot 那套 provider / 凭证 / model routing(同一个最经济模型),所以不额外配 endpoint、不引入新的外发面。
变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
maker:predict-promptIPC +maker-ipc/promptPrediction.ts(取最近 3 轮 user/assistant 作素材,截断后走 one-shot)title-one-shot.ts命名与TitleOneShotResult结构化返回,并重新加回可选OneShotOptsusePromptRecommendationPreferencehook(模块级内存 SoT + listeners + storage 跨窗口同步)makerChatStore:pendingTaskWake加入SessionChatLightState,纳入isAgentBusy计算UI 变化
改动两处:输入框 placeholder 位置的推荐词,设置里新增一行开关 cell。
怎么验证的
自动验证
手工验证
在 dev 模式下反复走通了主流程:发消息 → 等回复结束 → placeholder 变推荐词 → Tab 填入 → 发送。
未执行的验证
pnpm test:unit未完整跑绿。desktop 和 cindy-tools 的 TEST_COLLECT_FAILED 为基线问题,与本次改动无关。风险
风险分类
影响与回滚
makerChatStoreLightState。git revert,无 migration、无持久化状态、无协议变更。提交前检查
Review 反馈处理(第五十六轮)
workingDir: sessions.workingDir,预测时用latestSessionRow.workingDir。Commit: 2ad1f14provider_id为 NULL)预测被beforeDispatch静默跳过row.providerId != null &&时才拦截,DB 无显式 provider 不存在 TOCTOU 风险。Commit: 2bda7f2updateAll对象内重复 key 导致静默值覆盖remoteHostId,SSH 归属解析后 effect 重跑并清理交接状态。Commit: 34b4385基线同步
upstream/main(211 commits),解决 auto-merge 冲突。Typecheck 与 related unit tests 通过(2 个基线失败与 PR 无关:ghostInstallReceipt 2 个,在 upstream/main 亦复现)。新增:修复 greptile P1(SSH 归属 handoff 依赖数组缺 remoteHostId,Commit: 34b4385)。Review 反馈处理(第五十七轮)
🤖 Generated with Claude Code