Commit Graph
1094 Commits
Author SHA1 Message Date
wushenghua 53588c5aeb feat(hub,web): HTML preview — raw file endpoint + viewer toggle + inline chat preview 2026-08-03 00:21:44 +08:00
wushenghua ceeff60235 feat(web): split pinned running section into working/pending/idle groups with distinct badges 2026-08-02 22:48:23 +08:00
wushenghua b4a8e89fe3 fix(web): write VAPID key only after hub registration; make running-section toggle keyboard-accessible with correct filtered state 2026-08-02 22:37:00 +08:00
wushenghua 087cb08e53 feat(hub,web): support custom Claude models via settings.json (customClaudeModels) 2026-08-02 22:32:19 +08:00
wushenghua da59a0011a feat(web): show machine label on pinned running session rows 2026-08-02 22:27:04 +08:00
wushenghua 240bf8affe fix(web): address review findings — prune stale push endpoints, keep running section open while searching, clear auto-expand guard on section transitions; update tests 2026-08-02 21:55:46 +08:00
wushenghua fd457e0303 chore: hide voice button when no voice backend configured (not deployed) 2026-08-02 21:45:37 +08:00
wushenghua 5b0cda9c01 fix(web): don't auto-expand directory groups when opening pinned running sessions 2026-08-02 21:26:30 +08:00
wushenghua 9cbb242580 fix(web): re-subscribe push when VAPID key changes (stale hub subscriptions) 2026-08-02 21:26:30 +08:00
wushenghua ee13e85e27 feat(web): make the pinned 'in progress' section collapsible 2026-08-02 21:26:30 +08:00
wushenghua 597fd93b71 feat(web): show project name on pinned running session rows 2026-08-02 21:26:30 +08:00
wushenghua f61ee46fec feat(web): pin running sessions in an 'in progress' section with a live badge 2026-08-02 21:26:30 +08:00
AnanovoandGitHub fb6f697555 fix(web): display Windows file search paths correctly (#1311)
* fix(web): display Windows file search paths correctly

* fix(hub): scope path normalization to Windows
2026-08-02 20:04:46 +08:00
AnanovoandGitHub a6f302ebd1 fix(web): preserve mobile scroll intent after pointer cancellation (#1312)
Keep touch and pen input eligible to cancel initial bottom settling when native panning dispatches pointercancel before scroll. Add interaction coverage for the mobile event sequence and unrelated global cancellations.
2026-08-02 19:53:31 +08:00
AnanovoandGitHub f018c6027b fix(web): restore composer attachment uploads (#1313) 2026-08-02 19:49:03 +08:00
SSU-WEI HUANGandGitHub 5b91504263 Add read-only session status panel (#1301)
* feat(web): add session status panel

* fix(web): include nested session activity

* fix(web): preserve incomplete status details

* fix(web): handle anonymous terminal completion

* fix(web): classify pending status accurately

* fix(web): retain ambiguous terminal candidates
2026-08-02 17:33:54 +08:00
KorenKritaandGitHub b7da8d3ab2 fix(web): show Pi reasoning effort (#1303) 2026-08-02 17:33:29 +08:00
KorenKritaandGitHub 147102a877 fix(web): preserve rich composer caret (#1305) 2026-08-02 17:33:15 +08:00
weishu 05ba050eb8 feat(hub): add message content codec for storage optimization
Implement two-stage content codec: truncate oversized agent messages
(48KB head + 12KB tail + marker, idempotent, never user messages) and
compress message content JSON ≥256 bytes via zstd with fallback.

- contentCodec.ts: new codec with truncation and compression routines
- messages.ts: wire codec into addMessage (truncate+compress),
  copyMessageToSession (lossless), toStoredMessage (decode both formats)
- index.ts: schema version 15→16 with no-op migration (enforces
  schema match on downgrade, no DDL change)
- codexDesktop.ts: pass content through idempotent truncation for
  canonical comparison in transcript-import
- cleanup-sessions.ts: decode compressed rows, replace full-scan with
  per-session batched scan (LIMIT 50) stopping at first user message
- compact-db.ts: new offline compactor that retroactively applies
  truncate+compress+VACUUM to existing DBs; guards against schema
  version mismatch, symlink aliasing, and handles re-runs
- Tests: contentCodec round-trip + truncation + idempotence + legacy
  decode; messages integration (compressed/truncated round-trip);
  migration tests updated to version 16
- README.md: document codec and both maintenance scripts

Measured on 2.26GB production DB: 2159MB→768MB (-64%) in 12s,
748k messages intact, integrity verified.
2026-08-02 13:21:32 +08:00
AnanovoandGitHub 68299631f9 feat(web): customize composer toolbar visibility (#1298) 2026-08-02 13:14:00 +08:00
AnanovoandGitHub 74ec247b92 fix(web): make inactive session notices flush with headers (#1299) 2026-08-02 13:04:27 +08:00
weishu e425761c41 Release version 0.25.3 2026-08-02 11:04:12 +08:00
KorenKritaandGitHub 1ca7af44d2 fix(pi): keep archived sessions visible (#1297) 2026-08-02 10:00:15 +08:00
SSU-WEI HUANGandGitHub f213bc348c fix(web): require user intent to cancel initial scroll (#1291)
* fix(web): require user intent to cancel initial scroll

* fix(web): snapshot scroll intent before consumption
2026-08-02 09:27:37 +08:00
SSU-WEI HUANGandGitHub 545af9b4e0 fix(pi): expose native skills through $ completion (#1286) 2026-08-02 08:49:46 +08:00
SSU-WEI HUANGandGitHub 2556729ba8 fix(codex): use app-server native skills (#1289)
* fix(codex): use native skill catalog

* fix(codex): refresh changed skill inventory

* fix(codex): preserve skill fallback on discovery error

* fix(web): refresh skills when completion opens
2026-08-02 08:49:35 +08:00
SSU-WEI HUANGandGitHub 82da539d32 fix(claude): separate skills from slash commands (#1293)
* fix(claude): separate skills from slash commands

* fix(claude): make native skills ready before use

* fix(claude): keep skill commands before attachments

* fix(claude): align skill catalog with launch args

* fix(claude): include launch plugin skills

* fix(claude): use native loaded skill list

* refactor(claude): remove obsolete metadata callback

* fix(claude): wait for skill catalog before draining messages

* fix(claude): cancel deferred startup messages

* fix(claude): bound skill catalog startup probe
2026-08-02 08:49:14 +08:00
SSU-WEI HUANGandGitHub 4683b0cb47 fix(web): refresh skill inventories (#1295) 2026-08-02 08:48:56 +08:00
weishu 9b299eaab7 feat(web): migrate to @assistant-ui/react 0.14 (tap 0.9.8 with update-depth fix)
- @assistant-ui/react ^0.11.53 -> ^0.14.29, react-markdown ^0.11.9 -> ^0.14.7
- resolves @assistant-ui/tap 0.9.8, which ships the upstream fix for
  bulk message prepends (per-scheduler MAX_UPDATE_DEPTH guard, PR
  assistant-ui/assistant-ui#5370) that the local patch covered for 0.3.5
- API migration: useAssistantApi -> useAui, useAssistantState -> useAuiState
  with s.* selector access; TextMessagePart type-guard for content.find;
  portable DefaultComponentsMap annotation for memoizeMarkdownComponents

Verified: tsc clean, 1762 unit tests, history-load e2e 12/12 against the
unpatched upstream scheduler.
2026-08-02 00:12:29 +08:00
weishu 58ff91e5c4 fix(web): correct context window calculation for local-mode sessions
Remote sessions get an authoritative context_window injected into usage by
the CLI (from SDK result modelUsage), but local-mode sessions forward raw
transcript JSONL whose usage has no context_window, so the web fell back to
getContextBudgetTokens — which could not tell Fable's 1M window from its
bare id (only the "[1m]" suffix was recognized) and received session.model,
which is usually null for local sessions, defaulting to a 200k budget. A 1M
Fable session with ~256k of context showed 135% used with an over-limit
warning instead of ~26%.

- modelConfig: recognize Fable ids (fable, fable[1m], claude-fable-*) as 1M
- reducer: LatestUsage carries the usage-bearing message's own model
- StatusBar: new contextModel prop feeds the fallback heuristic only;
  the model prop's other semantics are unchanged
- HappyComposer forwards it; SessionChat passes
  latestUsage.model ?? session.model
2026-08-02 00:00:55 +08:00
weishu 3e61d276bd feat(cli): inherit local TUI permission mode on local→remote switch
Add permission mode tracking across the local→remote switch so mode changes
made inside the interactive Claude TUI (shift+tab) are inherited when
launching remote. Previously, a mode picked in local TUI was invisible to
remote sessions.

Implementation:
- generateHookSettings: add trackPermissionMode option to register UserPromptSubmit
  and PreToolUse hooks (their payloads carry permission_mode; SessionStart's does
  not). Export buildHookSettings for testing and make matcher optional.
- New hookPermissionMode.ts: normalizer for hook permission_mode → HAPI mode
  ('manual' → 'default'; unknown modes like 'dontAsk' → null/ignored).
- runClaude.ts: generate a second, local-TUI-only hook settings file with
  trackPermissionMode enabled (remote SDK process keeps the SessionStart-only
  file — these hooks block Claude per prompt/tool, and remote state is owned
  by hub/RPC). Hook callback inherits mode when session.mode === 'local': updates
  currentPermissionMode, syncs session, pushes keepalive, emits permission-mode-
  changed event.
- session.ts, loop.ts, claudeLocalLauncher.ts: plumb localHookSettingsPath
  (defaults to hookSettingsPath when not provided).
2026-08-01 23:40:46 +08:00
weishu 9727f7e4a0 fix(cli): seed mode gate from parked batch after pending delivery
When a batch is parked after a mode switch (pending delivery), the next
attempt that resumes from the parked batch must still seed modeHash/mode
into the relaunch gate. Without this, the gate keeps modeHash=null, so the
NEXT mode switch fails the hash check and gets silently fed into a process
spawned with the old --permission-mode (e.g. 'auto' silently running as
'default'). Fix adds hash to the pending type and seeds modeHash/mode when
delivering a parked batch.
2026-08-01 23:40:46 +08:00
bbe99f5c4c feat(codex): /personality slash + in-session app-server params (#1265)
* feat(codex): support /personality via in-session override

Intercept /personality in the Codex slash layer, keep the value in CLI
memory only, and forward it on thread/turn start when set. Unset means
omit the field so Codex config/thread defaults apply—no Hub DB or web UI.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(codex): refuse fake /personality clear (sticky thread setting)

turn/start.personality sticks for later turns; omitting the field does not
restore config.toml. Drop default|auto|clear success paths and require an
explicit friendly|pragmatic|none instead.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 23:26:32 +08:00
AnanovoandGitHub 0537ddf84a feat(web): make session header metadata configurable (#1267)
* feat(web): make session header metadata configurable

* fix(web): align mobile header metadata priority
2026-08-01 23:26:17 +08:00
Haoqing WangandGitHub 079556b43a fix(web): stop flashing the reconnecting banner on self-healing blips (#1230)
EventSource reports an error the moment a connection drops, including
while it is already retrying by itself - readyState is still CONNECTING
and the stream is typically back within a few seconds. useSSE forwards
that straight to onDisconnect, and App turned it into a full-width
"reconnecting" banner synchronously, so a blip the browser recovered from
on its own still read as a broken network.

Route the disconnect through a small hook that waits out a grace period
first. Genuine outages still surface the banner, just a moment later;
recoveries that beat the timer stay silent. The sibling syncing banner
already debounces this way in useSyncingState.

The grace period is anchored to the first drop, so repeated failed
retries cannot push the banner back indefinitely.
2026-08-01 23:25:40 +08:00
Haoqing WangandGitHub 8e261a1f7e perf(hub): gzip the SSE stream without delaying delivery (#1231)
* perf(hub): gzip the SSE stream without delaying delivery

SSE payloads are plain JSON that repeat the same field names on every
event, so they compress well - measured 72-77% on real captured traffic
from a hub with 15 active sessions.

Compression could not simply be turned on, though. Hono's compress()
middleware bails out whenever Transfer-Encoding is set, which streamSSE
always sets, so mounting it is a no-op. Wrapping the body in a
CompressionStream does compress, but it buffers until the stream ends -
measured on a 10-event stream, every event arrived at once when the
stream closed. On a connection that stays open for hours that means
events never arrive at all.

So drive zlib directly and issue a Z_SYNC_FLUSH after each chunk. That
costs about one percentage point of ratio and keeps delivery immediate:
verified in a real Chromium EventSource, first event at 13ms and each
subsequent event at its own 500ms tick, with no error events.

Clients that do not send Accept-Encoding: gzip keep the uncompressed
stream. No event payload or timing changes.

* fix(hub): cancel through the reader, gate reads on demand, honour q=0

Three defects in the first version of the SSE gzip wrapper:

Cancelling the source directly threw. The wrapper holds a reader for the
whole life of the connection, and cancelling a locked stream is invalid -
in Bun it throws TypeError: Invalid state: ReadableStream is locked
synchronously out of the cancel callback. Since SSE clients disconnect
mid-stream as a matter of course, this fired on essentially every
disconnect, and the upstream cancel never ran. Cancel through the reader
instead, which is allowed to.

Reads were not gated on downstream demand. Only zlib's own buffer was
consulted, and SSE compresses well enough that a slow client can be
megabytes behind while the compressed queue still looks nearly empty: a
test with a non-reading consumer pulled 1752 chunks before stalling.
Reading now waits for desiredSize to go positive, resumed from pull().

Accept-Encoding was matched with a substring test, so "gzip;q=0" - which
means the client refuses gzip - was read as acceptance. Parse the q-value.

Re-verified that none of this costs the property the change exists for:
in a real Chromium EventSource the first event still arrives at 13ms and
each one after it on its own 500ms tick, with no error events.
2026-08-01 23:24:51 +08:00
SSU-WEI HUANGandGitHub b5c83c6982 fix(cli): discover symlinked skill directories (#1283) 2026-08-01 23:18:10 +08:00
AnanovoandGitHub 6aae44498d fix(web): align browse button and select chevrons (#1279)
* fix(web): align new-session browse button

* fix(web): inset select chevrons
2026-08-01 22:55:21 +08:00
Junmo KimandGitHub 08fbea5311 feat(cli): bridge OpenCode native compaction via internal REST API (#1252)
* feat(cli): allocate a loopback port for the OpenCode ACP subprocess

opencode does not announce which port it bound when launched with
--port 0 (verified: not present in stdout/stderr even at DEBUG level),
so pick a free loopback port ourselves and pass it explicitly via
--port/--hostname. This makes the ACP subprocess's internal HTTP API
reachable at a known baseUrl for follow-up work (native /compact
bridging).

* feat(cli): add REST bridge for OpenCode native session compaction

opencode's ACP method table has no session/compact RPC, but the
opencode acp subprocess also runs an internal HTTP API. That API's
POST /api/session/:id/compact route is an unimplemented v2 stub
(always 503); the route that actually performs native AI compaction
is the legacy POST /session/:id/summarize, which requires providerID
and modelID in its payload. This adds a small client for that route
plus a helper to split ACP's combined "provider/model" wire id.

Not wired into the slash-command flow yet.

* feat(cli): trigger native OpenCode compaction from /compact

Wires the REST bridge into the OpenCode slash-command flow so /compact
performs real context compaction instead of returning a "not yet
supported" message.

- slashCommands.ts: /compact now resolves to its own `kind: 'compact'`
  (the synchronous 'handled' shape can't carry an async REST round
  trip). /clear is unchanged.
- opencodeRemoteLauncher.ts: registers a compact trigger callback once
  the ACP backend + internal HTTP baseUrl are ready, reading the
  session's current provider/model on every call so it reflects
  inline model switches. A `runExclusive` promise-chain mutex
  serializes the compact trigger against `backend.prompt()` so a
  still-in-flight prompt and a `/compact` sent moments later can't
  race against the same OpenCode session concurrently, in either
  arrival order.
- runOpencode.ts: on /compact, emits "Compaction started" as a session
  event (the same `sendSessionEvent({ type: 'message', ... })` status-
  line channel Claude/Codex already use for compaction and other
  transient state, rather than a chat message), awaits the bridge with
  no artificial timeout (compaction on a reasoning model can take
  90s+), then emits "Compaction completed" or "Compaction failed:
  <reason>" the same way. Falls back to the previous not-yet-supported
  chat message when no trigger is registered (local mode has no ACP
  backend, so this is unreachable there today). If the user cancels
  the message while compaction is queued or in flight, the eventual
  result is suppressed instead of surfacing a stray status message
  for an action the user already considered cancelled (aborting the
  in-flight HTTP call itself is left as follow-up scope).
- help text now notes /compact is remote-sessions only, since local
  mode has no ACP backend to bridge through.

Also fixes a runOpencode.test.ts fixture gap: the mocked
OpencodeSession was missing onThinkingChange, so any exception in that
call path was silently swallowed by the handler's outer catch instead
of failing the test.

* feat(cli): show compaction summary as a reasoning block

After a native OpenCode compaction succeeds, OpenCode's session
history gains a `role: "user"` marker message (a `{type:"compaction"}`
part with no text) followed by a normal assistant message holding the
actual generated summary in a `text` part. Left alone, neither is
visible in HAPI — the bridge only checked success/failure and never
looked at the resulting messages.

- opencodeCompactBridge.ts: `fetchCompactionSummary()` does one more
  GET against the session's message list after a successful compact,
  finds the most recent `type:"compaction"` marker, and extracts the
  following assistant message's text — preferring a match via the
  marker's `parentID` (order-safe) and falling back to simple array
  adjacency, both gated on `role === 'assistant'` so an unrelated
  same-shaped sibling can't be silently misattributed as the summary.
  Concatenates every `text` part in case a summary spans more than
  one. Never throws: any unexpected shape or request failure just
  yields "not found" so the caller can skip showing anything.
- opencodeRemoteLauncher.ts / runOpencode.ts: on a successful compact,
  forward the extracted summary as a `{ type: 'reasoning', text, id }`
  AgentMessage through the same `handleAgentMessage()` /
  `convertAgentMessage()` path OpenCode's own live thought-chunk
  streaming already uses, so it renders in the existing collapsible
  "Reasoning" block — no new UI component or schema field. The
  `role:"user"` marker is never constructed or forwarded at all, so
  there's nothing to filter (unlike Claude's compact summary, which
  is hidden after the fact via an `isCompactSummary` flag).

* fix(cli): disable Bun's hardcoded fetch timeout for OpenCode compaction

Isolated E2E against a real OpenCode session showed compaction always
failing with "Compaction failed: The operation timed out." after
~250s, even though session/prompt-style unlimited waits were intended.
Root cause: Bun's global fetch() hardcodes an internal ~5 minute
timeout that fires independently of any AbortSignal (or its absence) —
see oven-sh/bun#16682. The only documented workaround is passing the
non-standard `timeout: false` fetch option that Bun itself recognizes.

Cast through a local `BunFetchInit = RequestInit & { timeout?: false }`
type alias rather than `Record<string, unknown>`, so the option stays
structurally checked against the rest of the fetch call's shape.

* fix(cli): serialize /compact through the message queue instead of a mutex

HAPI Bot flagged two Major correctness issues on the PR:

- `/compact` bypassed `MessageQueue2` and entered a `runExclusive` mutex
  directly from the user-message handler. If prompt A was in flight and
  prompt B already queued behind it, `/compact` sent afterward could
  still reach the mutex before B did, running compaction ahead of an
  earlier-queued user prompt.
- `compactTriggerRef` (a closure capturing the remote backend) was
  never cleared on a remote→local handoff, so `/compact` typed after
  switching to local mode could call a stale closure targeting an
  already-disposed backend instead of the intended local-mode fallback.

Removes the mutex entirely and routes `/compact` through the same
`messageQueue` regular prompts use (a new `operation?: 'compact'` field
on `OpencodeMode`, dequeued by the launcher's single sequential
consumer loop, which branches to a new `runCompactOperation()` instead
of `backend.prompt()`). Ordering is now enforced by construction (one
queue item in flight at a time) rather than a second bolted-on lock.

Replaces the closure-based `onCompactTriggerReady` callback with a
boolean-flag `onCompactAvailabilityChange`, reset to `false` on every
entry into local mode (cold-start and handoff alike) before the remote
backend is even disposed, so there is no window where the flag says
available but the backend underneath it is gone.

* fix(cli): let /compact's cancel ack fire at dequeue time, not on queue

A follow-up HAPI Bot review caught a Major issue this PR's queue-based
/compact serialization (previous commit) left open: runOpencode.ts
still called session.emitMessagesConsumed manually and synchronously
the instant /compact was pushed onto the queue -- a leftover from
before /compact was routed through the queue at all. That beat
MessageQueue2's automatic dequeue-time ack (onBatchConsumed, wired in
sessionBase.ts, already used by every regular prompt) to the hub, so a
/compact sitting behind other queued prompts was marked "invoked"
immediately and could never actually be cancelled from the UI.

Removes the manual ack; the queue's own dequeue-time ack now covers
/compact exactly like any other queued operation. Adds a deterministic
test for the reported scenario: prompt A generating, /compact queued
behind it, cancelled before A finishes -- the compact REST bridge must
never be called.

* fix(cli): suppress live ACP updates while a compact REST call runs

Found via live use: OpenCode keeps streaming session/update
notifications (thought chunks, etc.) over the ACP transport while
/compact's REST call runs outside prompt(), and
AcpSdkBackend.handleSessionUpdate forwarded them unconditionally to
whatever messageHandler was still installed from the last real prompt
turn -- rendering the compaction summary a second time as a plain
assistant message, alongside the explicit Reasoning block this PR
already sends for the same content.

Adds a narrow, opt-in AcpSdkBackend.suppressUpdatesDuring() (shared
with Gemini, but a pure addition with no behavior change for existing
prompt() callers) that temporarily swaps out the message handler for
the duration of an async callback, restoring it afterward. Wraps the
compact bridge's REST call with it so the live stream produces no
output during that window -- the Reasoning block built from the
explicit GET response becomes the only place the summary appears.

* fix(cli): let Stop/switch-to-local interrupt an in-flight /compact REST call

triggerOpencodeCompact's HTTP request is intentionally unbounded (a
real compaction can take minutes), but the launcher awaited it with no
way to interrupt it once dequeued and running. handleAbort() only
cancels the ACP prompt() turn and resets the queue -- neither touches
this raw HTTP call -- so Stop (and switch-to-local, which routes
through the same handler) stayed blocked until the request settled on
its own: a stale "Compaction completed/failed" could still surface
afterward, queued prompts behind it were delayed, and remote->local
handoff couldn't proceed.

Add a per-call AbortController (compactAbortController) that
handleAbort() aborts before cancelling the prompt, and thread it
through triggerOpencodeCompact's new optional `signal` (kept separate
from the existing timeout:false Bun workaround, which stays
unconditional). An aborted call now folds into the same isCancelled()
check that already suppresses a stale result for the existing
queue-cancel race, so either kind of interruption behaves the same
way.

* fix(cli): structurally close remaining /compact abort/lifecycle races

Two more narrow races surfaced in review, both symptoms of ad hoc
per-site fixes rather than a shared mechanism:

1. The signal threaded through triggerOpencodeCompact (the POST) did
   not also reach fetchCompactionSummary (the GET runCompactOperation
   makes right after it), so Stop/switch-to-local could still block on
   that call alone. Introduce OpencodeCompactCallOpts with `signal`
   required (not optional) so every HTTP step opencodeCompactBridge.ts
   makes on behalf of one /compact operation is forced by the compiler
   to accept it, not left to remembering to wire it in per call site.

2. /compact availability (runOpencode.ts's compactSupported flag) was
   only reset to false on the *next* local-mode entry (loop.ts's
   runLocal callback), leaving a window between "switch/exit was
   requested" and "local mode actually started" where a /compact
   arriving mid-transition could still queue, and -- since local mode
   hands straight back to remote when it finds a non-empty queue --
   run anyway despite the user having already left remote mode. Add an
   onLeavingRemote() hook to RemoteLauncherBase (no-op default, so the
   other six flavors built on it are unaffected) called synchronously
   as the very first action of requestExit() -- closing the race at
   its source -- and again unconditionally in start()'s finally block
   as a backstop for exit paths that never call requestExit() at all
   (an exception thrown from runMainLoop, for instance).
   OpencodeRemoteLauncher overrides it to flip availability false;
   loop.ts's local-entry reset is removed as redundant now that
   leaving remote is what's authoritative.

* fix(cli): create compactAbortController before the inline model/effort switch

A hostile-review whole-feature sweep of the /compact abort/lifecycle
surface (round 5) found that the dequeue loop applied the per-batch
inline model/effort switch (real async ACP round-trips that yield to
the event loop) *before* branching into runCompactOperation(), which
is where compactAbortController used to get created. An abort firing
during that switch hit a still-null controller (a no-op), and by the
time the switch resolved and runCompactOperation() created a fresh
one, the abort was forgotten -- the compact's unbounded REST call
would then run to completion despite the user having already pressed
Stop/switch/exit.

Move controller creation to the top of the loop iteration, as soon as
the batch is known to be a compact operation, and pass it into
runCompactOperation() rather than having that function create its
own. Also: soften an overstated doc comment about what the required
`signal` field actually guarantees, and add a regression test locking
in that two sequential compact operations each get an independent
controller (no leak or cross-clearing).

* fix(cli): drain quietly before restoring the handler in suppressUpdatesDuring

A 5th PR-review round found that suppressUpdatesDuring restored the
suppressed messageHandler the instant its callback settled, but
aborting the client-side HTTP call (e.g. OpenCode's compact bridge
aborting via compactAbortController) does not necessarily stop the
agent from continuing that operation server-side -- session/update is
a separate notification channel from the HTTP request's lifecycle.
A late straggler notification from a still-running server-side
operation could leak straight into the restored handler (or into a
new one prompt() installs right after).

Reuse the same quiet-drain prompt() already runs before installing a
new handler for the next turn (waitForSessionUpdateQuiet with the
PRE_PROMPT_* constants) -- same class of race, same validated
mechanism, just on the way back in instead of the way out. No new
state or Stop-vs-switch branching: the wait is internal to
suppressUpdatesDuring and the handler stays suppressed throughout it.

* fix(cli): queue /compact during remote-mode initialization instead of rejecting it

compactSupported alone conflated two different situations: a
genuinely local-mode session (compact fundamentally can't run) versus
a session that's already in remote mode but hasn't finished ACP
initialize + session load/new yet (onCompactAvailabilityChange(true)
hasn't fired yet, but will shortly). A regular prompt sent in that
same startup window queues normally and just waits its turn; /compact
sent in the identical window instead got an immediate
not-yet-supported reply.

Check sessionWrapperRef.current?.mode (the actual OpencodeSession
instance's mode, synced synchronously by onModeChange before either
launcher starts) alongside compactSupported: only genuinely local mode
now gets the not-yet-supported reply. A session already in remote mode
but still initializing queues /compact exactly like a prompt and lets
it settle into its real FIFO position once the launcher is ready.

* fix(cli): don't let the remote-init /compact queuing fix reopen the teardown race

A hostile-review whole-feature sweep found that gating /compact
queuing on sessionWrapperRef.current?.mode alone (26344118) fixed the
startup window but silently reopened the exact race
OpencodeRemoteLauncher's onLeavingRemote() exists to close: mode stays
'remote' for the entire teardown window too (it only flips back to
'local' once runMainLoop() fully unwinds), so a /compact arriving
after switch/exit was requested -- while compactSupported has already
gone false -- queued anyway instead of getting rejected, and could
still run once local mode bounced back to remote to drain a non-empty
queue.

Add compactTeardownInProgress, true from the moment
onCompactAvailabilityChange(false) fires (which -- since the old
reset-on-local-entry was removed -- only ever means "leaving remote",
never "not ready yet") until the session next re-enters remote mode.
Wrap the onModeChange callback opencodeLoop already receives to reset
it back to false on that re-entry. The existing "stops queuing /compact
once availability is reset to false" test didn't catch this because
its mock never set mode to 'remote' during the simulated teardown,
unlike real production timing -- fixed to match.

* fix(cli): keep the dequeue loop blocked on a compact until it really finishes on plain Stop

A 6th PR-review round rejected the quiet-drain mitigation from the
previous round (bounded at ~1.2s) and asked for the originally
proposed fix instead: quiet-drain cannot guarantee a multi-minute
server-side compaction has actually finished, since session/update is
a separate notification channel from the aborted HTTP request's
lifecycle. Unconditionally aborting compactAbortController on any
abort (the previous fix) let the dequeue loop move on to the next
queued prompt while the agent could still be compacting the same
OpenCode session server-side -- breaking the core invariant this
feature's whole queue-based redesign depends on: compact and a prompt
must never touch the same session concurrently.

handleAbort() now takes a leavingRemote parameter. Plain Stop
(leavingRemote=false, the default) only sets compactResultSuppressed
-- the eventual result gets hidden, but compactAbortController is left
alone, so runCompactOperation()'s own awaits keep blocking the dequeue
loop until the real HTTP response arrives, i.e. until the server
actually finishes. Switch-to-local/exit (leavingRemote=true) still
abort the controller for real, since cleanup() disconnects the whole
ACP subprocess right after regardless -- there's no shared session left
to protect there, and the responsiveness fixed in an earlier round
still matters for that path.

The quiet-drain from the previous round (AcpSdkBackend.suppressUpdatesDuring)
is left in place -- it still helps for a compaction that finishes
quickly and for trailing session/update stragglers right after a real
completion, it's just no longer the thing plain Stop relies on for
correctness.

* fix(cli): close 3 gaps a hostile-review pass expected the next bot round to flag

Pre-emptively addresses findings a hostile-review final pass on
65729bb7 judged likely for the next external bot round, since a
communication round-trip costs more than fixing them now:

1. No dedicated test existed for the Stop/switch-to-local RPC-overlap
   message-ordering fix (handleAbort() re-reading compactAbortController's
   abort state instead of a stale snapshot). The test harness has no way
   to observe MessageBuffer/Ink content, so the decision logic that
   picks the status message and whether to clear `thinking` is extracted
   into a pure, exported selectAbortStatusMessage() function and unit
   tested directly against all four (hasCompactInFlight, leavingRemote,
   compactAborted) combinations, including the exact overlap case.

2. No test verified compactResultSuppressed doesn't leak between two
   sequential compact operations. Added a regression test: a Stop-suppressed
   compact #1 finishing for real must not silence a normally-completed
   compact #2 queued after it.

3. The "Stop requested — waiting..." status message didn't tell the user
   how to actually leave the session (switch-to-local/exit) while a
   compaction is deliberately left running. Appended that guidance.

* fix(cli): skip a compact cancelled before its request ever went out

A plain Stop landing during the inline model/effort switch that
precedes a compact batch only set compactResultSuppressed; it never
stopped the dequeue loop from calling runCompactOperation()
unconditionally once that switch resolved, so a cancelled-before-start
compact would still fire a brand new REST request and block the loop
for however long that call takes.

Skip starting the operation when compactResultSuppressed is set and
the controller was never actually aborted (plain Stop leaves the
signal alone by design). Deliberately excludes the
compactAbortController.signal.aborted case (switch/exit) and
isLocalIdCancelled: both must keep falling through to
runCompactOperation() as before, per Round 5's and the
isLocalIdCancelled suite's existing coverage.

* fix(cli): also skip a compact cancelled-before-start via isLocalIdCancelled

Round 7's pre-start skip check only covered compactResultSuppressed
(plain Stop), deliberately leaving isLocalIdCancelled out so as not
to disturb the "Compaction started is never suppressed" tests that
predated that check. But isLocalIdCancelled's backing Set can only
ever be populated during the brief ack-vs-hub-DB-write race before a
queued item's REST call is sent, never while it's actually running
(see runOpencode.ts's cancelledBeforeEnqueue doc comment) — so a true
result here unconditionally means the same "cancelled before it ever
went out" situation Round 7 already handles for plain Stop, and
deserves the same treatment: skip starting the operation instead of
sending "Compaction started" for a request already known to be
discarded.

Updates the two tests that had encoded the old "started is never
suppressed" behavior for this specific signal to their corrected
expectation, and removes a no-longer-consumed mockImplementationOnce
that would otherwise have leaked its failure response into the next
test that actually calls the REST bridge.

* fix(cli): don't resurrect /compact availability after a startup-time switch/exit

onCompactAvailabilityChange(true) fired unconditionally right after
newSession/loadSession resolved, with no way to know a terminal
switch-to-local/exit had already run during that pending ACP round
trip (RemoteLauncherBase.requestExit() sets shouldExit synchronously
before awaiting its handler, so the flag is already accurate at that
point). runOpencode.ts's compactSupported/compactTeardownInProgress
gate treats compactSupported flipping true as reason enough to ignore
compactTeardownInProgress entirely, so this belated true could let a
/compact arriving right after slip into the queue mid-teardown.

Guard the call with the same shouldExit flag requestExit() already
set. The race can only be reached via the terminal UI's onExit/
onSwitchToLocal callbacks (wired up before runMainLoop starts, well
before the RPC 'abort'/'switch' handlers exist), so the regression
test forces isTTY and captures ink's render() props to invoke them
directly.

* fix(cli): clear the hub's queued-thinking grace when a compact is skipped pre-start

The cancelledBeforeStart skip path never calls session.onThinkingChange(true)
(the whole point of skipping), but also never told the hub the queued
item was done. The hub's 15s queued-thinking grace (markMessageQueued,
sessionCache.ts) keeps thinking pinned true regardless of keepalives
until a messages-consumed ack with clearQueuedThinkingGrace arrives,
so the web UI spinner could sit stuck for the full grace window.

Applies the same pattern already used by runOpencode.ts's synchronous
slash.kind === 'handled' path (e.g. /model): an emitMessagesConsumed
ack with clearQueuedThinkingGrace, then an immediate thinking=false
keepalive. This is additive to, not a replacement for, the queue's own
unflagged onBatchConsumed ack — a second ack for an already-invoked
localId is a no-op on the hub's first-write-wins protocol, and
clearQueuedThinkingGrace is keyed by session, not localId, so both are
idempotent.
2026-08-01 17:20:07 +08:00
Junmo KimandGitHub 084d3462cf fix(web): keep line numbers clear when code wraps (#1260)
* fix(web): reserve code gutter padding

* fix(web): expose diff wrap controls

* test(ci): run terminal wrap regression
2026-08-01 17:11:40 +08:00
AnanovoandGitHub bbcef8c300 fix(web): preserve share export layout fidelity (#1277)
* fix(web): preserve share export layout fidelity

* fix(web): keep mobile and multi-image exports responsive

* fix(web): distinguish coarse pointers from touch desktops
2026-08-01 17:10:51 +08:00
AnanovoandGitHub 01bffa3c8c fix(web): stabilize chat scrolling and mobile alignment (#1278)
* fix(web): stabilize chat scrolling and mobile alignment

* fix(web): scope chat scroll containment
2026-08-01 17:10:38 +08:00
AnanovoandGitHub fd20e584d6 feat(web): refine composer status bar (#1281) 2026-08-01 17:09:49 +08:00
weishu 51d8c04e0a feat(web): collapse session machine filter into header menu on mobile
Replace the always-visible wrapping chip row below the md breakpoint with a
filter icon button in the session list header (right side, next to the new
session button). The button opens a radio menu with per-machine counts and
an inline health summary, shows an active-filter dot, clamps to the
remaining viewport/safe-area space, and supports Escape/Arrow-key
navigation with focus restore. Desktop keeps the one-tap chip bar.
2026-08-01 13:26:15 +08:00
weishu b1b0d590a7 feat(web): hide browse affordances unless a machine reports workspace roots 2026-08-01 11:36:12 +08:00
weishu b6897ee736 feat(web): replace session list refresh button with pull-to-refresh
Remove the refresh icon button from the session list toolbar and make
the list itself the refresh affordance via a touch pull gesture.

Gesture (SessionList):
- Touch listeners on the scrollable list container; pull engages only
  at scrollTop 0, with 16px feedback / 64px trigger thresholds, and
  fires on release past the trigger. Mirrors the established
  pull-to-load-older pattern in HappyThread.
- Touch-only by design: desktop has no overscroll bounce, so a wheel
  pull feels broken; desktop keeps relying on SSE live updates and
  query focus refetch.
- onRefresh widened to () => Promise<unknown> | void so the indicator
  tracks the in-flight refetch and ignores re-entrant pulls.

Feedback:
- Status pill over the list (role=status, aria-live) shows
  pull/release/refreshing states with a spinner while refreshing; it
  also covers the initial useSessions load (isLoading), which lost its
  only busy indication when the toolbar button was removed.
- The success toast is dropped (the pill is the feedback); the failure
  toast is kept. handleRefresh now returns its promise.

Empty states (review P2s):
- SessionsEmptyState and the no-results message move from the shrink-0
  header container into the scroll container, so the gesture works on
  the visible empty state (retry path after a failed initial fetch)
  and short viewports scroll instead of crushing the gesture area.
- SessionsEmptyState is gated on !isLoading so a slow initial request
  no longer flashes the final empty state with active actions.

i18n: add sessions.refresh.pull/release/refreshing (en + zh-CN),
remove now-unused button.refresh and sessions.refresh.success.*.
Desktop wheel pull was implemented and then reverted after review.
2026-08-01 10:37:09 +08:00
AnanovoandGitHub 39da5c4b8e fix(web): align compact dialog titles (#1253) 2026-07-31 18:17:57 +01:00
AnanovoandGitHub f985d56ba5 fix(web): open Windows absolute file paths in session viewer (#1113) 2026-07-31 18:17:45 +01:00
Junmo KimandGitHub 770439730a fix(web): keep abort next to Send by default (#988)
* refactor(web): pin abort button to end of composer left cluster

Abort's position shifted with conditional siblings (terminal/switch/
schedule), making the destructive action's location unpredictable.
Move it to the last child of the left button group so it's always
immediately left of Send — pure JSX reorder, no markup/props/handler
changes.

* fix(web): keep abort last in default toolbar

Keep the product default predictable without changing saved custom order or the registry used to append missing items.
2026-07-31 18:17:34 +01:00
SSU-WEI HUANGandGitHub 7ad454f9a2 fix(web): prioritize session names in narrow sidebar (#1029) 2026-07-31 18:17:23 +01:00