Skip to content

feat(resume): reopen Antigravity CLI (agy) conversations per tab - #307

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
clemrdh:feat/agy-resume
Oct 19, 2026
Merged

amirlehmam merged 1 commit into
amirlehmam:masterfrom
clemrdh:feat/agy-resume

Conversation

@clemrdh

@clemrdh clemrdh commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

wmux restores the conversations of Claude (#186), Codex (#261) and OpenCode (#290), each in the tab it was in. Tabs running the Antigravity CLI (agy) came back as bare shells. This adds agy as a fourth provider, behind a new opt-in setting, "Resume Antigravity CLI conversations on restore" (default off). A restored tab types agy --conversation <id>.

Stacked on #306. That PR moves Claude onto the shared provider lookup that this one extends, so its commit appears here until it merges.

Capturing the id

agy has hooks, but it has no --resume-style handshake with wmux. wmux therefore installs a plugin of its own, ~/.gemini/config/plugins/wmux/, made of three files: plugin.json, hooks.json and wmux-agy-hook.cjs.

  • It is a separate directory, so wmux never parses or rewrites the user's own ~/.gemini/config/hooks.json. Removal deletes only files wmux recognises, through the same wmux-plugin-version marker the other plugins carry.
  • It is installed under the Status hooks consent and listed in the consent text. It is only written where ~/.gemini/antigravity-cli exists (wmux modifies global claude settings without permission and/or warning #132).
  • The hook reads conversationId from agy's stdin payload and sends pane.report_agent_session with provider: 'agy', validated as a UUID at the plugin, in main and in the renderer.
  • It runs on two events, because neither alone sees every conversation:
    • SessionStart fires for a new conversation, but not for --conversation <id>;
    • PreInvocation fires before each model call, and only invocationNum 0 is reported. That makes a resumed conversation known at its first message.
  • It always prints {}, since agy requires a JSON object on stdout. It never blocks longer than one bounded pipe round trip.
  • Each command is a bare node wmux-agy-hook.cjs <Event>. agy runs a hook from the folder holding its hooks.json, and on Windows passes a quoted argument to node with the quotes still on. With an absolute path, which has to be quoted as soon as it contains a space, node fails with Cannot find module '<dir>\"C:\...\x.js"'.

Releasing it

agy has no session-end hook, so its exit is taken to be the shell returning to its prompt (report_shell_state). releaseAgyAtPrompt then drops the pane's agy handle. It never touches another provider's session, and it is skipped for an out-of-sequence prompt report: AgentIdentityTracker.clearReported now returns whether it applied. Like every other release, it is refused while wmux quits.

A resumed agy that is quit before its first message never reported. Where the shell reports the command it ran (bash, WSL), the restored id is still dropped. The PowerShell integration reports ssh only, so in pwsh that tab keeps its id and the conversation reopens on the next restore. That is the safe direction to fail in.

agy is also added to AGENT_ALIASES.

Verified live (agy 1.4.1, Windows 11, inside a wmux pane)

  • The plugin is discovered from ~/.gemini/config/plugins/ and loads with no hook errors in agy's log.
  • A new conversation reports at SessionStart and PreInvocation, with the pane's own WMUX_SURFACE_ID and the same id agy prints as conversation_id.
  • agy --conversation <id> reports at PreInvocation, and SessionStart does not fire.
  • The hook environment carries WMUX, WMUX_SURFACE_ID, WMUX_PIPE and WMUX_PIPE_TOKEN.

Tests

  • agy-resume.test.ts:
    • two tabs in one folder round-trip to their own conversations;
    • the id is never stamped as Claude's;
    • hostile ids are refused at the RPC and at restore;
    • the setting is opt-in and the resume happens once;
    • mixed-provider tabs type nothing, and layout presets drop the id;
    • prompt release covers both the record and the never-reported case, never touches another provider, and refuses an out-of-sequence prompt;
    • agy is identified as an agent.
  • agy-context.test.ts:
    • nothing is written without agy, and the plugin is named in the consent text;
    • the install has the expected exact shape;
    • a foreign plugins/wmux is left alone;
    • uninstall removes exactly what was installed;
    • the hook script runs as a real process against a stand-in pipe and sends the expected frame;
    • outside wmux it prints {} and touches no pipe.
  • npm run typecheck and npm run verify:resources pass. ESLint shows no new findings on the changed files; the 3 no-empty errors in useTerminal.ts are already on master.
  • Full suite with --maxWorkers=2: 4,789 passed, 0 failed, 14 skipped.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-19T11:11:04.048565Z 36c149a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 711a22e6c6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/index.ts
// quitting wmux kills the shell rather than returning to it, but keep
// the same refusal every other release has.
if (cleared && !isQuitting) {
releaseAgyAtPrompt(surfaceId as SurfaceId, ran?.source === 'command' && ran.kind === 'agy');

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 Track agy exits in every supported shell

In a Command Prompt pane, src/shell-integration/wmux-cmd-integration.cmd explicitly has no preexec/precmd hook and never emits report_shell_state, so this call is never reached and every reported agy conversation survives a normal return to the cmd prompt. The fallback for a resumed conversation exited before its first model call is also ineffective on Bash/WSL because _wmux_report_command accepts only ssh|ssh.exe, so ran cannot have source === 'command' for agy. A later save therefore retains agySessionId, causing the next restore to relaunch a conversation the user explicitly quit; wire release tracking to signals these shells actually emit or add an agy command report.

Useful? React with 👍 / 👎.

Comment thread src/main/agy-context.ts
Comment on lines +78 to +80
const script = readOrNull(path.join(dir, HOOK_SCRIPT));
if (script !== null) return isWmuxPluginFile(script);
try { return fs.readdirSync(dir).length === 0; } catch { return true; }

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 Recognize partial agy plugin installs

If installation is interrupted or a later synchronous write fails after plugin.json or hooks.json is created but before wmux-agy-hook.cjs, this function sees no script and a nonempty directory and returns false. ensureAgyPlugin then permanently classifies its own partial install as foreign, while removeAgyPlugin also refuses it, potentially leaving agy to invoke a missing hook script on every event. Recognize the exact partial files or use a separate ownership marker so the next launch can complete or clean the install.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@clemrdh

clemrdh commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 2.29.0 (on top of the rebased #306) and adapted to #303. agy is now a ResumableAgent in agent-launcher.ts (/^agy\d*$/, --conversation <id>), and its resume goes through applyResume. A pane whose own startup command is agy … gets the resume merged into that command with its flags kept, and a pane that launches another agent gets nothing. A new test covers both cases. The full-suite result on the rebased branch will follow.

Opt-in "Resume Antigravity CLI conversations on restore", beside Claude
(amirlehmam#186), Codex (amirlehmam#261) and OpenCode (amirlehmam#290): a restored tab types
`agy --conversation <id>`.

The id comes from a plugin of wmux's own, ~/.gemini/config/plugins/wmux/
(plugin.json, hooks.json, wmux-agy-hook.cjs), installed under the Status
hooks consent and only where ~/.gemini/antigravity-cli exists. Its hooks
read `conversationId` from agy's payload and send
`pane.report_agent_session` with `provider: 'agy'`:
- SessionStart for a new conversation;
- PreInvocation (first model call of a turn), because SessionStart does
  not fire for `--conversation` and a resumed conversation's first sign
  of life is its first message.
They always answer `{}`, which agy requires. Commands are a bare
`node wmux-agy-hook.cjs <Event>`: agy runs a hook from its hooks.json
folder, and on Windows hands a quoted argument to node with the quotes
still on.

agy has no session-end hook, so its exit is the shell returning to its
prompt. `releaseAgyAtPrompt` drops an agy handle there, or, when the
command that ended was `agy` but it never reported, the id restored into
the tab. It never touches another provider's session, and is refused for
an out-of-sequence prompt report (AgentIdentityTracker.clearReported now
says whether it applied) and while wmux quits. `agy` is also a known
agent kind now.

Verified live with agy 1.4.1 on Windows: the plugin is discovered from
~/.gemini/config/plugins/, a new conversation reports at SessionStart
and PreInvocation, a `--conversation` resume reports at PreInvocation,
and the payload carries the pane's WMUX_SURFACE_ID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amirlehmam
amirlehmam merged commit aae5e42 into amirlehmam:master Oct 19, 2026
@amirlehmam

Copy link
Copy Markdown
Owner

Merged, thank you. Antigravity is now the fourth resumable agent, opt-in, in 2.30.0. Since #306 was squashed first, I rebased this branch onto master (one commit) before merging.

Two non-blocking follow-ups from the bot review, if you want to pick them up:

  • cmd panes: wmux-cmd-integration.cmd has no precmd seam, so report_shell_state never fires there, and an agy conversation is not released when you exit agy in a cmd pane. It fails in the safe direction (the conversation reopens on restore), but it might be worth noting in the setting's help text.
  • Partial plugin install: if a write fails after plugin.json/hooks.json but before wmux-agy-hook.cjs, isWmuxAgyPlugin treats the directory as foreign, and neither install nor uninstall touches it again. Recognising those exact files (or writing the script first) would fix it.

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.

2 participants