gemini-cli - ✅(Solved) Fix Interactive shell backgrounding can fail due to missing sessionId [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25111Fetched 2026-04-11 06:31:29
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×2closed ×1unlabeled ×1

Root Cause

The model-driven shell path appears to pass a sessionId explicitly, but the interactive UI path does not. That makes this look like a UI-specific regression rather than a generic shell backgrounding problem.

Fix Action

Fixed

PR fix notes

PR #25114: fix(cli): pass session id to interactive shell executions

Description (problem / solution / changelog)

Fixes #25111

Summary

  • pass config.getSessionId() into interactive shell execution config
  • add a targeted hook test asserting the session ID is propagated to ShellExecutionService.execute()

Why

Backgrounding an interactive shell currently goes through ShellExecutionService.background(pid). Recent shell background tracking expects executions to be associated with a session ID. The interactive UI path was not passing one into ShellExecutionService.execute(...), which made the runtime repro fail with Session ID is required for background operations.

Testing

  • npm run test --workspace @google/gemini-cli -- src/ui/hooks/useExecutionLifecycle.test.tsx

Changed files

  • packages/cli/src/ui/hooks/useExecutionLifecycle.test.tsx (modified, +23/-1)
  • packages/cli/src/ui/hooks/useExecutionLifecycle.ts (modified, +1/-0)

PR #25132: fix(cli): preserve shell session id for backgrounding

Description (problem / solution / changelog)

Fixes #25111

Summary

Preserve the current session ID in the interactive shell execution config so backgrounding can resolve the active PTY/session later.

Validation

  • npm test packages/cli/src/ui/hooks/useExecutionLifecycle.test.tsx

Changed files

  • packages/cli/src/ui/hooks/useExecutionLifecycle.test.tsx (modified, +4/-1)
  • packages/cli/src/ui/hooks/useExecutionLifecycle.ts (modified, +1/-0)
  • packages/cli/src/ui/hooks/useSessionResume.ts (modified, +3/-0)
  • packages/core/src/config/config.test.ts (modified, +37/-0)
  • packages/core/src/config/config.ts (modified, +21/-0)

Code Example

pid 16508
sessionIdInConfig null
background_error Session ID is required for background operations

---

Session ID is required for background operations
RAW_BUFFERClick to expand / collapse

Interactive shell backgrounding fails with "Session ID is required for background operations"

What happened

While exercising current main, I reproduced a failure when backgrounding a shell execution through the same runtime path used by the interactive UI.

I used the built origin/main code in a clean worktree (5fc8fea8d762d67d3bff14d00307138faff0bca5) and ran a real shell command via ShellExecutionService.execute(...) using the same shape the interactive UI builds in useExecutionLifecycle:

  • start from config.getShellExecutionConfig()
  • override terminalWidth, terminalHeight, defaultFg, defaultBg
  • do not add sessionId

Then I called ShellExecutionService.background(pid) the same way the interactive UI does.

Observed output:

pid 16508
sessionIdInConfig null
background_error Session ID is required for background operations

Expected

Backgrounding an interactive shell execution should succeed and register the task normally.

Actual

It throws:

Session ID is required for background operations

Why this matters

The model-driven shell path appears to pass a sessionId explicitly, but the interactive UI path does not. That makes this look like a UI-specific regression rather than a generic shell backgrounding problem.

Likely area

  • packages/cli/src/ui/hooks/useExecutionLifecycle.ts
  • packages/core/src/services/shellExecutionService.ts

The interactive UI path appears to call ShellExecutionService.execute(...) without a sessionId, then later calls ShellExecutionService.background(pid).

extent analysis

TL;DR

Passing a valid sessionId to ShellExecutionService.execute(...) is likely required to fix the "Session ID is required for background operations" error when backgrounding an interactive shell execution.

Guidance

  • Verify that sessionId is being generated and passed correctly in the interactive UI path, specifically in useExecutionLifecycle and ShellExecutionService.execute(...).
  • Check the config.getShellExecutionConfig() method to ensure it includes a valid sessionId or modify it to generate one if necessary.
  • Review the ShellExecutionService.background(pid) method to understand how it uses the sessionId and ensure it is being called with a valid sessionId.
  • Consider adding a sessionId parameter to the ShellExecutionService.execute(...) method call in the interactive UI path to match the model-driven shell path.

Example

No code snippet is provided as the issue does not contain sufficient information to create a specific example.

Notes

The fix may require modifying the useExecutionLifecycle hook or the ShellExecutionService to handle sessionId generation or passing. The exact changes will depend on the implementation details of these components.

Recommendation

Apply a workaround by passing a valid sessionId to ShellExecutionService.execute(...), as this is the most direct way to address the "Session ID is required for background operations" error.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING