Repository navigation
Let agents hand drafts of copy to the human to edit - #333
Open
frenchie4111 wants to merge 14 commits into
Open
frenchie4111 wants to merge 14 commits into
frenchie4111 wants to merge 14 commits into
Conversation
New ness-control MCP tool `edit_copy`: the agent sends a draft (plus an optional title and context), Ness docks an editor over the bottom of the calling tab, and the call blocks until the human submits or dismisses. The agent gets back the human's final text to use verbatim, or an error on dismissal, plus any note they added. - copyDrafts slice holds pending drafts so every client renders them - CopyDraftBroker parks the control server's HTTP response until answered; a dropped connection (bridge timeout, notifications/cancelled, process exit) withdraws the card - Works in Chat and Terminal tabs; both get a needs-approval dot - The permission bridge always allows edit_copy so Chat tabs don't prompt twice for the same decision Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chat tabs now render the editor under the edit_copy tool call instead of docked over the composer. Terminal tabs keep the docked overlay since an xterm has no transcript to put it in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same gate as send_message: off by default, the bridge hides the tool from tools/list when it's off, and /copy-drafts refuses with a 403 pointing at the setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rafts # Conflicts: # CLAUDE.md # resources/mcp-bridge.js # src/main/build-initial-state.ts # src/main/control-server.test.ts # src/main/control-server.ts # src/main/persistence.ts # src/renderer/build-backend.ts # src/renderer/components/JsonModeChat.tsx # src/renderer/components/Settings.tsx # src/renderer/store.ts # src/renderer/types.ts # src/shared/state/index.ts # src/shared/state/settings.test.ts # src/shared/state/settings.ts
The bridge replies to the cancelled call before the server side sees the socket close, so asserting immediately raced on slower CI runners. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-ups on #333: - Keep in-progress text per draft id outside the editor, so a mobile tab switch or the Chat card moving to its tool call no longer resets it. - A draft the agent stops waiting on moves to copyDrafts.withdrawn instead of vanishing; the card says it wasn't sent and offers Copy text / Close. - Claude Code aborts a silent stdio tool call after 30 min but resets that on progress notifications (hard cap ~27.8 h), so the bridge now sends a progress heartbeat while waiting and allows 24 h itself. - A withdrawn Terminal tab goes to waiting, not processing: Esc in the TUI ends the turn with no later hook event to fix the dot. - Anchor the Chat card only to an edit_copy call that has no result yet. - Don't send a response for a call the client cancelled (per MCP). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A draft withdrawn because its tab closed is dropped on the spot, and the broker clears any withdrawn draft whose tab disappears on a pane change, so they no longer pile up in state and snapshots until restart. - A withdrawn draft with no edits closes itself instead of leaving a "not sent" notice the user has to dismiss. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The renderer used to auto-clear an unedited withdrawn draft, but that decision was per client while the clear was global: a desktop renderer with no local edits would wipe a notice whose text was rewritten on a phone. Clients now report their first edit with copyDrafts:markEdited, and the broker only keeps a withdrawal as a "not sent" notice when some client edited it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rafts # Conflicts: # CLAUDE.md
…rafts # Conflicts: # resources/mcp-bridge.js # src/main/build-initial-state.ts # src/main/control-server.test.ts # src/main/control-server.ts # src/main/persistence.ts # src/renderer/components/JsonModeChat.tsx # src/renderer/components/Settings.tsx # src/renderer/types.ts # src/shared/state/settings.test.ts # src/shared/state/settings.ts
…rafts # Conflicts: # src/main/index.ts
…rafts # Conflicts: # resources/mcp-bridge.test.js # src/main/control-server.ts
Main's #418 added shared/ness-tool-policy.ts as the one place that decides which ness-control tools skip approval. edit_copy now lives in its allow list instead of a special case in ApprovalBridge, which also puts it in Terminal tabs' --allowedTools so they stop prompting for it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rafts # Conflicts: # src/main/build-initial-state.ts
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
edit_copytool to the ness-control MCP server. The agent sends a draft of human-facing copy (UI strings, release notes, a post…) plus an optional title and context. Ness shows it to the user in an editor, and the tool call blocks until they submit or dismiss it. The agent gets back the user's final text with instructions to use it verbatim. A dismissal comes back as an error, so the agent won't ship the draft. Either way it gets any note the user added.send_message. When it's off, the bridge leaves it out oftools/listand/copy-draftsreturns a 403.edit_copytool call, styled like an AskUserQuestion card. The permission bridge always allowsedit_copy, because the editor already is the prompt and approving first would ask twice.notifications/cancelledon interrupt, process exit), the HTTP connection drops and the card is withdrawn.How it's built
copyDraftsslice holds the pending drafts, so every client renders them.CopyDraftBroker(main) holds thePOST /copy-draftscontrol-server response open until the user answers through thecopyDrafts:resolveIPC.resources/mcp-bridge.jsadds the tool with a 30-minute timeout, matching Claude's MCP idle timeout. It also aborts in-flight calls onnotifications/cancelled.JsonClaudeStatusDeriverhandles Chat-tab status. For Terminal tabs the broker sets the status itself, andhooks.tswon't let a late PreToolUse hook reset it to processing.Test plan
npm run typecheck,npx electron-vite buildnpx vitest run: new tests for the slice, broker,/copy-draftsroute, bridge tool (edited / unchanged / dismissed / cancelled), approval-bridge auto-allow and status deriver. In the full run, the unrelatedworktree-watcher.integration.test.tsflaked once; it passes on its own.edit_copyin a Chat tab and in a Terminal tab; edit, submit, dismiss, interrupt mid-wait.🤖 Generated with Claude Code