Skip to content

feat: add Antigravity session restore support - #1839

Closed
adamkrellenstein wants to merge 4 commits into
herdrdev:masterfrom
adamkrellenstein:feat/agy-session-restore
Closed

feat: add Antigravity session restore support#1839
adamkrellenstein wants to merge 4 commits into
herdrdev:masterfrom
adamkrellenstein:feat/agy-session-restore

Conversation

@adamkrellenstein

@adamkrellenstein adamkrellenstein commented Jul 24, 2026

Copy link
Copy Markdown
  • Registers "herdr:agy" / "agy" as an official agent source.
  • Formulates native session resume plan: agy --conversation <session_id>.
  • Adds unit test coverage for agy resume planning and state reservation.

(Cf. #1571)

Summary by CodeRabbit

  • New Features
    • Added support for resuming sessions with the herdr:agy agent.
    • Session resume now recognizes herdr:agy session references and automatically forwards the conversation ID when launching the agent.
  • Bug Fixes
    • Improved agent session snapshot detection to reliably infer and persist the correct herdr:agy/agy session details when no prior persisted session is available.
  • Tests
    • Updated automated checks to cover reserved herdr:agy handling, expected resume argv, and conversation ID inference/parsing behavior.

@kangal-bot kangal-bot added the greptile-review Trigger Greptile review for contributor-approved pull requests label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds AGY session resume support by registering herdr:agy, generating agy --conversation <id> arguments, inferring session IDs, and capturing inferred sessions in pane snapshots.

Changes

AGY Resume Support

Layer / File(s) Summary
AGY source registration and planning
src/agent_resume.rs
Registers AGY as a reserved and official source, generates agy --conversation <id> arguments, and tests the behavior.
AGY session ID inference
src/agent_resume.rs
Extracts conversation IDs from command lines or selects the newest entry from the AGY brain directory.
AGY snapshot capture
src/persist/snapshot.rs
Preserves persisted sessions and captures inferred AGY sessions as ID-based snapshots.

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
Loading

Possibly related issues

  • ogulcancelik/herdr#1824 — Covers Antigravity session capture and restoration using agy --conversation <id>.

Suggested reviewers: ogulcancelik

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding Antigravity session restore support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@adamkrellenstein
adamkrellenstein force-pushed the feat/agy-session-restore branch from 7f941f2 to b85481c Compare July 24, 2026 20:44
@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown

Greptile Summary

Adds Antigravity session restoration support.

  • Registers herdr:agy as an official reserved agent source.
  • Builds native resume commands using agy --conversation <session_id>.
  • Infers Antigravity session IDs during snapshot capture and adds focused unit coverage.

Confidence Score: 5/5

The 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.

Important Files Changed

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

Comment thread src/agent_resume.rs Outdated
@ogulcancelik ogulcancelik changed the title Adds native agent session restore support for the Antigravity CLI feat: add Antigravity session restore support Jul 25, 2026
@ogulcancelik
ogulcancelik marked this pull request as draft July 25, 2026 18:15
@ogulcancelik

Copy link
Copy Markdown
Collaborator

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 conversationId. The Herdr-managed integration should capture that value, report it through pane.report_agent_session with the official herdr:agy source, and include install/status/uninstall behavior plus the required docs/next updates.

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 agy --conversation <id> resumes the same conversation. Cover the supported platforms and document any AGY version requirement.

@adamkrellenstein
adamkrellenstein marked this pull request as ready for review July 25, 2026 18:16

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5285d54 and 03c6818.

📒 Files selected for processing (2)
  • src/agent_resume.rs
  • src/persist/snapshot.rs

Comment thread src/agent_resume.rs
Comment on lines +218 to +226
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());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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.

Comment thread src/agent_resume.rs
Comment on lines +231 to +255
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ 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 ogulcancelik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@ogulcancelik
ogulcancelik marked this pull request as draft July 25, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

greptile-review Trigger Greptile review for contributor-approved pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants