Skip to content

Commit 0b194c9

Browse files
committed
fix: terminal uses dedicated session 'terminal:main' — isolate from chat
Terminal was sharing session 'main' with chat, causing message bleed. Now uses TERMINAL_SESSION_KEY = 'terminal:main' for its own isolated session. Chat and terminal conversations are fully separated.
1 parent 7a548bb commit 0b194c9

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

components/gateway-terminal.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ interface TerminalEntry {
9797

9898
const MONO = "'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace"
9999
const STORAGE_KEY = 'knot-code:gw-terminal-history'
100+
const TERMINAL_SESSION_KEY = 'terminal:main'
100101
const MAX_HISTORY = 100
101102

102103
function uid(): string {
@@ -451,9 +452,9 @@ export function GatewayTerminal() {
451452
: undefined)) as string | undefined
452453
const eventIdempotencyKey = (p.idempotencyKey ?? p.idempotency_key) as string | undefined
453454

454-
// Accept if: idempotency key matches one we sent, OR session is 'main', OR no session key
455+
// Accept if: idempotency key matches one we sent, OR session is terminal's, OR no session key
455456
const idempotencyMatch = eventIdempotencyKey && pendingIdempotencyKeys.current.has(eventIdempotencyKey)
456-
const sessionMatch = !eventSessionKey || eventSessionKey === 'main'
457+
const sessionMatch = !eventSessionKey || eventSessionKey === TERMINAL_SESSION_KEY
457458

458459
console.log('[GW-Terminal] chat event:', { state, sessionKey: eventSessionKey, idempotencyKey: eventIdempotencyKey, idempotencyMatch, sessionMatch })
459460

@@ -579,7 +580,7 @@ export function GatewayTerminal() {
579580
const idempotencyKey = `gw-term-${Date.now()}`
580581
pendingIdempotencyKeys.current.add(idempotencyKey)
581582
const resp = (await sendRequest('chat.send', {
582-
sessionKey: 'main',
583+
sessionKey: TERMINAL_SESSION_KEY,
583584
message,
584585
idempotencyKey,
585586
})) as Record<string, unknown> | undefined
@@ -697,9 +698,9 @@ export function GatewayTerminal() {
697698
}
698699

699700
// Chat send (slash command or plain text)
700-
updateSkillProbeFromMessage('main', trimmed)
701+
updateSkillProbeFromMessage(TERMINAL_SESSION_KEY, trimmed)
701702
const policy = evaluateSkillFirstPolicy({
702-
sessionKey: 'main',
703+
sessionKey: TERMINAL_SESSION_KEY,
703704
message: trimmed,
704705
mode: 'hard_with_override',
705706
})

0 commit comments

Comments
 (0)