@jacexh/claude-web-console 0.12.0 → 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
|
@@ -17,10 +17,10 @@ export function registerHttpRoutes(app: FastifyInstance, sessionManager: Session
|
|
|
17
17
|
await mkdir(cwd, { recursive: true })
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
const status = sessionManager.getSessionStatus(
|
|
20
|
+
const sessionId = await sessionManager.createSession(body ?? undefined)
|
|
21
|
+
const status = sessionManager.getSessionStatus(sessionId)
|
|
22
22
|
|
|
23
|
-
reply.code(201).send({ sessionId
|
|
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
|
-
|
|
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
|
-
|
|
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
|