Skip to content

feat(bot): add desktop discovery controls and quoted feedback - #6730

Open
sunrioa wants to merge 98 commits into
apache:rust-previewfrom
sunrioa:codex/feat-rust-discovery-desktop
Open

sunrioa wants to merge 98 commits into
apache:rust-previewfrom
sunrioa:codex/feat-rust-discovery-desktop

Conversation

@sunrioa

@sunrioa sunrioa commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refs #6716. Depends on #6724 and #6728.

The discovery backend can already run scheduled investigations and retain shared records, but users need a desktop entry point to approve and manage discovery, inspect the original investigation, and reply to a finding with an explicit reference.

This PR connects those capabilities to the Bot desktop interface.

  • Add a proactive-discovery panel for creating and approving plans, editing the investigation direction and interval, pausing/resuming, and checking once. Show the selected workspace and model, execution status, errors, and last/next check times.
  • Preserve existing schedule settings when editing a plan, including cadence, time zone, fire limits, expiry and misfire handling. Approval captures the displayed target and model.
  • Mark discovery publications in Bot Chat and link them to the original worker Session and Turn.
  • Allow users to select text in a Bot reply and quote it in the composer. Preserve the source message and Turn identity through draft persistence, sending, retry and restart.
  • Render quoted excerpts in sent messages and pending/retried sends. History pages return bounded previews; original text and provenance remain unchanged.
  • Resolve discovery feedback from its quoted publication. Reject a supplied discovery record that conflicts with the quoted source.
  • Update the client journal, generated SDK contracts and composer consumers. Existing journals and frozen sends without quote data remain readable.

This is the desktop-control and quoted-feedback slice of #6716, built on the scheduling and shared-record work in the preceding PRs.

Proactive discovery flow

flowchart TD
    plan["Approved discovery plan"]
    scheduler["Host Scheduler<br/>One active investigation"]
    worker["Fresh worker Session<br/>Approved Session tools"]
    complete{"DiscoveryComplete"}
    settled["Settle quietly"]
    bot["Existing Bot Session<br/>Review queued report"]
    outbox["Bot outbox<br/>User sees the finding"]
    asleep["End Bot turn quietly"]
    memory[("DiscoveryMemory<br/>Results, notes, decisions and feedback")]

    plan -->|"Timer or Check now"| scheduler
    scheduler --> worker
    worker --> complete
    complete -->|no_report| settled
    complete -->|"report via Session queue"| bot
    bot -->|SendUser| outbox
    bot -->|sleep| asleep
    complete -. "Persist on settlement" .-> memory
    memory -. "Read records on demand" .-> worker
    bot -. "Record notification decision" .-> memory
    outbox -. "User quotes finding, Bot records feedback" .-> memory
Loading

Verification

The branch has been synchronized with #6728 and rust-preview through e8bc5aa2f. Local checks below apply to that updated implementation on macOS.

Check Result
Native Agent and client regression 50 passed, 0 failed
Workbench unit and component tests 25 passed, 0 failed
JavaScript/tooling tests 196 passed, 0 failed
Generated schemas, SDK/product and desktop TypeScript checks Passed
Formatting, ASF headers, dependency-license and whitespace checks Passed

Coverage includes discovery status and original-worker links, durable notification receipts, quote-linked feedback after restart, rejecting mismatched discovery records, quoted drafts and frozen-send upgrades, and bounded quote previews. Existing tests were adapted to the durable Agent interfaces without restoring the removed legacy harnesses.

The remaining sent-message quote preview has been implemented. This update does not change retry policy or investigation permissions.

The release packaging and real-provider checks below were completed before this upstream synchronization, on the earlier implementation. They have not been repeated on the updated head.

Live-provider checks used Command Code → DeepSeek V4.1 Flash with isolated synthetic data:

Scenario Observed result
Scheduled investigation with a new actionable finding One linked notification
Recheck without new information No repeated notification
Quote a finding and report it resolved Feedback linked to the original discovery
Investigate again in a fresh Session Feedback retrieved; no repeated notification
Introduce an independent finding New notification delivered
Read actual sample files, then correct their contents Files reread; corrected findings not repeated
Terminate the Host during a real model request Original investigation settled as failed without replay; the next investigation completed normally

All investigating workers used read-only permissions. Test plans were paused after verification.

The live checks also exposed model-quality limitations: one investigation incorrectly treated an additional, permitted language file as a mismatch, and the Bot initially described background file access inaccurately. Corrective feedback was retained and respected in subsequent investigations. These checks validate the integration, not general discovery accuracy.

Windows/Linux desktop validation and full repository CI were not run locally. The macOS package was a local smoke-test artifact, not a signed or source-bound publication candidate.

Live use in an approved workspace

