feat: add Antigravity session restore support - #1839
Conversation
📝 WalkthroughWalkthroughAdds AGY session resume support by registering ChangesAGY Resume Support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Terminal
participant capture_tab
participant infer_agy_session_id
participant Snapshot
Terminal->>capture_tab: launch argv and agent state
capture_tab->>infer_agy_session_id: infer AGY session ID
infer_agy_session_id-->>capture_tab: session ID
capture_tab->>Snapshot: create herdr:agy/agy ID snapshot
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
7f941f2 to
b85481c
Compare
Greptile SummaryAdds Antigravity session restoration support.
Confidence Score: 5/5The PR appears safe to merge. The previously reported compilation failure is fixed, and no remaining blocking failure eligible for this follow-up review was identified.
|
| Filename | Overview |
|---|---|
| src/agent_resume.rs | Registers Antigravity session handling, adds resume planning and session-ID inference, and correctly resolves the previously reported match-brace compilation issue. |
| src/persist/snapshot.rs | Captures inferred Antigravity conversation IDs in pane session snapshots when no authoritative or persisted session is already available. |
Reviews (4): Last reviewed commit: "feat(persist): add automatic session ID ..." | Re-trigger Greptile
|
Thanks for the contribution. I moved this PR back to draft because the current change only adds the final resume-command mapping. Herdr recognizes and screen-detects AGY today, but it does not have an AGY integration that captures and reports the conversation ID, so the new planner has no production input. Please implement the AGY integration end to end. AGY supports plugins and command hooks, and hook payloads expose Please also validate this against the real AGY CLI rather than only the planner unit test: install the integration, start an AGY conversation, confirm Herdr persists its session reference, restart/restore Herdr, and verify that |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/agent_resume.rs`:
- Around line 231-255: The global newest-session fallback in the AGY resume
discovery flow must not identify a pane-specific conversation; remove or
redesign the fallback in src/agent_resume.rs lines 231-255 so the session
remains unknown without a pane-associated conversationId. In
src/persist/snapshot.rs lines 360-370, only synthesize an AGY snapshot when the
ID comes from the pane-correlated AGY hook/report path; otherwise leave the
snapshot unsynthesized.
- Around line 218-226: Update infer_agy_session_id to tokenize command-line
arguments and recognize only the exact --conversation <id> and
--conversation=<id> forms, preserving the existing filtering of empty values and
--continue. Ensure --conversation-id and similar flags are ignored, and add a
regression case covering --conversation-id so it cannot be restored as a session
ID.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: dcadec2c-468b-45df-bffd-01c31244c403
📒 Files selected for processing (2)
src/agent_resume.rssrc/persist/snapshot.rs
| pub fn infer_agy_session_id(cmdline: Option<&str>) -> Option<String> { | ||
| if let Some(cmd) = cmdline { | ||
| if let Some(idx) = cmd.find("--conversation") { | ||
| let rest = cmd[idx + "--conversation".len()..].trim_start(); | ||
| let rest = rest.strip_prefix('=').unwrap_or(rest).trim_start(); | ||
| let token = rest.split_whitespace().next().unwrap_or(""); | ||
| let token = token.trim_matches('\'').trim_matches('"'); | ||
| if !token.is_empty() && token != "--continue" { | ||
| return Some(token.to_string()); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Parse --conversation as an exact argument.
Line 220 also matches flags such as --conversation-id; it then captures -id as a session ID and restores the wrong conversation. Tokenize arguments and accept only --conversation <id> or --conversation=<id>. Add a regression case for --conversation-id.
Also applies to: 482-491
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/agent_resume.rs` around lines 218 - 226, Update infer_agy_session_id to
tokenize command-line arguments and recognize only the exact --conversation <id>
and --conversation=<id> forms, preserving the existing filtering of empty values
and --continue. Ensure --conversation-id and similar flags are ignored, and add
a regression case covering --conversation-id so it cannot be restored as a
session ID.
| let home = std::env::var("HOME").ok()?; | ||
| let brain_dir = std::path::PathBuf::from(home).join(".gemini/antigravity-cli/brain"); | ||
| let entries = std::fs::read_dir(brain_dir).ok()?; | ||
|
|
||
| let mut newest: Option<(std::time::SystemTime, String)> = None; | ||
| for entry in entries.flatten() { | ||
| let path = entry.path(); | ||
| if path.is_dir() { | ||
| if let Ok(meta) = entry.metadata() { | ||
| if let Ok(mtime) = meta.modified() { | ||
| let name = path.file_name()?.to_string_lossy().to_string(); | ||
| match &newest { | ||
| Some((best_time, _)) if mtime > *best_time => { | ||
| newest = Some((mtime, name)); | ||
| } | ||
| None => { | ||
| newest = Some((mtime, name)); | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| newest.map(|(_, name)| name) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Do not use a global “newest” session as a per-pane identity.
With multiple AGY panes lacking an explicit conversation argument, every pane can snapshot the same newest brain directory and later resume the wrong conversation. Require a pane-associated conversationId from the AGY hook/report path; otherwise leave the session unknown.
src/agent_resume.rs#L231-L255: remove or redesign the global fallback so it cannot claim a specific pane’s session.src/persist/snapshot.rs#L360-L370: only synthesize an AGY snapshot from a pane-correlated ID.
📍 Affects 2 files
src/agent_resume.rs#L231-L255(this comment)src/persist/snapshot.rs#L360-L370
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/agent_resume.rs` around lines 231 - 255, The global newest-session
fallback in the AGY resume discovery flow must not identify a pane-specific
conversation; remove or redesign the fallback in src/agent_resume.rs lines
231-255 so the session remains unknown without a pane-associated conversationId.
In src/persist/snapshot.rs lines 360-370, only synthesize an AGY snapshot when
the ID comes from the pane-correlated AGY hook/report path; otherwise leave the
snapshot unsynthesized.
ogulcancelik
left a comment
There was a problem hiding this comment.
please implement the agy integration through its plugin and hook system rather than inferring session ids by scanning ~/.gemini/antigravity-cli/brain. selecting the newest directory is not robust and can associate multiple panes with the same or wrong conversation.
please use the existing integrations as references. src/integration/assets/grok/herdr-agent-state.sh shows a session-only hook reporting an id through pane.report_agent_session, while the opencode and kilo integrations show plugin-based integration patterns. the registry, install, status, and uninstall wiring lives under src/integration/.
the agy hook should report the exact conversationId for its pane using the official herdr:agy source. please include install/status/uninstall coverage, docs/next updates, and validation against the real agy cli.
"herdr:agy" / "agy"as an official agent source.agy --conversation <session_id>.agyresume planning and state reservation.(Cf. #1571)
Summary by CodeRabbit
herdr:agyagent.herdr:agysession references and automatically forwards the conversation ID when launching the agent.herdr:agy/agysession details when no prior persisted session is available.herdr:agyhandling, expected resume argv, and conversation ID inference/parsing behavior.