open-design/packages/contracts/src/sse/chat.ts
nettee 3fb849d047
Fix chat runs surviving web disconnects (#146)
* fix chat runs surviving web disconnects

* fix chat run create abort propagation

Generated-By: looper 0.0.0-dev (runner=fixer, agent=openai/gpt-5.5)

* fix daemon keepalive reconnect budget

Generated-By: looper 0.0.0-dev (runner=fixer, agent=gpt-5.5)

* fix daemon stream disconnect cancellation

Generated-By: looper 0.0.0-dev (runner=fixer, agent=openai/gpt-5.5)

* fix daemon stream abort cancellation race

Generated-By: looper 0.0.0-dev (runner=fixer, agent=openai/gpt-5.5)

* fix daemon run cancellation semantics

* fix load

* doc

* 2

* add run refresh recovery

* fix active run refresh status

* fix reattach abort handling

* fix

* fix chat initial scroll

* fix daemon start failures

Generated-By: looper 0.2.7 (runner=fixer, agent=openai/gpt-5.5)

* fix background run recovery

Generated-By: looper 0.2.7 (runner=fixer, agent=openai/gpt-5.5)

* fix stop run status

Generated-By: looper 0.2.7 (runner=fixer, agent=openai/gpt-5.5)

* fix background run recovery

Generated-By: looper 0.2.7 (runner=fixer, agent=openai/gpt-5.5)

* extract daemon run service

* move prompt composition to daemon

* fix prompt module resolution

* fix project id generation

* add project run status

* add designs kanban view with awaiting_input status

- add grid/kanban view toggle on Designs tab; persist choice in localStorage
- introduce awaiting_input project display status (daemon-derived from
  unanswered <question-form>) so projects asking the user aren't shown
  as Completed; ordered between Running and Completed with amber accent
- hide transient queued state from users: coerce queued/starting to
  running in daemon /api/projects projection and drop the queued kanban
  column
- a11y polish on Designs cards: Space activation, aria-labels on delete,
  focus-visible outlines, reveal delete on focus-within and touch,
  prefers-reduced-motion handling
- kanban layout uses flex sizing instead of viewport math; scoped icon-
  only pill button rule fixes view-toggle icon alignment

---------

Co-authored-by: mrcfps <mrc@powerformer.com>
2026-04-30 20:16:46 +08:00

44 lines
1.5 KiB
TypeScript

import type { SseErrorPayload } from '../errors';
import type { SseTransportEvent } from './common';
export const CHAT_SSE_PROTOCOL_VERSION = 1;
export interface ChatSseStartPayload {
runId?: string;
agentId?: string;
bin: string;
protocolVersion?: typeof CHAT_SSE_PROTOCOL_VERSION;
/** Legacy daemon-internal absolute cwd. Kept for compatibility during W2 adoption. */
cwd?: string | null;
projectId?: string | null;
model?: string | null;
reasoning?: string | null;
}
export interface ChatSseChunkPayload {
chunk: string;
}
export interface ChatSseEndPayload {
code: number | null;
signal?: string | null;
status?: 'succeeded' | 'failed' | 'canceled';
}
export type DaemonAgentPayload =
| { type: 'status'; label: string; model?: string; ttftMs?: number; detail?: string }
| { type: 'text_delta'; delta: string }
| { type: 'thinking_delta'; delta: string }
| { type: 'thinking_start' }
| { type: 'tool_use'; id: string; name: string; input: unknown }
| { type: 'tool_result'; toolUseId: string; content: string; isError?: boolean }
| { type: 'usage'; usage?: { input_tokens?: number; output_tokens?: number }; costUsd?: number; durationMs?: number }
| { type: 'raw'; line: string };
export type ChatSseEvent =
| SseTransportEvent<'start', ChatSseStartPayload>
| SseTransportEvent<'agent', DaemonAgentPayload>
| SseTransportEvent<'stdout', ChatSseChunkPayload>
| SseTransportEvent<'stderr', ChatSseChunkPayload>
| SseTransportEvent<'error', SseErrorPayload>
| SseTransportEvent<'end', ChatSseEndPayload>;