This snapshot comes from macOS runtime records for an existing approved workspace. Both builds used Command Code / DeepSeek V4.1 Flash. The post-sync local build was based on this PR with #6874, #6907 and a local adapter for the existing schedule.

Observation window (UTC+8) Investigations Bot notifications with an original Session link Worker model attempts with token counts / total Input tokens Output tokens Share of input read from cache
Earlier local build, 2026-11-14 20:13 to 23:29 4 completed with reports, 2 failed 4 216 / 220 19,044,923 113,708 92.0%
Post-sync local build, 2026-11-14 23:29 to 2026-11-15 01:35 1 completed with a report in 2h 5m 14s 1 171 / 173 16,440,532 72,285 97.2%
  • The four completed reports took 17m 58s to 27m 02s. Their linked notifications reached the Bot outbox 22 to 82 seconds after the investigations settled. One failure followed a model-step error and the other settled during restart recovery.
  • The post-sync investigation settled at 01:35:12, and the Bot published one notification with a link to the original investigation Session at 01:35:30 (about 18 seconds later, UTC+8).
  • The post-sync worker recorded 110 Shell calls returning without a tool-level error, including four issued in a later model step than the one that started the code cell. The runtime recorded zero agent_cell_origin_mismatch errors in that round.
  • Three non-overlapping searches (recent media files, a broad local scan, and a quota ledger lookup) took 43m 14s in total from call to return. The worker called wait 32 times and made 10 separate checks of the same repository fix across commits, branches, and worktrees. This run had no execution deadline.
  • Input includes cached tokens. Token totals cover attempts with provider-reported usage. The four linked Bot runs on the earlier build separately recorded 891,165 input and 4,413 output tokens across eight model attempts. The Bot run that published the post-sync notification separately recorded 224,778 input and 1,202 output tokens across two model attempts.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex assisted with implementation, regression tests, local verification and drafting this description.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
简体中文

概述

关联 #6716,依赖 #6724 和 #6728。

主动发现后端已经能够执行定时调查并保留共享记录,但用户还需要桌面入口来批准和管理发现计划、查看原始调查,以及明确引用某条发现进行反馈。

本 PR 将这些能力接入 Bot 桌面界面。

  • 增加主动发现面板,支持创建和批准计划、编辑调查方向与间隔、暂停/恢复,以及检查一次。显示所选工作区和模型、执行状态、错误及上次/下次检查时间。
  • 编辑计划时保留原有调度设置,包括执行节奏、时区、触发次数限制、到期时间和错过执行时的处理方式。批准操作固定界面展示的目标与模型。
  • 在 Bot 对话中标记主动发现消息,并关联原始 worker Session 和 Turn。
  • 支持选中 Bot 回复中的文字并引用到输入框。在草稿保存、发送、重试和重启过程中保留来源消息及 Turn 身份。
  • 在已发送消息和待发送/重试消息中展示引用。历史分页返回有长度限制的预览,原始正文与来源保持不变。
  • 根据被引用的通知定位原始发现;显式指定的发现记录与引用来源冲突时拒绝关联。
  • 更新客户端日志、生成的 SDK 契约及输入框调用方。旧版数据库和不包含引用字段的已冻结发送内容仍可读取。

这是 #6716 中桌面控制与引用反馈部分的实现,建立在前两个 PR 的调度和共享记录能力之上。

主动发现流程

flowchart TD
    plan["已批准的主动发现计划"]
    scheduler["Host 调度器<br/>同时只运行一轮调查"]
    worker["每轮新建调查会话<br/>使用获准的会话工具"]
    complete{"DiscoveryComplete<br/>提交调查结果"}
    settled["静默结算"]
    bot["原有 Bot 会话<br/>判断是否通知用户"]
    outbox["Bot 发件箱<br/>用户收到发现"]
    asleep["静默结束 Bot 本轮"]
    memory[("DiscoveryMemory<br/>调查结果、笔记、通知决定和反馈")]

    plan -->|"定时到点或点击立即检查"| scheduler
    scheduler --> worker
    worker --> complete
    complete -->|"no_report 无需汇报"| settled
    complete -->|"report 报告进入会话队列"| bot
    bot -->|SendUser| outbox
    bot -->|sleep| asleep
    complete -. "结算时写入" .-> memory
    memory -. "按需读取历史调查记录" .-> worker
    bot -. "记录通知决定" .-> memory
    outbox -. "用户引用通知,Bot 记录反馈" .-> memory
Loading

验证

分支已同步 #6728,并纳入截至 e8bc5aa2f 的 rust-preview。以下本地检查对应同步后的 macOS 实现。

检查 结果
原生 Agent 与客户端回归 50 项通过,0 项失败
Workbench 单元与组件测试 25 项通过,0 项失败
JavaScript/工具链测试 196 项通过,0 项失败
生成的 Schema、SDK/产品及桌面 TypeScript 检查 通过
格式、ASF 文件头、依赖许可证及空白检查 通过

