Skip to content

Commit 8a41375

Browse files
committed
Fix OpenCode sessions not showing up immediately in sessions list
- Fix session ID regex parsing to correctly capture the ID after 'Session started' instead of incorrectly capturing 'started' as the ID - Add query invalidation when new session is created so the sessions list refreshes immediately instead of waiting for the 10-second polling interval
1 parent f2f7f71 commit 8a41375

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

web/src/components/Chat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,9 @@ export function Chat({ workspaceName, sessionId: initialSessionId, onSessionId,
538538

539539
if (msg.type === 'system') {
540540
if (msg.content.startsWith('Session started')) {
541-
const match = msg.content.match(/Session (\S+)/)
541+
const match = msg.content.match(/Session started:?\s+(\S+)/)
542542
if (match) {
543-
const newSessionId = match[1]
543+
const newSessionId = match[1].replace(/\.+$/, '')
544544
setSessionId(newSessionId)
545545
onSessionIdRef.current?.(newSessionId)
546546
}

web/src/pages/WorkspaceDetail.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ export function WorkspaceDetail() {
227227
const handleSessionId = useCallback((sessionId: string) => {
228228
if (name && chatMode?.type === 'chat' && chatMode.agentType) {
229229
api.recordSessionAccess(name, sessionId, chatMode.agentType).catch(() => {})
230+
queryClient.invalidateQueries({ queryKey: ['sessions', name] })
230231
}
231232
setChatMode((prev) => prev?.type === 'chat' ? { ...prev, sessionId } : prev)
232-
}, [name, chatMode])
233+
}, [name, chatMode, queryClient])
233234

234235
const { data: hostInfo, isLoading: hostLoading } = useQuery({
235236
queryKey: ['hostInfo'],

0 commit comments

Comments
 (0)