@jacexh/claude-web-console 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jacexh/claude-web-console",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "Web-based console for Claude Code — manage sessions, switch models, preview artifacts",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,10 +17,10 @@ export function registerHttpRoutes(app: FastifyInstance, sessionManager: Session
17
17
  await mkdir(cwd, { recursive: true })
18
18
  }
19
19
 
20
- const tempId = await sessionManager.createSession(body ?? undefined)
21
- const status = sessionManager.getSessionStatus(tempId)
20
+ const sessionId = await sessionManager.createSession(body ?? undefined)
21
+ const status = sessionManager.getSessionStatus(sessionId)
22
22
 
23
- reply.code(201).send({ sessionId: tempId, status })
23
+ reply.code(201).send({ sessionId, status })
24
24
  })
25
25
 
26
26
  app.post<{ Params: { id: string } }>('/api/sessions/:id/resume', async (request, reply) => {
@@ -158,7 +158,7 @@ export class SessionManager {
158
158
  private streamingSessionIds = new Set<string>()
159
159
  private sessionListeners = new Map<string, Set<SessionListener>>()
160
160
  private idleTimers = new Map<string, ReturnType<typeof setTimeout>>()
161
- private pendingRemaps = new Map<string, { sessionIdRef: { current: string } }>()
161
+ private pendingRemaps = new Map<string, { sessionIdRef: { current: string }; resolve?: (sessionId: string) => void }>()
162
162
  // Track cwd for each session so we can resume in the correct project
163
163
  private sessionCwds = new Map<string, string>()
164
164
  /** User-supplied creation options that must survive resume cycles */
@@ -384,12 +384,21 @@ export class SessionManager {
384
384
  })
385
385
 
386
386
  // Store tempId in pendingRemaps for remap inside consumeStream
387
- this.pendingRemaps.set(tempId, { sessionIdRef })
387
+ const sessionIdReady = new Promise<string>((resolve) => {
388
+ this.pendingRemaps.set(tempId, { sessionIdRef, resolve })
389
+ })
388
390
 
389
391
  // For new sessions, start stream immediately — SDK may emit init messages
390
392
  this.startStreamConsumer(tempId, session)
391
393
 
392
- return tempId
394
+ // Wait for real sessionId (resolved when consumeStream processes first SDK message)
395
+ const timeoutMs = 10_000
396
+ const sessionId = await Promise.race([
397
+ sessionIdReady,
398
+ new Promise<string>((_, reject) => setTimeout(() => reject(new Error('Session init timed out')), timeoutMs)),
399
+ ])
400
+
401
+ return sessionId
393
402
  }
394
403
 
395
404
  private fetchAndBroadcastModels(sessionId: string, session: SDKSession, currentModel?: string): void {
@@ -528,6 +537,8 @@ export class SessionManager {
528
537
  if (prevStatus) this.sessionStatus.set(sessionId, prevStatus)
529
538
  const q = this.activeQueries.get(tempId)
530
539
  if (q) { this.activeQueries.delete(tempId); this.activeQueries.set(sessionId, q) }
540
+ // Resolve the sessionId promise before cleaning up the remap entry
541
+ if (remap.resolve) remap.resolve(sessionId)
531
542
  this.pendingRemaps.delete(tempId)
532
543
  // Update our tracking variable
533
544
  currentSessionId = sessionId