{"version":3,"file":"sessionStore.mjs","names":[],"sources":["../../../src/web/stores/sessionStore.ts"],"sourcesContent":["import type { SessionLifecycle } from '@agimon-ai/po-core/sessionProtocol';\nimport type { ApiTransport } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\n\nimport { CONTEXT_ENTRY_TYPE, MODE_ENTRY_TYPE, HISTORY_REQUEST_TYPE } from '../../types/hub';\nimport {\n  abortCommand,\n  builtinCommandFrame,\n  clearQueueCommand,\n  dialogCancelled,\n  dialogConfirmed,\n  dialogValue,\n  enqueueAutomaticCommand,\n  promoteQueuedCommand,\n  removeQueuedCommand,\n  resumeQueueCommand,\n  getAvailableModelsCommand,\n  getAvailableThinkingLevelsCommand,\n  getCommandsCommand,\n  getSessionStatsCommand,\n  getStateCommand,\n  promptCommand,\n  type RpcImage,\n  rewindCommand,\n  setModelCommand,\n  setSessionNameCommand,\n  setThinkingLevelCommand,\n  steerCommand,\n} from '../lib/commands';\nimport { modeToggle } from '../lib/composition';\nimport {\n  appendUserPrompt,\n  applySelectionAnswer,\n  clearDialog,\n  initialSessionState,\n  prependHistory,\n  reduceSession,\n  replaceQueuedEntries,\n  type QueuedEntry,\n  type SessionState,\n  type TimelineEntry,\n  type UserEntry,\n} from '../lib/sessionModel';\nimport { hasSessionProtocol } from '../lib/sessionProtocolCommands';\nimport { fetchSessionSelection, postModeAction } from '../lib/sessionSelectionApi';\nimport { sendFrame, sendFrameWithAck, sendHubFrame } from '../lib/transport';\nimport { traceStore } from '../lib/uiTrace';\nimport { activeSessionId, sessionsStore } from './sessionsStore';\n\n/**\n * One store per session, created on first touch.\n *\n * The heavyweight timeline state only exists for sessions this page has\n * subscribed to; the rail runs on hub summaries alone.\n */\nconst stores = new Map<string, Store<SessionState>>();\nconst selectionRequests = new Map<string, object>();\nconst selectionVersions = new Map<string, { selection: number; context: number; modes: number }>();\nconst SELECTION_STATUS_KEYS = new Set(['po-preset', 'po-domain', 'po-profile']);\n\n/** Newer reads and live projections supersede each independently fetched part. */\nexport async function refreshSessionSelection(sessionId: string): Promise<void> {\n  const token = {};\n  selectionRequests.set(sessionId, token);\n  const versions = selectionVersions.get(sessionId) ?? { selection: 0, context: 0, modes: 0 };\n  selectionVersions.set(sessionId, versions);\n  const before = { ...versions };\n  const answer = await fetchSessionSelection(sessionId);\n  if (selectionRequests.get(sessionId) !== token) return;\n  selectionRequests.delete(sessionId);\n  if (before.selection !== versions.selection) {\n    delete answer.preset;\n    delete answer.domains;\n    delete answer.profile;\n  }\n  if (before.context !== versions.context) delete answer.context;\n  if (before.modes !== versions.modes) delete answer.modes;\n  sessionStoreFor(sessionId).setState((state) => applySelectionAnswer(state, answer));\n}\n\n/**\n * Flips a mode through the modes API, not a `/mode` prompt, so the switch settles as soon as the\n * action does. The answer supersedes any older read; a failure shows as a session error.\n */\nexport async function invokeModeAction(\n  modeId: string,\n  action: string,\n  sessionId: string | null = activeSessionId(),\n  request?: ApiTransport,\n): Promise<void> {\n  if (sessionId === null) return;\n  try {\n    const projection = await postModeAction(sessionId, modeId, action, request);\n    const versions = selectionVersions.get(sessionId) ?? { selection: 0, context: 0, modes: 0 };\n    versions.modes++;\n    selectionVersions.set(sessionId, versions);\n    sessionStoreFor(sessionId).setState((state) =>\n      state.modes !== null && state.modes.revision > projection.revision ? state : { ...state, modes: projection },\n    );\n  } catch (error) {\n    const message = error instanceof Error ? error.message : String(error);\n    sessionStoreFor(sessionId).setState((state) => reduceSession(state, { type: 'error', message }));\n  }\n}\n\n/**\n * Flips a mode the way its switch would: through the modes API when the catalog offers an\n * input-free toggle, else through `/mode <id>`, which asks for what the action still needs.\n */\nexport async function toggleMode(\n  modeId: string,\n  sessionId: string | null = activeSessionId(),\n  request?: ApiTransport,\n): Promise<void> {\n  if (sessionId === null) return;\n  const record = sessionStoreFor(sessionId).state.modes?.modes.find(({ id }) => id === modeId);\n  const action = record === undefined ? undefined : modeToggle(record);\n  if (action === undefined) return runCommand(`/mode ${modeId}`, sessionId);\n  await invokeModeAction(modeId, action, sessionId, request);\n}\n\nconst MAX_CACHED_ENTRIES = 500;\n\nexport function setHasNewerHistory(sessionId: string, value: boolean): void {\n  sessionStoreFor(sessionId).setState((state) =>\n    state.hasNewerHistory === value ? state : { ...state, hasNewerHistory: value },\n  );\n}\n/** Sessions whose visible transcript is currently supplied by Pi's protocol. */\nconst protocolTranscripts = new Set<string>();\n/** Projection keys changed after a subscription snapshot was requested. */\nconst replayGuards = new Map<string, { statuses: Set<string>; widgets: Set<string> }>();\nconst PROTOCOL_ENTRY_KINDS = new Set<TimelineEntry['kind']>(['user', 'assistant', 'tool']);\n/** Read-only stand-in while no session is focused, so hooks stay unconditional. */\nconst detachedStore = new Store<SessionState>(initialSessionState);\n/** Sessions a live transcript stream currently feeds; any other store may hold stale facts. */\nexport const streamedSessions = traceStore('streamedSessions', new Store<ReadonlySet<string>>(new Set<string>()));\n\nexport function setSessionStreamed(sessionId: string, streamed: boolean): void {\n  if (streamedSessions.state.has(sessionId) === streamed) return;\n  streamedSessions.setState((state) => {\n    const next = new Set(state);\n    if (streamed) next.add(sessionId);\n    else next.delete(sessionId);\n    return next;\n  });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function sessionStoreFor(sessionId: string | null): Store<SessionState> {\n  if (sessionId === null) return detachedStore;\n  const existing = stores.get(sessionId);\n  if (existing) return existing;\n  const created = traceStore('session', new Store<SessionState>(initialSessionState));\n  stores.set(sessionId, created);\n  return created;\n}\n\n/** Reads the focused session's state; components stay on the useStore idiom. */\nexport function useActiveSession<T>(selector: (state: SessionState) => T): T {\n  const activeId = useStore(sessionsStore, (state) => state.activeId);\n  return useStore(sessionStoreFor(activeId), selector);\n}\n\nfunction projectionKey(frame: Record<string, unknown>): { kind: 'status' | 'widget'; key: string } | undefined {\n  const projected = frame.type === 'replay' && isRecord(frame.frame) ? frame.frame : frame;\n  if (projected.type !== 'extension_ui_request') return undefined;\n  if (typeof projected.statusKey === 'string' && projected.method === 'setStatus') {\n    return { kind: 'status', key: projected.statusKey };\n  }\n  if (typeof projected.widgetKey === 'string' && projected.method === 'setWidget') {\n    return { kind: 'widget', key: projected.widgetKey };\n  }\n  return undefined;\n}\n\n/** Presentation frames from the Pi protocol, or from bounded replay when replay is true. */\nexport function applySessionFrame(\n  sessionId: string,\n  frame: Record<string, unknown>,\n  options: { replay?: boolean; source?: 'hub' } = {},\n): void {\n  if (!options.replay) {\n    const versions = selectionVersions.get(sessionId) ?? { selection: 0, context: 0, modes: 0 };\n    selectionVersions.set(sessionId, versions);\n    if (\n      frame.type === 'extension_ui_request' &&\n      frame.method === 'setStatus' &&\n      SELECTION_STATUS_KEYS.has(String(frame.statusKey))\n    )\n      versions.selection++;\n    if (frame.type === 'entry_appended' && isRecord(frame.entry) && frame.entry.type === 'custom') {\n      if (frame.entry.customType === CONTEXT_ENTRY_TYPE) {\n        versions.context++;\n        versions.selection++;\n      }\n      if (frame.entry.customType === MODE_ENTRY_TYPE) versions.modes++;\n    }\n  }\n  const projection = projectionKey(frame);\n  const guard = replayGuards.get(sessionId);\n  if (projection !== undefined && guard !== undefined) {\n    const keys = projection.kind === 'status' ? guard.statuses : guard.widgets;\n    if (options.replay && keys.has(projection.key)) return;\n    if (!options.replay) keys.add(projection.key);\n  }\n  // The presentation stream owns live and replay projection until the typed session\n  // service publishes a snapshot. Once it does, only Po-specific frames reduce here.\n  const transcriptFromProtocol =\n    protocolTranscripts.has(sessionId) || (options.source === 'hub' && hasReadyHistoryReader(sessionId));\n  sessionStoreFor(sessionId).setState((state) => {\n    const next = reduceSession(state, frame, { transcriptFromProtocol });\n    if (\n      !historyReaders.has(sessionId) ||\n      (next.entries.length <= MAX_CACHED_ENTRIES && next.restoredIds.length <= MAX_CACHED_ENTRIES)\n    )\n      return next;\n    return {\n      ...next,\n      entries: next.entries.length > MAX_CACHED_ENTRIES ? next.entries.slice(-MAX_CACHED_ENTRIES) : next.entries,\n      restoredIds:\n        next.restoredIds.length > MAX_CACHED_ENTRIES ? next.restoredIds.slice(-MAX_CACHED_ENTRIES) : next.restoredIds,\n    };\n  });\n}\n\n/** Lets the presentation stream resume transcript ownership after a typed service failure. */\nexport function releaseProtocolTranscript(sessionId: string): void {\n  protocolTranscripts.delete(sessionId);\n}\n\n/** A thread has no protocol session, so its journal remains its authoritative transcript. */\nexport function applyThreadFrame(threadKey: string, frame: Record<string, unknown>): void {\n  sessionStoreFor(threadKey).setState((state) => reduceSession(state, frame));\n}\n\n/**\n * One session's paging state: how far back the page has read, and whether a\n * request is already in flight. Kept beside the timeline rather than inside it\n * because it describes the reading, not the session.\n */\ninterface HistoryState {\n  cursor: string | null;\n  hasMore: boolean;\n  loading: boolean;\n  /** Pages taken so far; also what keeps prepended entry ids unique. */\n  pages: number;\n}\n\nconst history = new Map<string, HistoryState>();\nconst historyReaders = new Map<\n  string,\n  {\n    read: (direction: 'older' | 'newer' | 'latest') => boolean;\n    ready: () => boolean;\n  }\n>();\n\nfunction hasReadyHistoryReader(sessionId: string): boolean {\n  return historyReaders.get(sessionId)?.ready() === true;\n}\n\nexport function bindHistoryReader(\n  sessionId: string,\n  reader: (direction: 'older' | 'newer' | 'latest') => boolean,\n  ready: () => boolean = () => false,\n): () => void {\n  const binding = { read: reader, ready };\n  historyReaders.set(sessionId, binding);\n  return () => {\n    if (historyReaders.get(sessionId) === binding) historyReaders.delete(sessionId);\n  };\n}\n\nexport function requestNewerHistory(sessionId: string | null): boolean {\n  return sessionId !== null && (historyReaders.get(sessionId)?.read('newer') ?? false);\n}\n\nexport function requestLatestHistory(sessionId: string | null): boolean {\n  return sessionId !== null && (historyReaders.get(sessionId)?.read('latest') ?? false);\n}\nconst historyStore = traceStore('sessionHistory', new Store<Record<string, HistoryState>>({}));\nconst NO_HISTORY: HistoryState = { cursor: null, hasMore: true, loading: false, pages: 0 };\n\nfunction historyFor(sessionId: string): HistoryState {\n  return history.get(sessionId) ?? NO_HISTORY;\n}\n\nfunction setHistory(sessionId: string, next: HistoryState): void {\n  history.set(sessionId, next);\n  historyStore.setState((state) => ({ ...state, [sessionId]: next }));\n}\n\n/** Whether more transcript exists above what this session's page holds. */\nexport function useHasOlderHistory(sessionId: string | null): boolean {\n  return useStore(historyStore, (state) => (sessionId === null ? false : (state[sessionId] ?? NO_HISTORY).hasMore));\n}\n\n/**\n * Asks the hub for the window above what this page holds.\n *\n * One request at a time: a reader flicking upwards would otherwise ask for the\n * same window repeatedly before the first answer lands, and every copy would\n * be prepended.\n */\nexport function requestOlderHistory(sessionId: string | null): boolean {\n  if (sessionId === null) return false;\n  const reader = historyReaders.get(sessionId);\n  if (reader) return reader.read('older');\n  const current = historyFor(sessionId);\n  if (current.loading || !current.hasMore) return false;\n  setHistory(sessionId, { ...current, loading: true });\n  sendHubFrame({\n    type: HISTORY_REQUEST_TYPE,\n    sessionId,\n    ...(current.cursor === null ? {} : { before: current.cursor }),\n  });\n  return true;\n}\n\n/** Folds one answered window above the timeline and records how far back it reached. */\nexport function applyHistoryPage(sessionId: string, frames: Record<string, unknown>[], next: HistoryPage): void {\n  const current = historyFor(sessionId);\n  const pages = current.pages + 1;\n  sessionStoreFor(sessionId).setState((state) => prependHistory(state, frames, pages));\n  setHistory(sessionId, { cursor: next.cursor, hasMore: next.hasMore, loading: false, pages });\n}\n\nexport interface HistoryPage {\n  cursor: string | null;\n  hasMore: boolean;\n}\n\n/** The oldest entry the page holds, which is where the next window ends. */\nexport function seedHistoryCursor(sessionId: string, cursor: string | null): void {\n  setHistory(sessionId, { ...NO_HISTORY, cursor });\n}\n\n/** Keeps Po-only and optimistic entries beside the protocol items that preceded them. */\nfunction mergeProtocolEntries(\n  previous: TimelineEntry[],\n  protocol: TimelineEntry[],\n  pendingUserIds: ReadonlySet<string>,\n  reconciledUserIds: ReadonlySet<string>,\n): TimelineEntry[] {\n  const localByAnchor = new Map<string | null, TimelineEntry[]>();\n  let anchor: string | null = null;\n  for (const entry of previous) {\n    const protocolOwned =\n      (PROTOCOL_ENTRY_KINDS.has(entry.kind) || reconciledUserIds.has(entry.id)) && !pendingUserIds.has(entry.id);\n    if (protocolOwned) {\n      anchor = entry.id;\n      continue;\n    }\n    const local = localByAnchor.get(anchor) ?? [];\n    local.push(entry);\n    localByAnchor.set(anchor, local);\n  }\n\n  // Entries folded before any protocol item (a page load replays notifications before the\n  // snapshot lands) have no anchor. Those with a time go where it says, not all at the top.\n  const unanchored = localByAnchor.get(null) ?? [];\n  const merged = unanchored.filter((entry) => entry.timestamp === undefined);\n  const used = new Set<string | null>([null]);\n  for (const entry of protocol) {\n    merged.push(entry, ...(localByAnchor.get(entry.id) ?? []));\n    used.add(entry.id);\n  }\n  for (const [entryAnchor, local] of localByAnchor) {\n    if (!used.has(entryAnchor)) merged.push(...local);\n  }\n  for (const entry of unanchored) {\n    if (entry.timestamp === undefined) continue;\n    const index = merged.findIndex((other) => other.timestamp !== undefined && other.timestamp > entry.timestamp!);\n    if (index === -1) merged.push(entry);\n    else merged.splice(index, 0, entry);\n  }\n  return merged;\n}\n\n/**\n * Replaces protocol-owned transcript items with the authoritative snapshot.\n *\n * Local echoes disappear when the protocol publishes them. Po-only entries,\n * such as notices, queued messages, and run dividers, retain their place beside\n * the protocol item that preceded them.\n */\nexport function applyProtocolTranscript(sessionId: string, entries: TimelineEntry[], streaming: boolean): void {\n  protocolTranscripts.add(sessionId);\n  sessionStoreFor(sessionId).setState((state) => {\n    const pendingUserEntries = [...state.pendingUserEntries];\n    const pendingUserIdsBeforeReconciliation = new Set(pendingUserEntries.map((pending) => pending.id));\n    const knownProtocolIds = new Set(\n      state.entries\n        .filter((entry) => PROTOCOL_ENTRY_KINDS.has(entry.kind) && !pendingUserIdsBeforeReconciliation.has(entry.id))\n        .map((entry) => entry.id),\n    );\n    const protocolUserEntryIds = { ...state.protocolUserEntryIds };\n    const previousBySource = new Map(state.entries.map((entry) => [entry.sourceEntryId ?? entry.id, entry]));\n    const normalizedEntries = entries.map((entry) => {\n      const sourceEntryId = entry.sourceEntryId ?? entry.id;\n      const previous = previousBySource.get(sourceEntryId);\n      const turnId = entry.turnId ?? previous?.turnId ?? state.transcriptTurnIds[sourceEntryId];\n      return {\n        ...entry,\n        ...(entry.sourceEntryId !== undefined ? { sourceEntryId } : {}),\n        ...(entry.sourceEntryIds === undefined && previous?.sourceEntryIds\n          ? { sourceEntryIds: previous.sourceEntryIds }\n          : {}),\n        ...(turnId ? { turnId } : {}),\n      };\n    });\n    // Claimed prompts are remembered rather than dropped: the journal reports\n    // the same message on its own channel, and that copy has to fold into this\n    // entry instead of arriving as a new one.\n    const reconciledUserEntries = [...state.reconciledUserEntries];\n\n    // Work backwards so repeated text binds to the newest matching prompt. The\n    // local id keeps React from mounting the same message again when Pi publishes\n    // its authoritative transcript copy at the end of a run.\n    for (let index = entries.length - 1; index >= 0; index -= 1) {\n      const entry = entries[index];\n      if (entry?.kind !== 'user') continue;\n      const localId = protocolUserEntryIds[entry.id];\n      if (localId !== undefined) {\n        normalizedEntries[index] = {\n          ...normalizedEntries[index]!,\n          sourceEntryId: entry.sourceEntryId ?? entry.id,\n          id: localId,\n        };\n        continue;\n      }\n      if (knownProtocolIds.has(entry.id)) continue;\n      const pendingIndex = pendingUserEntries.findLastIndex((pending) => pending.text === entry.text);\n      if (pendingIndex === -1) continue;\n      const [pending] = pendingUserEntries.splice(pendingIndex, 1);\n      if (pending === undefined) continue;\n      protocolUserEntryIds[entry.id] = pending.id;\n      reconciledUserEntries.push(pending);\n      normalizedEntries[index] = {\n        ...normalizedEntries[index]!,\n        sourceEntryId: entry.sourceEntryId ?? entry.id,\n        id: pending.id,\n      };\n    }\n\n    const pendingUserIds = new Set(pendingUserEntries.map((pending) => pending.id));\n    const reconciledUserIds = new Set(Object.values(protocolUserEntryIds));\n    return {\n      ...state,\n      entries: mergeProtocolEntries(state.entries, normalizedEntries, pendingUserIds, reconciledUserIds),\n      streaming: state.lifecycle === null ? streaming : state.lifecycle.operation !== null,\n      settled: state.lifecycle === null ? !streaming : state.lifecycle.operation === null,\n      pendingUserEntries,\n      reconciledUserEntries,\n      protocolUserEntryIds,\n    };\n  });\n}\n\nfunction protocolQueueMatches(state: SessionState, queue: readonly QueuedEntry[]): boolean {\n  const current = state.entries.filter((entry): entry is QueuedEntry => entry.kind === 'queued');\n  return queueEntriesMatch(current, queue);\n}\n\nfunction queueEntriesMatch(\n  current: readonly Omit<QueuedEntry, 'kind'>[],\n  queue: readonly Omit<QueuedEntry, 'kind'>[],\n): boolean {\n  return (\n    current.length === queue.length &&\n    current.every((entry, index) => {\n      const next = queue[index];\n      if (\n        next === undefined ||\n        entry.id !== next.id ||\n        entry.text !== next.text ||\n        entry.delivery !== next.delivery ||\n        entry.scheduling !== next.scheduling ||\n        entry.disposition !== next.disposition\n      )\n        return false;\n      const images = entry.images ?? [];\n      const nextImages = next.images ?? [];\n      return (\n        images.length === nextImages.length &&\n        images.every((image, imageIndex) => {\n          const nextImage = nextImages[imageIndex];\n          return nextImage !== undefined && image.data === nextImage.data && image.mimeType === nextImage.mimeType;\n        })\n      );\n    })\n  );\n}\n\n/** Applies execution and retained-input state from the server, never from replayed history. */\nexport function applySessionLifecycle(sessionId: string, lifecycle: SessionLifecycle, newBinding = false): void {\n  sessionStoreFor(sessionId).setState((state) => {\n    const current = state.lifecycle;\n    if (!newBinding && current !== null && lifecycle.revision < current.revision) return state;\n    const queue: QueuedEntry[] = lifecycle.queue.map(({ id, text, images, delivery, scheduling, disposition }) => ({\n      kind: 'queued',\n      id,\n      text,\n      delivery,\n      scheduling,\n      disposition,\n      ...(images === undefined ? {} : { images: images.map(({ data, mimeType }) => ({ data, mimeType })) }),\n    }));\n    const streaming = lifecycle.operation !== null;\n    const queueMatches = protocolQueueMatches(state, queue);\n    const pendingSteers = steerEntries(state, lifecycle.steers ?? []);\n    if (\n      !newBinding &&\n      current !== null &&\n      current.revision === lifecycle.revision &&\n      current.paused === lifecycle.paused &&\n      current.operation?.id === lifecycle.operation?.id &&\n      current.operation?.kind === lifecycle.operation?.kind &&\n      current.operation?.status === lifecycle.operation?.status &&\n      queueEntriesMatch(current.queue, queue) &&\n      queueMatches &&\n      pendingSteers === state.pendingSteers &&\n      state.streaming === streaming &&\n      state.settled === !streaming &&\n      (state.agent === null || state.agent.isStreaming === streaming)\n    )\n      return state;\n    const updated = queueMatches ? state : replaceQueuedEntries(state, queue);\n    return {\n      ...updated,\n      lifecycle,\n      pendingSteers,\n      streaming,\n      settled: !streaming,\n      ...(state.agent === null || state.agent.isStreaming === streaming\n        ? {}\n        : { agent: { ...state.agent, isStreaming: streaming } }),\n    };\n  });\n}\n\n/**\n * The lifecycle's in-flight steers as user rows, skipping any whose entry already landed. Unchanged rows keep\n * their object, and an unchanged list returns the current one, so renders and native row caches stay put.\n */\nfunction steerEntries(state: SessionState, steers: NonNullable<SessionLifecycle['steers']>): readonly UserEntry[] {\n  const next = steers\n    .filter((steer) => !state.placedSteers.includes(steer.id))\n    .map(({ id, text, images, sender }): UserEntry => {\n      const current = state.pendingSteers.find((entry) => entry.id === `steer:${id}`);\n      const userImages = images?.map(({ data, mimeType }) => ({ data, mimeType }));\n      if (\n        current &&\n        current.text === text &&\n        current.sender?.id === sender?.id &&\n        current.sender?.name === sender?.name &&\n        JSON.stringify(current.images) === JSON.stringify(userImages)\n      )\n        return current;\n      return {\n        kind: 'user',\n        id: `steer:${id}`,\n        text,\n        pending: true,\n        ...(userImages?.length ? { images: userImages } : {}),\n        ...(sender ? { sender } : {}),\n      };\n    });\n  return next.length === state.pendingSteers.length &&\n    next.every((entry, index) => entry === state.pendingSteers[index])\n    ? state.pendingSteers\n    : next;\n}\n\n/** Replaces composer queue rows with the protocol server's authoritative queue. */\nexport function applyProtocolQueue(sessionId: string, queue: readonly QueuedEntry[]): void {\n  sessionStoreFor(sessionId).setState((state) =>\n    protocolQueueMatches(state, queue) ? state : replaceQueuedEntries(state, queue),\n  );\n}\n/** Marks the start of a subscription replay, so live projections beat an older snapshot. */\nexport function beginSessionReplay(sessionId: string): void {\n  replayGuards.set(sessionId, { statuses: new Set(), widgets: new Set() });\n}\n\nexport function endSessionReplay(sessionId: string): void {\n  replayGuards.delete(sessionId);\n}\n\nexport function resetSessionStore(sessionId: string, options: { source?: 'hub' } = {}): void {\n  selectionRequests.delete(sessionId);\n  selectionVersions.delete(sessionId);\n  const guard = replayGuards.get(sessionId);\n  const preservePages = options.source === 'hub' && hasReadyHistoryReader(sessionId);\n  sessionStoreFor(sessionId).setState((state) => {\n    // Transcript pages do not contain facts returned by the session commands.\n    // Keep those facts even when their response arrives before a page reload.\n    const reset = {\n      ...initialSessionState,\n      agent: state.agent,\n      lifecycle: state.lifecycle,\n      pendingSteers: state.pendingSteers,\n      placedSteers: state.placedSteers,\n      stats: state.stats,\n      commands: state.commands,\n      models: state.models,\n      thinkingLevels: state.thinkingLevels,\n      context: state.context,\n      modes: state.modes,\n    };\n    const preservedStatuses = Object.fromEntries(\n      Object.entries(state.statuses).filter(([key]) => SELECTION_STATUS_KEYS.has(key) || guard?.statuses.has(key)),\n    );\n    const preservedWidgets = guard === undefined ? [] : state.widgets.filter((key) => guard.widgets.has(key));\n    // A bounded hub backlog is not a canonical page. Keep durable entries,\n    // their deduplication ids, and custom projections while replaying hub state.\n    if (preservePages) return { ...state, statuses: preservedStatuses, widgets: preservedWidgets };\n    if (!protocolTranscripts.has(sessionId)) {\n      return {\n        ...reset,\n        statuses: preservedStatuses,\n        widgets: preservedWidgets,\n      };\n    }\n    // A legacy socket reconnect replays its backlog. Keep the protocol snapshot\n    // visible while that replay rebuilds Po-only state around it.\n    const entries = state.entries.filter((entry) => PROTOCOL_ENTRY_KINDS.has(entry.kind));\n    return {\n      ...reset,\n      entries,\n      statuses: preservedStatuses,\n      widgets: preservedWidgets,\n      streaming: state.streaming,\n      settled: state.settled,\n      pendingUserEntries: state.pendingUserEntries,\n      reconciledUserEntries: state.reconciledUserEntries,\n      protocolUserEntryIds: state.protocolUserEntryIds,\n      transcriptTurnIds: state.transcriptTurnIds,\n    };\n  });\n  if (preservePages) return;\n  history.delete(sessionId);\n  historyStore.setState((state) => {\n    const { [sessionId]: _dropped, ...rest } = state;\n    return rest;\n  });\n}\n\nexport function dropSessionStore(sessionId: string): void {\n  selectionRequests.delete(sessionId);\n  selectionVersions.delete(sessionId);\n  stores.delete(sessionId);\n  protocolTranscripts.delete(sessionId);\n  replayGuards.delete(sessionId);\n}\n\nexport function resetSessionStores(): void {\n  selectionRequests.clear();\n  selectionVersions.clear();\n  stores.clear();\n  protocolTranscripts.clear();\n  replayGuards.clear();\n  streamedSessions.setState(() => new Set<string>());\n  detachedStore.setState(() => initialSessionState);\n}\n\n/**\n * Asks for the facts the cockpit shows but Pi only reports on request.\n *\n * A session with no live protocol is skipped: it asks for these itself when it\n * connects, and a caller refreshing every listed session (after a settings save,\n * say) must not fail on one that is not open.\n */\nexport function refreshSessionFacts(sessionId: string): void {\n  if (!hasSessionProtocol(sessionId)) return;\n  sendFrame(sessionId, getStateCommand());\n  sendFrame(sessionId, getSessionStatsCommand());\n  sendFrame(sessionId, getCommandsCommand());\n}\n\n/**\n * Asks only for the usage figures, cheap enough to run once per message.\n *\n * `refreshSessionFacts` costs three round trips because it also re-reads the\n * state and the command list, and neither of those changes mid-turn.\n */\nexport function refreshSessionStats(sessionId: string): void {\n  sendFrame(sessionId, getSessionStatsCommand());\n}\n\n/** Asks what the model picker lists; Pi's answer depends on the current model. The picker opens on sessions that are not connected. */\nexport function loadModelChoices(sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null || !hasSessionProtocol(sessionId)) return;\n  sendFrame(sessionId, getAvailableModelsCommand());\n  sendFrame(sessionId, getAvailableThinkingLevelsCommand());\n}\n\n/**\n * Switches the model, then re-reads the facts Pi adjusts alongside it: the\n * thinking level gets clamped to what the new model accepts, and the level\n * list changes with it.\n */\nexport function selectModel(provider: string, modelId: string, sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null) return;\n  sendFrame(sessionId, setModelCommand(provider, modelId));\n  sendFrame(sessionId, getStateCommand());\n  sendFrame(sessionId, getAvailableThinkingLevelsCommand());\n}\n\n/** Read back server state rather than optimistically enabling priority. */\nexport function selectFastMode(enabled: boolean, sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null) return;\n  const agent = sessionStoreFor(sessionId).state.agent;\n  if (agent?.provider !== 'openai-codex') return;\n  sendFrame(sessionId, { type: 'set_fast_mode', enabled });\n  sendFrame(sessionId, getStateCommand());\n}\n\n/** Locking aborts a running local turn; the snapshot reports the new state back. */\nexport function setAgentLock(locked: boolean, sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null) return;\n  sendFrame(sessionId, { type: 'set_agent_lock', locked });\n  sendFrame(sessionId, getStateCommand());\n}\n\n/** The set reply carries nothing back, so get_state is what updates the chip. */\nexport function selectThinkingLevel(level: string, sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null) return;\n  sendFrame(sessionId, setThinkingLevelCommand(level));\n  sendFrame(sessionId, getStateCommand());\n}\n\nfunction isRegisteredAction(state: SessionState, text: string): boolean {\n  const name = /^\\/(\\S+)(?:\\s|$)/u.exec(text)?.[1];\n  return (\n    name !== undefined &&\n    state.commands.some((command) => command.name === name && command.source !== 'skill' && command.source !== 'prompt')\n  );\n}\n\n/** Sends a prompt, or steers an active run. Only non-journaled actions get a local echo. */\nexport function submitMessage(\n  text: string,\n  images: RpcImage[] = [],\n  sessionId: string | null = activeSessionId(),\n): void {\n  const trimmed = text.trim();\n  if (!trimmed || sessionId === null) return;\n  const store = sessionStoreFor(sessionId);\n  // A built-in is an action, not something to say: steering the run with the\n  // text, or prompting with it, would reach the model as literal characters.\n  const builtin = builtinCommandFrame(trimmed);\n  if (builtin) {\n    store.setState((state) => appendUserPrompt(state, trimmed));\n    sendFrame(sessionId, builtin);\n    return;\n  }\n  const streaming = store.state.streaming;\n  // Ordinary messages appear only when durably published, with the admitted sender snapshot.\n  if (isRegisteredAction(store.state, trimmed)) store.setState((state) => appendUserPrompt(state, trimmed));\n  sendFrame(sessionId, streaming ? steerCommand(trimmed, images) : promptCommand(trimmed, images));\n}\n\n/** The composer retains its draft until the server acknowledges admission. */\nexport async function submitMessageWithAck(\n  text: string,\n  images: RpcImage[] = [],\n  sessionId: string | null = activeSessionId(),\n): Promise<boolean> {\n  const trimmed = text.trim();\n  if (!trimmed || sessionId === null) return false;\n  const store = sessionStoreFor(sessionId);\n  const builtin = builtinCommandFrame(trimmed);\n  const active = store.state.lifecycle === null ? store.state.streaming : store.state.lifecycle.operation !== null;\n  const echoAction = builtin !== undefined || isRegisteredAction(store.state, trimmed);\n  const localId = echoAction ? `u${store.state.nextId}` : undefined;\n  if (echoAction) store.setState((state) => appendUserPrompt(state, trimmed));\n  let accepted = false;\n  try {\n    const response = await sendFrameWithAck(\n      sessionId,\n      builtin ?? (active ? steerCommand(trimmed, images) : promptCommand(trimmed, images)),\n    );\n    accepted = response.success;\n    if (!accepted && response.error?.includes('uncertain'))\n      store.setState((state) => reduceSession(state, { type: 'error', message: response.error }));\n    return accepted;\n  } finally {\n    if (!accepted && localId !== undefined)\n      store.setState((state) =>\n        state.pendingUserEntries.some(({ id }) => id === localId)\n          ? {\n              ...state,\n              entries: state.entries.filter(({ id }) => id !== localId),\n              pendingUserEntries: state.pendingUserEntries.filter(({ id }) => id !== localId),\n            }\n          : state,\n      );\n  }\n}\n\nexport function rewindToMessage(itemId: string, sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null || itemId === '') return;\n  sendFrame(sessionId, rewindCommand(itemId));\n}\n\nexport function queueFollowUp(\n  text: string,\n  images: RpcImage[] = [],\n  sessionId: string | null = activeSessionId(),\n): void {\n  const trimmed = text.trim();\n  if (!trimmed || sessionId === null) return;\n  sendFrame(sessionId, enqueueAutomaticCommand(trimmed, images));\n}\n\n/** A queued submission is acknowledged by the server; consumption is a later lifecycle event. */\nexport async function queueFollowUpWithAck(\n  text: string,\n  images: RpcImage[] = [],\n  sessionId: string | null = activeSessionId(),\n): Promise<boolean> {\n  const trimmed = text.trim();\n  if (!trimmed || sessionId === null) return false;\n  const response = await sendFrameWithAck(sessionId, enqueueAutomaticCommand(trimmed, images));\n  if (!response.success && response.error?.includes('uncertain'))\n    sessionStoreFor(sessionId).setState((state) => reduceSession(state, { type: 'error', message: response.error }));\n  return response.success;\n}\n\nexport async function clearQueuedMessages(sessionId: string | null = activeSessionId()): Promise<void> {\n  if (sessionId === null) throw new Error('The session protocol is not connected.');\n  const response = await sendFrameWithAck(sessionId, clearQueueCommand());\n  if (!response.success) throw new Error(response.error ?? 'Could not clear queued messages.');\n}\n\n/** Requests server-owned removal; the authoritative snapshot removes the row on success. */\nexport async function deleteQueuedMessage(\n  id: string,\n  _knownQueueCount: number,\n  sessionId: string | null = activeSessionId(),\n): Promise<void> {\n  if (sessionId === null) throw new Error('The session protocol is not connected.');\n  const response = await sendFrameWithAck(sessionId, removeQueuedCommand(id));\n  if (!response.success) throw new Error(response.error ?? 'Could not delete the queued message.');\n  switch (response.data) {\n    case 'removed':\n      return;\n    case 'in_flight':\n      throw new Error('This message is already being delivered and cannot be deleted.');\n    case 'already_consumed':\n      throw new Error('This message has already been sent.');\n    case 'not_found':\n      throw new Error('This message is no longer queued. Refresh the session.');\n    default:\n      throw new Error('Deletion uncertain. Check the queue before trying again.');\n  }\n}\n\n/** The caller captures the active target at click time; absent means expected idle. */\nexport async function promoteQueuedMessage(\n  id: string,\n  operationId?: string,\n  sessionId: string | null = activeSessionId(),\n): Promise<void> {\n  if (sessionId === null) throw new Error('The session protocol is not connected.');\n  const response = await sendFrameWithAck(sessionId, promoteQueuedCommand(id, operationId));\n  if (!response.success) throw new Error(response.error ?? 'Could not send the queued message.');\n  switch (response.data) {\n    case 'promoted':\n      return;\n    case 'target_changed':\n      throw new Error('The active run changed. Check the session before sending this message.');\n    case 'in_flight':\n      throw new Error('This message is already being delivered.');\n    case 'not_found':\n      throw new Error('This message is no longer queued. Refresh the session.');\n    default:\n      throw new Error('Delivery uncertain. Check the conversation before trying again.');\n  }\n}\n\nexport async function resumeQueuedMessages(sessionId: string | null = activeSessionId()): Promise<void> {\n  if (sessionId === null) throw new Error('The session protocol is not connected.');\n  const response = await sendFrameWithAck(sessionId, resumeQueueCommand());\n  if (!response.success) throw new Error(response.error ?? 'Could not resume queued messages.');\n}\n\n/**\n * Renames the session where the name actually lives: in the agent. Pi keeps\n * it in the session file and reports it back through get_state, which is\n * what the hub folds into every page's rail card.\n */\nexport function renameSession(name: string, sessionId: string | null = activeSessionId()): void {\n  const trimmed = name.trim();\n  if (!trimmed || sessionId === null) return;\n  sendFrame(sessionId, setSessionNameCommand(trimmed));\n  sendFrame(sessionId, getStateCommand());\n}\n\nexport function abortRun(sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null) return;\n  sendFrame(sessionId, abortCommand(sessionStoreFor(sessionId).state.lifecycle?.operation?.id));\n}\n\nexport function runCommand(name: string, sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null) return;\n  const slashed = name.startsWith('/') ? name : `/${name}`;\n  sendFrame(sessionId, builtinCommandFrame(slashed) ?? promptCommand(slashed));\n}\n\nexport function answerDialogValue(id: string, value: string, sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n  sendFrame(sessionId, dialogValue(id, value));\n  sessionStoreFor(sessionId).setState(clearDialog);\n}\n\nexport function answerDialogConfirm(\n  id: string,\n  confirmed: boolean,\n  sessionId: string | null = activeSessionId(),\n): void {\n  if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n  sendFrame(sessionId, dialogConfirmed(id, confirmed));\n  sessionStoreFor(sessionId).setState(clearDialog);\n}\n\nexport function cancelDialog(id: string, sessionId: string | null = activeSessionId()): void {\n  if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n  sendFrame(sessionId, dialogCancelled(id));\n  sessionStoreFor(sessionId).setState(clearDialog);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwDA,MAAM,yBAAS,IAAI,IAAiC;AACpD,MAAM,oCAAoB,I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