gemini-cli - 💡(How to fix) Fix Logger keeps stale session ID after /clear [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#27280Fetched 2026-05-20 03:59:29
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×2

Root Cause

/clear creates a new session ID and updates config. The session stats UI also listens to the clear event and updates. But useLogger() creates a Logger once using config.getSessionId(). Its dependency array is only [config], and config is the same object after /clear. So logs may continue to be written under the old session ID. This does not directly control resume, but it makes debugging misleading because logs and chat files disagree.

Code Example

useEffect(() => {
    const newLogger = new Logger(config.getSessionId(), config.storage);
    // ...
  }, [config]);

---

newSessionId = randomUUID();
  config.resetNewSessionState(newSessionId);

---

const handleClear = (newSessionId?: string) => {
    setStats((prevState) => ({
      ...prevState,
      sessionId: newSessionId || prevState.sessionId,

---

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                                 │
About Gemini CLI│                                                                                                                                                                                                                                                                                 │
CLI Version                                                                                    0.42.0Git Commit                                                                                     68e2196d5                                                                                                                                                                        │
Model                                                                                          Auto (Gemini 3)Sandbox                                                                                        no sandbox                                                                                                                                                                       │
OS                                                                                             linux                                                                                                                                                                            │
Auth Method                                                                                    Signed in with GoogleTier                                                                                           Gemini Code Assist in Google One AI Pro│                                                                                                                                                                                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RAW_BUFFERClick to expand / collapse

What happened?

/clear creates a new session ID and updates config. The session stats UI also listens to the clear event and updates. But useLogger() creates a Logger once using config.getSessionId(). Its dependency array is only [config], and config is the same object after /clear. So logs may continue to be written under the old session ID. This does not directly control resume, but it makes debugging misleading because logs and chat files disagree.

packages/cli/src/ui/hooks/useLogger.ts:16

  useEffect(() => {
    const newLogger = new Logger(config.getSessionId(), config.storage);
    // ...
  }, [config]);

packages/cli/src/ui/commands/clearCommand.ts:42

  newSessionId = randomUUID();
  config.resetNewSessionState(newSessionId);

packages/cli/src/ui/contexts/SessionContext.tsx:220

  const handleClear = (newSessionId?: string) => {
    setStats((prevState) => ({
      ...prevState,
      sessionId: newSessionId || prevState.sessionId,

What did you expect to happen?

The logger should follow the active session ID. It could listen to uiTelemetryService.clear, or useLogger() could depend on a session ID value rather than the stable config object. Logs should be reliable evidence for the current session. After /clear, new log entries should use the new session ID.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                                 │
│ About Gemini CLI                                                                                                                                                                                                                                                                │
│                                                                                                                                                                                                                                                                                 │
│ CLI Version                                                                                    0.42.0                                                                                                                                                                           │
│ Git Commit                                                                                     68e2196d5                                                                                                                                                                        │
│ Model                                                                                          Auto (Gemini 3)                                                                                                                                                                  │
│ Sandbox                                                                                        no sandbox                                                                                                                                                                       │
│ OS                                                                                             linux                                                                                                                                                                            │
│ Auth Method                                                                                    Signed in with Google                                                                                                                             │
│ Tier                                                                                           Gemini Code Assist in Google One AI Pro                                                                                                                                          │
│                                                                                                                                                                                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
</details>

Login information

Signed in with Google

Anything else we need to know?

No response

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

gemini-cli - 💡(How to fix) Fix Logger keeps stale session ID after /clear [1 participants]