Files
orca/src/main/runtime/agent-session-conversation-command-record.ts
T
Brennan BensonandMerge Sim f1d8545024 feat(chat): support structured /clear and /compact commands (#19164)
* feat(chat): support structured clear and compact commands

* fix(chat): authorize mobile commands and bound clear-chain projection

* fix(chat): localize conversation command send errors

* fix(chat): retain clear pane identity with reopened history

* test: account for combined structured session RPC additions

---------

Co-authored-by: Merge Sim <sim@local>
2026-09-06 21:17:00 -07:00

28 lines
1007 B
TypeScript

import type { AgentSessionStoreState } from './agent-session-record-store-file'
import type { AgentSessionConversationCommandRecord } from '../../shared/agent-session-conversation-command'
export function commitConversationCommandRecord(
state: AgentSessionStoreState,
sessionId: string,
fence: number,
command: AgentSessionConversationCommandRecord
): void {
const record = state.records.get(sessionId)
if (!record || record.lease.runtimeFence !== fence) {
throw new Error('agent_session_checkpoint_stale')
}
state.records.set(sessionId, { ...record, conversationCommand: command })
if (
command.command === 'clear' &&
command.phase === 'committed' &&
command.replacementSessionId
) {
if (!state.records.has(command.replacementSessionId)) {
throw new Error('agent_session_identity_required')
}
state.visibleSessionIds.delete(sessionId)
state.visibleSessionIds.add(command.replacementSessionId)
state.visibleSessionIdsIndexPresent = true
}
}