Skip to content

feat(desktop): edit and resend user messages - #1287

Merged
likun666661 merged 6 commits into
apache:mainfrom
Hxnxe:feat/desktop-edit-resend-user-messages
Jul 22, 2026
Merged

likun666661 merged 6 commits into
apache:mainfrom
Hxnxe:feat/desktop-edit-resend-user-messages

Conversation

@Hxnxe

@Hxnxe Hxnxe commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refs #700.

Implement Desktop Edit & resend as a durable, non-destructive version of the same conversation — not as an ordinary derived/sidebar conversation.

  • edit starts as a local composer draft; no durable version is created until Send
  • Send uses the dedicated reviseBeforeTurn(ReviseBeforeTurnInput) runtime/IPC path; Desktop no longer exposes or calls branchBeforeTurn
  • revision lineage is separate from ordinary branch lineage (revisionRootSessionId, parent, turn, immutable index, preparing/committed state)
  • the sidebar, search, Daily Review, onboarding state, and Open Gateway share one logical-conversation projection
  • committed versions stay in one sidebar row and have previous/next version navigation in the chat surface
  • normal “Branch from here” sessions remain independent conversations and retain the branch banner
  • preparing versions are hidden after restart; startup recovery removes empty preparations or self-heals an admitted user edit to committed
  • cancel/navigation/load failures roll back the prepared version and preserve the edited composer text
  • rename, pin, archive, unarchive, and delete operate on the revision family through one main-process boundary; ordinary branches are not included
  • inherited ShellRun ownership follows revision lineage, and session inspect exposes revision metadata
  • source/retained attachments, transformed skill prompts, pending attachments, live turns, automation turns, and incompatible slash commands remain fail-closed

Persisted history is never rewritten. Old versions stay available through the in-conversation version navigator.

Verification

Current commit d6122e36 (rebased onto 1ca46327):

  • npm run build:test — passed across Core, Storage, MCP, Runtime, Runtime Host, Computer Use, Headless, CLI, UI, and Desktop
  • npm --workspace @maka/desktop test (clean dist) — 2782 passed, 0 failed
  • complete Runtime suite, serialized to avoid process/PTY timing contention — 2329 passed, 0 failed, 7 skipped
  • complete Storage suite, serialized to avoid FIFO timing contention — 411 passed, 0 failed, 1 skipped
  • complete Core suite — 1140 passed, 0 failed
  • complete UI suite — 206 passed, 0 failed
  • npm --workspace @maka/desktop run typecheck — passed
  • npm --workspace @maka/desktop run test:checks — console, accessibility, and copy checks passed
  • npx biome lint <changed files> and git diff --check — passed

Review focus

  • revisions and ordinary branches use distinct persistent lineage and distinct Desktop entry points
  • preparing → committed happens only after AgentRun.begin() durably appends the edited user turn
  • restart recovery cannot surface an empty revision as a second conversation
  • continuing an older version changes the logical sidebar head without renumbering or hiding other committed versions
  • logical projections still preserve the raw revision summaries needed for version navigation

@Hxnxe
Hxnxe force-pushed the feat/desktop-edit-resend-user-messages branch from 9a2bdff to 2442af7 Compare July 20, 2026 23:35

@Astro-Han Astro-Han 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.

Approving edit-and-resend. Two things:

  • The MAKA_RUNTIME_SAFE_BOUNDARY_RESUME flip in app-lifecycle.ts / main.ts (opt-in to opt-out) changes startup behavior for every desktop session and isn't mentioned in the PR body. Either split it into its own PR or add a line to the body so it's visible to reviewers.
  • prepareRevisionSend relies on nextAnimationFrame() to wait for the composer's draftKey swap before setText, with the safety margin coming from the refreshMessages IPC round-trip. A deterministic setDraft(key, text) primitive would remove that timing coupling later.

@likun666661 likun666661 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.

审计结论

1. 解决了什么问题

把 runtime 的 branchBeforeTurn 接到 Desktop,形成非破坏性的“编辑并重发”:点击时只改本地草稿,发送时才创建分支;原会话不改写,并对运行中/自动化回合、附件历史、显式技能变换文本和 /compact fail-closed。

2. 模块图

flowchart LR
  Turn["ChatTurn 编辑入口"] --> Shell["AppShell revision actions"]
  Shell --> Composer["Composer 草稿隔离"]
  Shell --> Preload["Preload bridge"] --> IPC["branchBeforeTurn IPC"]
  IPC --> Runtime["SessionManager.branchBeforeTurn"] --> Child["子会话"] --> Send["普通 sessions.send"]
Loading

3. 时序图

sequenceDiagram
  actor U as 用户
  participant UI as Desktop UI
  participant IPC as IPC/Main
  participant RT as Runtime
  U->>UI: 点击编辑并修改草稿
  Note over UI,RT: 点击阶段不创建分支
  U->>UI: 发送
  UI->>IPC: branchBeforeTurn(source, turnId)
  IPC->>RT: 校验后创建子会话
  RT-->>UI: child session
  UI->>UI: 切换子会话并迁移文本
  UI->>RT: 正常发送 edited prompt
Loading

4. 有无明显 blocker

有。 PR 同时把 MAKA_RUNTIME_SAFE_BOUNDARY_RESUME 从 opt-in 改成默认开启;这是影响所有 Desktop 启动恢复的全局行为,与 edit-and-resend 边界无关且未写入 Summary。建议拆 PR,或单独说明并取得明确 sign-off。

非阻塞项:prepareRevisionSend 依赖 refreshMessages + requestAnimationFrame 等待 draft key;后续宜改为确定性的 setDraft(key, text)。

验证:本地全依赖构建及 7 个相关 Desktop 定向测试文件通过;GitHub Actions 为 action_required,尚未启动 job。

@Hxnxe
Hxnxe force-pushed the feat/desktop-edit-resend-user-messages branch from be30cd7 to 5e283bb Compare July 21, 2026 17:53
@Hxnxe

Hxnxe commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback and rebased this branch onto current main (2971a385).

  • Removed the unrelated MAKA_RUNTIME_SAFE_BOUNDARY_RESUME opt-in → opt-out change entirely. main.ts, app-lifecycle.ts, and the resume-routing contract now have no diff in this PR; safe-boundary default behavior can be considered separately.
  • Kept the edit-and-resend flow plus the compact revision notice/UI consistency fixes.
  • Resolved the ChatView rebase conflict by preserving current-main conversation-item/Deep Research rendering and adding the revision props on top.
  • Kept the nextAnimationFrame() draft-key handoff unchanged for this PR; I agree a keyed setDraft(key, text) primitive would be a worthwhile follow-up to remove the timing dependency.

Validation on the rebased head 5e283bb0:

  • npm run build:test
  • npm --workspace @maka/desktop run typecheck
  • 6 focused Desktop revision/attachment/IPC test files: 50 passed
  • UI conversation-copy tests: 3 passed
  • npm --workspace @maka/desktop run test:checks
  • Biome on all changed files and git diff --check

陈翼然 and others added 4 commits July 22, 2026 08:13
Keep the edit-and-resend notice compact and aligned with the existing composer UI, split the banner copy for clearer styling, and add the missing focus/cursor affordances.
@Hxnxe
Hxnxe force-pushed the feat/desktop-edit-resend-user-messages branch from 352395f to d6122e3 Compare July 22, 2026 00:15
@likun666661
likun666661 merged commit 397d62a into apache:main Jul 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants