Skip to content

Commit e095772

Browse files
alari76claude
andcommitted
fix: show 'Session started' immediately instead of empty chat on startup (#386)
Use a dedicated _processStartedOnce flag to detect restarts instead of _lastReportedModel, which may be undefined when the first process never emitted system_init (e.g. OpenCode sessions starting without a model). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3c30ac4 commit e095772

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

server/session-lifecycle.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,10 @@ export class SessionLifecycle {
174174
session.claudeProcess = cp
175175
this.deps.globalBroadcast?.({ type: 'sessions_updated' })
176176

177-
// Only show "Session started" for the initial start, not for restarts
177+
// Only show "Session started" for the very first start, not for restarts
178178
// triggered by model/permission changes — those already show a model message.
179-
const isRestart = !!session._lastReportedModel
179+
const isRestart = !!session._processStartedOnce
180+
session._processStartedOnce = true
180181
const startMsg: WsServerMessage = { type: 'claude_started', sessionId }
181182
this.deps.addToHistory(session, startMsg)
182183
if (!isRestart) {

server/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export interface Session {
8989
_namingAttempts: number
9090
/** The model reported by the last system init event, used to suppress duplicate init messages. */
9191
_lastReportedModel?: string
92+
/** Whether a process has been started at least once (to suppress "Session started" on restarts). */
93+
_processStartedOnce?: boolean
9294
/** Last user input sent, stored for API error retry. */
9395
_lastUserInput?: string
9496
/** First user input, preserved for session naming (not cleared by API retry). */

0 commit comments

Comments
 (0)