25 Commits

Author SHA1 Message Date
alan 2307d45417 Release native chat runtimes on lifecycle changes
Ensure /new and chat close stop native foreground and background work before changing registry state. Preserve transcripts while surfacing release and recovery cleanup failures instead of reporting false success, with focused adapter and server regressions.
2026-11-11 17:11:40 +00:00
alan 9246c168ac Add opt-in live thinking-level checks and notes 2026-11-09 20:22:33 +00:00
alan 06001697c8 Add per-chat thinking levels for Codex, Claude Code and OpenCode
Codex: model/list supportedReasoningEfforts per model, turn/start effort,
thread reasoningEffort as the current level. Claude Code: initialize
supportedEffortLevels, apply_flag_settings effortLevel at the next turn
start. OpenCode v2: model variants via the session model endpoint.
chat_effort sets a level; rows and chat_models carry the levels; Codex and
Claude levels persist in operator_sessions.chat_effort and are re-applied
before every turn.
2026-11-09 20:07:41 +00:00
alan 9791f09230 Serve the Pipelines chat tools over a loopback MCP endpoint and register it with Claude Code, Codex and OpenCode chats 2026-11-09 16:34:21 +00:00
alan b15597662f Preserve independent background sessions through owner shutdown and idle cleanup 2026-11-07 16:23:20 +00:00
alan 6421554bfe Expose recorded background task timing and progress metadata 2026-11-06 15:08:34 +00:00
alan 20a69b7e47 Forward recorded Codex turn timestamps to chat history 2026-11-06 00:00:21 +00:00
alan 1e886faa41 Complete the Codex host initialization handshake once 2026-11-05 15:49:44 +00:00
alan c2a8f5ff16 Retain Codex interaction callbacks across server restarts 2026-11-05 14:32:59 +00:00
alan a627b38ef3 Merge main; use the shared chatShutdownDetacher for OpenCode and Codex
OpenCode and Codex chats implement Detach (called by chatManager.Close)
instead of a parallel DetachSessions interface. Docs follow the Claude Code
host and the systemd KillMode=process unit. The opt-in live restart check
copies only the stage provider's login row into its scratch OpenCode
database, builds the CLI for skill install and removes its scratch tree.
2026-11-04 16:24:17 +00:00
alan aa8eddd686 Keep OpenCode/Codex chat and stage sessions running across server restarts
A stopping server no longer interrupts harness sessions. Runs are canceled
with a shutdown cause, so stage clients leave admitted sessions running and
owned; start-up recovery re-adopts live OpenCode V2 stage sessions (wait,
read back the result, continue the graph), restarts unadmitted visits,
continues runs between stages, and falls back to interrupted with a reason
when the harness is gone. Chats with live work are recorded on shutdown and
reattached on start; turns that ended during the downtime are folded in
from history. The server-spawned V2 chat serve is now a detached owned
service. PIPELINES_SHUTDOWN_SESSIONS=stop restores the old behaviour.
2026-11-04 16:17:08 +00:00
alan 10049b8062 Chat info: account quota per harness (Claude rate_limit_event, Codex account/rateLimits, OpenCode unsupported)
Usage frames carry optional usage.account {harness, source, plan, as_of,
windows[{id,label,used_percent,resets_at}], unsupported}. Claude Code quota
comes from its rate_limit_event stream lines and the initialize account
(plan), shared across chats on the same account. Codex reads
account/rateLimits/read once per connection (re-read when a chat opens after
5 min) and merges account/rateLimits/updated. OpenCode exposes no quota API
and says so. The app's chat info sheet shows an Account usage section with a
progress bar and reset countdown per window, Material and Cupertino.
2026-11-02 18:57:13 +00:00
alan 80022ea41a Keep observing chats with an in-flight turn after the last client leaves
Chat attention notifications (questions, approvals, finished replies) come
from a session's event stream, which the hub only read while a room existed;
detach destroyed the room when the last client left, so a turn that finished
or asked with the app closed notified nobody.

A room whose last client leaves now stays observing, unattended, while its
turn is in flight or it holds an unanswered question/approval, and is torn
down when the turn ends (or after 6h for a stuck turn); at most 16 such rooms.
At server start, recently used open sessions whose harness reports a running
turn (OpenCode /api/session/active, Codex thread/turns/list) are observed
again so their reply still notifies. Settings, dedupe and app_notifications
recording are unchanged.
2026-11-02 16:07:42 +00:00
alan e42f9cc031 Send mid-turn chat prompts to the harness and queue the rest durably on the server
Claude Code (stream-json stdin) and Codex (turn/steer pinned to the active
turn) receive a prompt sent while a turn runs immediately. Other harnesses
(OpenCode) get a durable chat_prompt_queue row owned by the session: it
survives the last client detaching and a server restart, is delivered in
order when the turn ends with or without a client, and is deduplicated by
operation id. chat_subscribe carries the queue, chat_queue frames report
delivered/removed/failed changes, and chat_unqueue removes a waiting prompt.
2026-11-01 18:30:20 +00:00
alan 6d430948a6 feat(chat): per-chat permission modes for Claude, Codex and OpenCode 2026-10-24 18:16:10 +01:00
alan 83b60990d2 feat(codex): retain native session usage snapshots for chat
Verify typed ThreadTokenUsage/TokenUsageBreakdown/Thread/Turn against openai/codex@6fb1c3903d. Use native totalTokens and latest-call context tokens without re-adding cached/reasoning subsets. Replay bounded per-connection snapshots and clear on room/source release.

Cost stays unavailable: no subscription USD usage is reported by this notification. Throughput stays unavailable even with native Turn.durationMs because neither last-call nor cumulative-session output is a compatible turn-specific numerator. Thread readback exposes no token usage; no extra reads, resume, or live provider calls added.

Checks: go test -race ./internal/codex; go vet ./internal/codex; go test ./internal/server ./internal/protocol; git diff --check.
2026-10-21 00:07:12 +01:00
alan 4969d667b3 Expose native chat compaction activity and retained replay 2026-10-20 22:17:41 +01:00
alan 03a508fa2b fix(codex): load persisted threads only on explicit send after refusal 2026-10-20 18:46:17 +01:00
alan d564765ca5 fix(codex): reconcile cold connections without resuming queued goals 2026-10-20 18:33:20 +01:00
alan 68761652cf fix(codex): accept prepared chat attachments with model overrides 2026-10-20 18:07:00 +01:00
alan 83fef10331 feat(codex): retain all tool items and expose bounded command output 2026-10-20 18:07:00 +01:00
alan e374e8ef03 fix(codex): return no content for URL elicitation confirmation 2026-10-20 17:43:14 +01:00
alan 35329e4022 feat(chat): broker Codex approvals and complete typed tool interactions 2026-10-20 17:41:35 +01:00
alan ed0abb976d feat(chat): persist safe Codex next-turn model selection 2026-10-20 16:35:31 +01:00
alan f7a3a49f94 chat: add the Codex backend
Store a chat's harness with its operator session, expose chat_backends and a
backend choice in New chat, and route each session through a manager. The Codex
adapter uses the App Server's Unix WebSocket for threads, turns, history,
questions and interrupt; OpenCode remains the default and Claude is not
advertised until its sidecar and login are wired.
2026-10-20 12:10:39 +01:00