Skip to content

fix(gemini): wire --resume flag through to Gemini backend#378

Merged
tiann merged 2 commits intotiann:mainfrom
junmo-kim:fix/gemini-resume-wiring
Mar 31, 2026
Merged

fix(gemini): wire --resume flag through to Gemini backend#378
tiann merged 2 commits intotiann:mainfrom
junmo-kim:fix/gemini-resume-wiring

Conversation

@junmo-kim
Copy link
Copy Markdown
Contributor

@junmo-kim junmo-kim commented Mar 30, 2026

Problem

Gemini remote sessions currently start fresh when the runner respawns them with --resume <sessionId>. The --resume flag is accepted by the runner but not yet handled in the Gemini command path, so the session ID does not reach the ACP backend.

Related: #337, #338

Solution

  • Parse --resume in commands/gemini.ts and thread resumeSessionId through runGeminigeminiLoopGeminiSession, consistent with the existing OpenCode resume path (opencode/loop.ts)
  • When a session ID is present, call backend.loadSession() instead of backend.newSession() so the ACP server can restore the previous session state, with fallback to newSession on failure
  • Remove the now-redundant resumeSessionId from createGeminiBackend to avoid double-resume (CLI --resume flag + ACP session/load)
  • Extract Error.message before logging prompt failures, consistent with how stderr errors are already handled in the same file

Usage

Resume is triggered automatically by the runner when a Gemini session process is restarted. No user-facing CLI change; the --resume flag is an internal runner interface.

Tests

  • runGemini.test.ts: verify resumeSessionId is forwarded to geminiLoop
  • All existing tests pass

The --resume flag sent by the runner was silently ignored because
the gemini command did not parse it. This caused remote Gemini
sessions to always start fresh instead of resuming the previous
conversation context.

Thread resumeSessionId through commands/gemini.ts → runGemini →
geminiLoop → GeminiSession, mirroring the existing OpenCode
implementation. When a session ID is present, use ACP loadSession
instead of newSession to restore the previous session state, with
fallback to newSession on failure.

Remove the now-redundant resumeSessionId from createGeminiBackend
to avoid double-resume (CLI --resume flag + ACP session/load).
Error objects serialize to {} in JSON, making prompt failures
impossible to diagnose from logs. Extract the error message
before logging and surface it to the session UI, consistent with
how stderr errors are already handled in the same file.
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Findings

  • No issues identified in the added/modified lines.

Summary
Review mode: initial. No diff-attributable correctness, security, or regression issues found in the latest patch. Residual risk: the new Gemini resume path still lacks direct coverage for cli/src/commands/gemini.ts argument parsing and cli/src/gemini/geminiRemoteLauncher.ts loadSession fallback behavior; the added tests only verify runGemini forwards resumeSessionId.

Testing

  • Not run (automation)

HAPI Bot

@tiann tiann merged commit 3a073dc into tiann:main Mar 31, 2026
2 checks passed
SeeFlowerX pushed a commit to SeeFlowerX/hapi that referenced this pull request Apr 1, 2026
@junmo-kim junmo-kim deleted the fix/gemini-resume-wiring branch April 1, 2026 03:36
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