覆盖调查状态与原 worker 链接、通知回执持久化、重启后的引用反馈关联、错误记录关联拒绝、引用草稿与旧冻结发送内容的升级,以及引用预览的长度边界。原有有效测试已适配新的持久化 Agent 接口,没有恢复上游删除的旧测试框架。

此前剩余的已发送消息引用预览已实现。本次不改变重试策略或调查权限。

下述 release 打包和真实模型联调在本次同步上游之前的实现上完成,尚未在更新后的提交上重复执行。

真实模型联调使用 Command Code → DeepSeek V4.1 Flash,材料均为隔离的合成数据:

场景 实际结果
定时调查发现新的可行动问题 发出一条关联原调查的通知
没有新信息时再次检查 未重复通知
引用发现并反馈已经解决 反馈关联到原始发现
使用新的 Session 再次调查 读取反馈,未重复通知
加入独立的新问题 正常发送新通知
读取实际样例文件,再修改文件内容 重新读取文件,未重复报告已修正的问题
真实模型请求期间终止 Host 原调查明确结算为失败,没有重复执行;下一轮正常完成

调查 worker 均使用只读权限,测试结束后已暂停计划。

真实联调也暴露出模型判断的局限:一次调查把允许存在的额外语言文件误判为差异,Bot 最初也未准确说明后台调查的文件读取能力。纠正反馈得到保存,并在后续调查中生效。这些检查验证的是集成链路,不能作为普遍发现准确率的证明。

本地未执行 Windows/Linux 桌面验证或完整仓库 CI。macOS 包仅用于本地安装冒烟,不是已签名或绑定源码归档的正式发布候选产物。

已授权工作区的真实运行数据

以下数据来自现有已授权工作区的 macOS 运行记录。两个构建均使用 Command Code / DeepSeek V4.1 Flash。同步后的本地构建以本 PR 为基础,包含 #6874、#6907 和用于读取原有计划的本地适配。

观察窗口(UTC+8) 调查结果 带原 Session 链接的 Bot 通知 Worker 模型尝试(有 token 记录/总数) 输入 token 输出 token 输入缓存读取占比
较早的本地构建,2026-11-14 20:13 至 23:29 4 轮完成并提交报告,2 轮失败 4 216 / 220 19,044,923 113,708 92.0%
同步后的本地构建,2026-11-14 23:29 至 2026-11-15 01:35 1 轮完成并提交报告,耗时 2 小时 5 分 14 秒 1 171 / 173 16,440,532 72,285 97.2%
  • 四轮产出报告的调查耗时 17 分 58 秒至 27 分 2 秒。带原调查链接的通知在结算后 22 至 82 秒写入 Bot 发件箱。一轮在模型步骤报错后失败,另一轮在重启恢复时结算为失败。
  • 同步后的调查于 01:35:12 结算。Bot 于 01:35:30 发出 1 条带原调查 Session 链接的通知,相隔约 18 秒,均为北京时间。
  • 同步后的 Worker 有 110 次 Shell 调用返回且没有工具级错误,其中 4 次由此前模型步骤启动的代码单元在后续步骤发起。这轮没有记录 agent_cell_origin_mismatch。
  • 三条慢查询分别检索近期媒体文件、广泛扫描本地文件和查找额度台账,从发起到返回合计 43 分 14 秒,时间互不重叠。Worker 调用了 32 次 wait,另有 10 次围绕同一个仓库修复核对提交、分支和工作树。本轮没有执行截止时间。
  • 输入包含缓存 token,表内用量按供应商实际返回的计数求和。较早构建的四个关联 Bot 执行另有 8 次模型尝试,记录到 891,165 输入和 4,413 输出 token。同步后发送通知的 Bot 执行另有 2 次模型尝试,记录到 224,778 输入和 1,202 输出 token。

AI 使用说明

OpenAI Codex 协助完成实现、回归测试、本地验证及本说明起草。

检查清单

  • 测试覆盖本次改动,缺少相应实现时无法通过
  • 格式、类型检查和受影响套件在本地通过

本 PR 存在行为变化,已在概述中说明。

Add opt-in discovery schedules using fresh read-only worker Sessions and
explicit report or no_report settlement through the existing Bot path.
Preserve original execution identities across restart and Host handoff.

Refs: apache#6716
Generated-by: OpenAI Codex
Keep cancellation durable across resume and service disablement, and
settle only the original investigation Turn. Recheck report authority
at admission and restrict Recall to the enabled built-in implementation.
Preserve uncertain result writes and allow approved inactive plans to resume.

Generated-by: OpenAI Codex
Share scoped investigation outcomes and checkpoints across fresh workers using
the existing scheduler store. Keep complete reasons and source references
available through bounded queries and explicit continuation.

Link corrections and feedback to the original investigation and immutable
user input, including quoted and steered messages. Record notification
decisions in SendUser or sleep without an extra model step, retaining outbox
identity and uncertain-write semantics.

Generated-by: OpenAI Codex
@github-actions github-actions Bot added the effort/XXL Over 2500 readable lines label Nov 10, 2026
Exercise committed but unacknowledged settlement, uncertain notification receipts, concurrent memory writes, and project relocation with real storage and a test-only fault seam.

Generated-by: OpenAI Codex
Reconcile discovery jobs, feedback and bounded records with the durable Run and queue contracts introduced by apache#6713. Port the Host regressions to the current fixture and preserve unknown-effect cleanup semantics.

Generated-by: OpenAI Codex
Sync rust-preview through apache#6740, retaining its archive and WebSocket recovery fixes. Handle scheduler revision conflicts and wait for original Run cleanup in the discovery fixtures.

Generated-by: OpenAI Codex
Retain always-visible controls when rebuilding the authorized Run catalog, and calculate continuation replay evidence from the discovered tool subset. Keep replay signature validation and current tool authorization unchanged.

Exercise Bot controls with tool discovery enabled; the existing desktop continuation regression covers failed-Run continuation without duplicate input.

Generated-by: OpenAI Codex
Integrate apache#6728 and keep desktop discovery status, publication provenance and quoted feedback on the current Agent execution and queue contracts. Obsolete fixture coverage will be carried by the current Host and journal tests.

Generated-by: OpenAI Codex
Persist admitted discovery identity for desktop status, retain quoted previews through send and history, and migrate restart and UI coverage to the current interfaces.

Generated-by: OpenAI Codex

@liugddx liugddx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated code review by Codex. I found two correctness issues and called them out inline. The focused workbench checks could not run because this environment is missing /opt/homebrew/opt/simdjson/lib/libsimdjson.33.dylib; Rust checks were unavailable because cargo is not installed.

Keep existing second-based schedules intact during instruction edits. Hide continuation for quoted drafts and recheck quotes around asynchronous continuation admission. Extend existing regression coverage for both review findings.

Generated-by: OpenAI Codex
Preserve discovery tool restrictions and quoted draft actions while adopting upstream model stack and native residency updates.

Generated-by: OpenAI Codex
Check the original approval and pending fire before starting queue consumers. Retract revoked pending reports across both delivery crash windows, and preserve original notification identity when authorization remains valid.

Generated-by: OpenAI Codex
Integrate the durable Agent execution API, retain the A1 read-only investigation scope, and retract revoked pending reports before recovery consumers start. Port behavior coverage to the current real Host harness.

Generated-by: OpenAI Codex
Preserve shared discovery records and feedback while synchronizing the current durable Agent runtime. Carry the recovered-report authorization checks and their real Host regressions into A2.

Generated-by: OpenAI Codex
Include the latest upstream UI changes and regenerate the dependency inventory after the upstream native graph changes.

Generated-by: OpenAI Codex
Carry the current rust-preview synchronization while retaining the recovered-report authority checks and shared-memory regression coverage.

Generated-by: OpenAI Codex
Integrate the current rust-preview dependency stack and preserve desktop discovery, quoted drafts, publication identity, and recovery authorization coverage.

Generated-by: OpenAI Codex
Finish each simulated model step before awaiting steering. Verify that Stop targets the current Run while an accepted followup executes once and the next draft stays intact. Keep the existing input, queue, and timeout checks.

Generated-by: OpenAI Codex
Finish each simulated model step before awaiting steering. Verify that Stop targets the current Run while an accepted followup executes once and the next draft stays intact. Keep the existing input, queue, and timeout checks.

Generated-by: OpenAI Codex
Sync current rust-preview while retaining the recovered-report authorization boundary. Box the new legacy-compaction projection at its entrypoint to bound the debug poll stack, and keep the notification recovery fixture pinned to its original busy Run.

Generated-by: OpenAI Codex
Carry the verified A1 recovery boundary, bounded projection stack, and existing desktop steering fixture correction into the shared-memory layer.

Generated-by: OpenAI Codex
Preserve discovery and quoted drafts while integrating the removal of manual risk UI and history prefetch. Carry the verified recovery authorization and original-Run fixture fixes from A1/A2.

Generated-by: OpenAI Codex
Acquire the existing child handle before the five-second pipe-drain wait. This separates PowerShell fixture startup from drain timing and preserves cleanup when the wait fails; production process behavior and the drain bound are unchanged.

Generated-by: OpenAI Codex
The queue consumer uses try_lock for Goal admission, so an enqueue wake can be consumed while the producer still owns the gate. Notify after releasing it when the persisted schedule still has ready work; keep the existing authorization and ordering checks.

Generated-by: OpenAI Codex

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

Labels

effort/XXL Over 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants