Commit Graph
1874 Commits
Author SHA1 Message Date
Junmo KimandGitHub 90fbb417ca fix(agy): concatenate ACP text chunks as deltas (#2332)
agy streams agent_message_chunk as pure deltas, but the backend used the
default overlap-dedupe mode, which dropped a repeated character at a chunk
boundary (73-8 + 800 was shown as 73-800). Set textChunkMode to delta,
as the OpenCode and Grok backends do.
2026-11-13 18:46:55 +08:00
Junmo KimandGitHub 3aac283bff fix(web): generate read-state operation ids without crypto.randomUUID (#2333)
crypto.randomUUID is undefined outside secure contexts (plain HTTP on a LAN IP), so enqueueing a read threw and no read-state PUT was sent. Use the randomId() helper, which falls back to getRandomValues.
2026-11-13 18:46:37 +08:00
weishu a7fe2cdaf2 fix(android): compact sort & filter sheet and a clean date-range dialog
Sort & filter scrolled: four machine radio rows (a rare choice) led the
sheet, every status and sort option was its own 56dp radio row, and Done
sat in a footer. The activity-date dialog was a full-width custom Dialog
that clipped the picker title, and its range band was Material's baseline
purple next to green endpoints.

- The sheet is now single rows under Filter / Sort: Machines, Show and
  Sort by show their value and open an anchored menu (checkmark for the
  selection, machine session counts trailing); Activity dates opens the
  picker; Unread only and Active first stay switches. Reset and Done move
  into the header, so the whole sheet fits without scrolling (as on iOS,
  where machines moved into a submenu).
- The date range picker sits in Material's DatePickerDialog (standard
  width and margins), drops the title row, aligns the range headline with
  the 24dp content edge instead of M3's 64dp full-screen indent, keeps the
  recent-activity legend under the calendar, and omits the current year
  from legend days.
- The static light/dark schemes now define every accent role (primary,
  secondary, tertiary containers and their on-colors) from the green
  seed; unset roles were falling back to Material's purple.
- A window-level specimen covers the sheet, the machine menu and the
  picker; instrumentation tests open the Machines / Show menus first.
2026-11-13 18:00:58 +08:00
weishu 35e4578245 feat(android): drop the inactive bar and status strip above the composer
Both cost transcript lines on every screen: the "Session inactive — send
to resume, or Reopen" card and the "ctx 190k · 0% left / Auto" strip.

- Inactive sessions still resume by sending (unchanged), and Reopen stays
  in the chat overflow menu.
- Context remaining moves into the session config sheet (gear) under a
  new "Context" section, keeping its warning color bands.
- The permission-mode label above the composer goes away; the mode is
  shown and switched in the same sheet.
2026-11-13 17:49:03 +08:00
weishu 662b4739d1 feat(android): web-style copy / details / time row under agent responses
The usage-info button sat under whichever block carried metadata — often
a reasoning or tool card at the start of a response, sometimes several
per response — inside a padded TextButton that pushed it off the prose's
leading edge.

Close each agent response with one action row instead, like the web
MessageActions on an assistant-ui card: under the last block of each run
of assistant-role blocks (bounded by user text, agent events and
user-source CLI output), show copy (the run's prose joined by blank
lines; reasoning and tools excluded, Codex reviews via a port of
formatCodexReviewText), details (the run's first block with usage
labels) and the latest activity time (same day HH:mm, same year
MMM d HH:mm, otherwise with year; locale-ordered, 24-hour). Glyph
artwork aligns with the text edge; copy reuses FullTextAction's
clipboard-or-export logic with a transient checkmark.
2026-11-13 17:40:33 +08:00
weishu ac13d622b9 fix(android): soften the composer shadow
Material elevation is lit from above the screen, so at the bottom edge it
fell heavily under the hairline-bordered card and read as a smudge, and
the composer strip (a clipping Surface) cut the blur into a hard top edge.

Draw an even iOS-style shadow instead (black 8%, 8dp blur, 2dp down; 6%
and 6dp for suggestion popups) via a paint shadow layer, and make the
strip an unclipped Box so the blur fades out naturally. Dark mode keeps
relying on the lighter fill. The helper is a CacheDrawScope function, not
a Modifier factory: Compose lint's ModifierDeclarationDetector crashes on
app-module factories with this AGP.
2026-11-13 17:30:14 +08:00
weishu 893027c9e2 fix(android): keep the code copy action's 48dp touch target
The chat polish shrank the code-block copy IconButton to iOS's 44pt,
breaking Android's 48dp minimum (CodeBlockLayoutTest on API 29/36).
Restore the 48dp slot; the quieter 16dp symbol stays, so the test now
pins 16dp artwork.
2026-11-13 17:06:43 +08:00
weishu 5f1516489b build(android): derive versionCode from the git commit count
- versionCode is now `git rev-list --count HEAD`; the hapiVersionCode
  property is gone. Builds without git fall back to 1.
- Official builds fail fast when git is unavailable or the clone is
  shallow, since a shallow history undercounts.
- The official build workflow drops the version_code input, checks out
  full history and names the artifact hapi-android-<versionCode>.
- Android and CLI READMEs describe the new rule.
2026-11-13 17:03:06 +08:00
Junmo KimandGitHub c9686af735 test(hub): align archive cleanup timeout status with the 503 semantics (#2426)
ArchiveCleanupError no longer maps a cleanup timeout to 504 (tiann/hapi#2423), but the archive singleflight test added in tiann/hapi#2424 still expected 504, so syncEngineArchiveSession.test.ts fails on main. Expect 503, matching the new status mapping.
2026-11-13 16:51:44 +08:00
weishu 09f05a9e84 feat(android): refine the chat composer
- Collapse the empty, unfocused composer to one row (+ / field / primary
  action); anything in flight expands it, keeping one field instance so
  focus survives.
- Bare 22dp tool symbols with tint-only states; send/stop is the only
  filled 34dp circle, and stop uses the accent instead of error red.
- Composer card lifts off the canvas (composerSurface, hairline, light
  shadow); context usage and permission mode share one compact row.
- Scheduled sends show a "Scheduled · …" capsule with a clear action;
  tapping the clock no longer silently clears a pick.
- Queued messages become one inset card with one-line rows and icon
  actions; slash/mention popups get 48dp rows, icons and mono commands;
  attachment chips use vector symbols.
- Ctrl/Meta+Enter sends, gated exactly like the Send button.
2026-11-13 16:43:14 +08:00
weishu b2f50a0f83 feat(android): redesign tool cards, approvals and the tool inspector
- Tool summaries use monochrome symbols, a 15sp medium middle-truncated
  title and a one-line secondary subtitle; success is quiet, running is a
  neutral spinner, errors are a tinted chip.
- Groups lead with activity and total calls and count calls by kind
  ("2 reads · 1 search"), with running and error counts side by side.
- Pending approvals become a neutral card: hourglass status line with the
  full-input link, filled Allow / outlined Deny via ChatActionButton, and
  the submit spinner in the status slot; the duplicate "pending" chip is
  hidden. Settled verdicts are symbol + label (glyphs dropped from strings).
- Codex plan actions share ChatActionButton.
- The inspector header shows symbol, friendly title, raw name, labelled
  status and a selectable workspace path; empty results read "Waiting for
  output…" / "No output"; Source has a disclosure chevron; group browser
  rows form one card with inset hairlines and a category summary.
- Terminal output is selectable.
2026-11-13 16:43:14 +08:00
weishu ab96d78861 feat(android): iOS-parity Markdown rhythm and reasoning disclosure
- Headings follow iOS sizes (24/20/18/17sp semibold) instead of collapsing
  into body size; blocks are 12dp apart, 24dp before a heading and 8dp
  after one; list items 8dp with first-baseline-aligned markers.
- Inline code is 14sp JetBrains Mono on a glyph-hugging rounded chip drawn
  behind the text, instead of a span background filling the 24sp line box.
- Code block headers show the lowercase language in secondary mono caption
  with a quiet 16dp copy symbol.
- Reasoning uses a rotating chevron + "Reasoning…" label (no emoji or
  text arrows), a 32dp row with expanded/collapsed state semantics, and a
  subdued body behind a hairline rule.
2026-11-13 16:43:14 +08:00
weishu 0a8bb2ffc7 feat(android): neutral chat surfaces, symbol icons and reading tokens
Lay the shared foundation for iOS-level chat polish:

- Typography tokens mirror iOS HapiTypography: zero tracking on body
  slots, trimmed leading, strict CJK line breaking, row title/subtitle and
  heading tokens; code uses bundled JetBrains Mono NL (OFL, no ligatures).
- Static schemes get hue-free surface ladders (Material's baseline tinted
  every surface lavender) and the dark scheme sets onPrimary instead of
  inheriting Material purple. NeutralChatSurfaces keeps conversation
  surfaces gray under Material You; presets and OLED pass through.
- Extended colors add textSecondary, cardSurface and composerSurface.
- Material Symbols Rounded vector drawables (ic_sym_*) replace emoji and
  text glyphs in later commits; ChatActionButton is the one inline action
  style (48dp minimum, 10dp corners, one filled primary).
- Transcript rows use iOS TranscriptRowRole gaps instead of a flat 10dp.
- Roborazzi + Robolectric visual specimens (record on demand; Roborazzi
  pinned to 1.60.0 because 1.61+ ships Kotlin 2.3 metadata).
2026-11-13 16:42:32 +08:00
AnanovoandGitHub 6ea40f9e44 fix(web): align pending session indicators (#2425)
* fix(web): align pending session indicators

* fix(web): preserve background tooltip placement
2026-11-13 12:09:04 +08:00
adminandGitHub bebda45006 fix(dsh): respawn dead ACP children, recover closed sessions, sandbox modes, inline images, reasoning effort (#2386) 2026-11-13 08:40:55 +08:00
AnanovoandGitHub 7c66ca2226 feat(web): open Markdown images in fullscreen preview (#2395) 2026-11-13 08:40:33 +08:00
HeavyGeeandGitHub 04032d704e fix(cli): isolate claude.test.ts resume-identity tests from HAPI_INVOKED_CWD (#2396) 2026-11-13 08:40:19 +08:00
Junmo KimandGitHub f422cf4ec7 fix(web): count the waiting time on synthesized pending questions (#2397) 2026-11-13 08:40:04 +08:00
JeeandGitHub ebd4ac2105 fix(agy): handle stale errors and missing session titles (#2401) 2026-11-13 08:39:32 +08:00
AnanovoandGitHub 083aaca779 fix(web): distinguish and navigate pending requests (#2402) 2026-11-13 08:39:15 +08:00
JeeandGitHub d391324e81 fix(cli): handle ACP stdin stream errors (#2403) 2026-11-13 08:38:54 +08:00
AkiiiaandGitHub 72b341fde1 perf(cli): load command modules on demand (#2404) 2026-11-13 08:38:41 +08:00
Junmo KimandGitHub e24ccf5e50 feat(agy): show the round turn count and running background commands (#2405) 2026-11-13 08:38:25 +08:00
SSU-WEI HUANGandGitHub f1339d3ee5 docs(cli): note that worktree spawn-peer needs a git repository (#2410) 2026-11-13 08:38:08 +08:00
HeavyGeeandGitHub cca38a4acc fix(cli,hub): clear stale permission required when request is inactive (#2415) 2026-11-13 08:37:27 +08:00
JeeandGitHub b3219357eb fix(pi): register peer tools directly when registerMcpServer is absent (#2418) 2026-11-13 08:37:02 +08:00
peter-yyandGitHub 8e077991c1 fix(web): keep running sessions from looking finished when output is unread (#2420) 2026-11-13 08:36:35 +08:00
SSU-WEI HUANGandGitHub 020b313aff fix(hub): avoid 502/504 so Cloudflare Tunnel keeps JSON error bodies (#2423) 2026-11-13 08:36:02 +08:00
Junmo KimandGitHub cad21ec6d0 feat(opencode): fork and rewind OpenCode v2 conversations (#2424) 2026-11-13 08:35:45 +08:00
weishu 06d9e51f5c Release version 0.35.0 2026-11-12 10:16:52 +08:00
KiyoshiandGitHub 31cb262ee0 feat(usage): display CLI account quotas and rate limits in Settings -> Usage (#2389)
* feat(usage): display CLI account quotas and rate limits across Codex, Antigravity, and Claude

* fix(usage): persist live quota state across processes and normalize agy usage

* fix(cli): isolate Claude quota observations by account and bound probe deadlines

* fix(usage): bind Claude quota events to producing session account and surface quota fetch errors

* fix(usage): preserve OAuth token isolation without email and surface Codex read failures

* fix(usage): skip host claude path lookup when test probe override is active
2026-11-12 10:16:07 +08:00
KiyoshiandGitHub 0bea8967b4 fix(agy): wake session and stream reactive background turns over agy acp (#2387) 2026-11-12 08:47:36 +08:00
adminandGitHub 446cf2351c feat(cli): diagnose Bun pre-init fatal crashes in webhook failure messages (#2365) 2026-11-12 08:46:26 +08:00
AnanovoandGitHub 2e8b2a108b fix(codex): preserve completed-fork availability across stale refreshes (#2370) 2026-11-12 08:45:54 +08:00
Junmo KimandGitHub 20878e317a fix(claude): mark only the compaction turn result, not pending-compaction rounds (#2374) 2026-11-12 08:45:40 +08:00
HeavyGeeandGitHub 3a3e83b4b0 fix(voice): keep runtime backend/voice aligned with Settings preview (#2378) 2026-11-12 08:45:05 +08:00
AnanovoandGitHub 44fde2072b feat(web): combine session activity and unread indicators (#2380) 2026-11-12 08:44:38 +08:00
Junmo KimandGitHub 9a651dbd81 fix(web): give every tool card header the same shape (#2394) 2026-11-12 08:43:18 +08:00
Junmo KimandGitHub 4f2054b31f fix(web): make pending question cards read as waiting for a reply (#2390)
* refactor(web): share the AskUserQuestion option row and pill button styles

Move the interactive option row and the footer pill button class into
askUserQuestionOptionCard so another footer can reuse the exact presentation.
Pure move, no behavior change.

* fix(web): show Waiting for your reply on pending question cards

A pending question keeps the 'running' tool state until its reply lands in
the transcript, so the card header counted an ever-growing Duration and the
detail dialog showed a 'Running…' result pill. Neither is true: the agent is
not working on the question, it is waiting for an answer.

For question tools with a pending permission (AskUserQuestion and
request_user_input, covering Claude, OpenCode, agy, Cursor and Codex), the
card header now reads 'Waiting for your reply' instead of the timing rows,
and the result pill follows suit. The tool state and fixtures are unchanged.

* fix(web): title Codex question cards with the question text

request_user_input questions carry no header field, so the card title was
always the generic 'Question' while the actual question hid in the subtitle.
When no header is present, use the question text as the title and drop the
now-redundant subtitle; a header (Claude-style payloads) keeps the previous
title/subtitle split, and multi-question batches keep the counted title.

* fix(web): drop the redundant header chip on single-question cards

The card title already shows the question header for a single-question
AskUserQuestion, and the footer repeated it as a badge ('Database' twice).
Render the header chip only for multi-question steps, where it labels the
current step and adds information.

* fix(web): request_user_input footer adopts the shared question option rows

Codex question footers rendered their own flat option rows (dot glyphs,
aria-pressed buttons) and default-variant nav buttons, visually diverging
from the AskUserQuestion card. Reuse the shared option row and pill button
styles so both question surfaces present identically; rows now expose the
same radio/checkbox roles and aria-checked state. Behavior (selection
rules, notes, dismissal) is unchanged.

* fix(web): render request_user_input option labels as Markdown

The shared option row renders titles and descriptions as plain text, but
request_user_input option labels and descriptions are authored as Markdown
(bold targets, code commands) and the footer's own rows used to render them
through MarkdownRenderer. Give the shared row an opt-in markdown mode that
keeps the compact spacing, and enable it for the request_user_input footer.

* fix(web): title CursorAskQuestion cards from the parsed question header

CursorAskQuestion renders through the AskUserQuestion footer but had no
knownTools entry, so its card title stayed the raw tool name. Now that the
single-question header chip is deduped against the title, a Cursor question
lost its header entirely. Share the question-tool presentation (header as
title, question as subtitle, minimal pending header) with Cursor payloads,
reading their title/prompt field names the same way the parser does.

* fix(web): translate tool.waitingForReply for zh-CN and ru

Both locales shipped the English copy. Use the same register as the
neighbouring strings: zh-CN '等待你的回复' (matches the 等待+object pattern of
the ready toast and the approval key) and ru 'Ожидание вашего ответа'
(noun form of 'Ожидание одобрения').

* fix(web): fall back to the Cursor request title for question card headers

A Cursor question whose descriptive title lives only on the request
(input.title) produced an empty header in the card presentation, so the
single-question card fell back to the generic 'Question' title while the
footer's header chip is deduped away — the request lost its descriptive
title everywhere. Route the CursorAskQuestion presentation through
parseCursorAskQuestionInput, which already applies the request-level title
fallback, keeping that fallback the single source of truth.
2026-11-12 07:06:43 +08:00
1dd71e2f30 fix(web): keep attached-job progress visible when the label is long (#2392)
The job label, stale marker and progress/elapsed text shared one truncating
span, so a long label hid the parts that change. The label now grows only
into the space the status leaves, down to a small minimum, and the status
truncates only after that.

Closes #2391

via [HAPI](https://hapi.run)

Co-authored-by: HAPI <noreply@hapi.run>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 07:05:54 +08:00
weishuandGitHub 926eac7023 fix: keep one stable HAPI session id per Claude conversation (#2388)
* fix: keep one stable HAPI session id per Claude conversation

Every terminal `hapi claude -r` minted a new HAPI session id for the same
Claude conversation; the hub then merged the duplicates after the fact and
deleted the older row, so links and peer references to it broke, and two
live duplicates hid one row in the web sidebar.

CLI: resolve identity before Claude starts (HAPI_SESSION_ID is fixed at
bootstrap). `--resume <id>` / `--continue` look up the owning HAPI session
and reopen it with the same id, handing an active remote session over and
refusing one controlled by another terminal; bare `--resume` uses the
`hapi resume` picker filtered to Claude. Rotated Claude ids are kept in
`claudeSessionIdHistory` so older ids still match.

Hub: schema v35 adds `session_redirects`; every merge that deletes a row
records old -> survivor, and client-facing lookups follow it (sockets and
job ownership stay strict). New `GET /cli/sessions/resume-target-by-agent`.

Web: a merged-away URL moves to the survivor instead of bouncing home, and
live Claude duplicates stay visible in the sidebar.

* fix: keep job-key remaps and hub-archived resumes working after redirects

Review follow-up for the stable session identity change.

- Job routes: the session lookup now follows a merged-away id to the
  survivor, so `requestedSessionId` must stay the raw URL id. Otherwise a
  colliding `<old id>/<key>` remap was bypassed and PATCH/DELETE/late PUT
  through the old id hit the survivor's own job.
- Terminal resume of an inactive session now asks the hub to clear a
  hub-authored archive first (`POST /cli/sessions/:id/prepare-local-resume`,
  same clear as hub reopen), so `hapi claude --resume/--continue` (and
  `hapi resume`) no longer exit on the #1911 existing-session guard.

* fix(cli): refuse an explicit Claude resume whose transcript is gone

Reopening the owning HAPI session drops --resume and hands the id to the
local launcher, which silently starts a fresh conversation when the
transcript is missing — under the existing HAPI id, title and history.
Check the transcript before any handoff or archive change and fail
explicitly instead.

* fix: follow merged-session redirects on /api only for clients that rebind

Native clients store a session detail under the requested id and drop SSE
events for any other id, so a merged-away id that resolved to the survivor
loaded history but never showed live messages.

`SyncEngine.resolveSessionAccess` is strict again by default; `/api` routes
follow redirects only with `x-hapi-follow-session-redirects: 1`, which the
web client (that rebinds to the returned id) sends. Native clients keep the
previous 404. CLI REST always follows. Job routes still keep the raw URL id
for key remaps under both modes.
2026-11-12 07:05:37 +08:00
Junmo KimandGitHub 7ac33a70c3 feat: show generation rate (tok/s) for Codex rounds (#2379)
* feat(codex): fill the round footer tok/s from app-server timing

Measure each Codex round's generation window the way agy rounds do: the
live turn span minus tool-execution and wait-for-the-user windows, over
the thread-cumulative output-token delta, emitted on the turn's
turn_duration so the round footer shows tok/s. Tool windows prefer the
app-server's own item timing (startedAtMs/completedAtMs/durationMs).
The token baseline is the last reported cumulative total: the CLI seeds
a thread it created in this process (thread/start) to zero, while
resumed and forked threads receive the app-server's attach-time usage
replay and stay unseeded, so inherited history is never counted as a
turn's output. Only the live root-turn feed reaches the ledger: history
replays re-project old items and must not settle a round. Permission
hooks keep timing waits for the user.

* fix(codex): seed gateway-created threads for the first-turn tok/s baseline

Native /new and /clear create threads through the gateway before/after
hooks, whose after() binds the fresh root without the zero usage seed
the runtime create path applies - so the new thread's first turn
captured a null baseline and never showed tok/s. Seed it there too,
same as create(): thread/start only, since forked threads receive the
app-server's attach-time usage replay instead (tiann/hapi#2379).

* fix(codex): keep the active generation ledger across a hub-only reconnect

SharedCodexRoot's session.onReconnect reset the whole projection, but a
hub reconnect only replays final history: the native turn keeps running
without a new turn/started, so dropping the ledger identity, baseline
and windows made generation.settle() return null at completion and the
round permanently lost its tok/s. Add projection.resetAfterHubReconnect
which replays without touching the ledger; the app-server reconnect
path keeps the full reset, because the resumed turn re-announces itself
and must re-measure from its own start (tiann/hapi#2379).

* fix(codex): seed fresh usage before session-ready releases queued input

The gateway thread/start seed ran in the after() hook, after the bind
wrapper had already activated the root: registerControls and
emitSessionReady open the input gates, so a queued Web prompt (or one
submitted on session-ready while the runner notification is delayed)
could start the thread's first turn before the zero baseline existed,
and seeding afterward could not repair that captured-null turn. Move
the seed into the bind wrapper right after root.bind, guarded by a
freshThread flag the create and gateway paths set for thread/start
only - forks keep their app-server attach-time replay baseline
(tiann/hapi#2379).
2026-11-11 20:32:54 +08:00
adminandGitHub eff515e2e0 feat(cli): rotate hub entries after repeated connect failures (#2383)
Self-hosted hubs are commonly reachable through several origins (an
edge-proxied domain and a direct one); cross-border interference can
randomly break TLS on either for hours. A runner pinned to a single
HAPI_API_URL sat dead through those windows.

When HAPI_API_FALLBACK_URLS is set, the machine client keeps a rotation
ring (primary + fallbacks) and, after HAPI_API_FAILOVER_AFTER (default 5)
consecutive connect failures, tears the socket down and reconnects
through the next entry. A successful connection on a fallback schedules
a return-to-primary attempt after 30 minutes. Without the env, behavior
is byte-for-byte unchanged.
2026-11-11 20:30:23 +08:00
weishu 9fe29431a0 fix(ios): tidy the session sort & filter menu
The menu mixed three selection markers (hand-drawn checkmark images,
Toggle checkmarks plus icons, and a radio-like filled circle), so row
text started at different offsets, and the machine roster made the menu
scroll.

- Sort By and Show use inline Pickers; Active First and Unread Only are
  plain Toggles. Selection now always uses the system checkmark column
  and every row's text lines up.
- Machines move into a "Machine" submenu whose subtitle names the
  current choice; each machine keeps its session count as a subtitle.
2026-11-11 17:09:56 +08:00
weishu 92da78469a Release version 0.34.6 2026-11-11 13:10:41 +08:00
Junmo KimandGitHub 523decdf86 fix(hub): fold repeated ACP tool-call updates into one row per callId (#2350)
* feat(shared): read the callId of a supersedable tool-call row

ACP agents re-emit the same tool call under a stable callId on every
state tick, and the timeline folds all of those rows into one card. The
hub and the web both need to recognise the rows that may be superseded,
so add `getToolCallId`, mirroring `getReasoningStreamId`/`getLiveReasoningStreamId`.

Only `codex`/`tool-call` payloads match. The `tool-call-result` that
shares the callId is a different row type that carries completion, so it
never matches and is never dropped. Anything unrecognised reads as null
("keep it").

* fix(hub): fold ACP tool-call updates into one row per callId

ACP agents re-emit a tool_call agent message for the first tool_call and
again for every tool_call_update, all under one callId, and the hub stored
each as its own row. History pages therefore filled with 2-4 duplicate
tool-call rows per call that the web then folded back into a single card
by callId.

Route agent tool-call messages (getToolCallId != null) through an upsert:
scan the session tail for a live tool-call row with the same callId,
stopping at a tool-call-result with that callId or at a user message row
(both mean the incoming message is a new call). On a match, merge the new
payload into the stored row in place — non-null new values win for
name/input/nativeTitle/nativeKind/nativeName/nativeArgs/status so a
status-only tick cannot erase an earlier tick's input — and keep the
row's id, seq, createdAt and localId. The content swap follows the
queued-message edit pattern (no new seq, no content_revision bump).

The post-store broadcast is unchanged (session-room update + web
message-received) and now carries the existing row's id/seq with the
merged content, which the web window store already upserts by id.
Nothing is deleted: result rows, permissions, localId resend handling
and non-tool messages behave exactly as before.

* fix(hub): never regress a merged tool-call row's status

A later tool-call tick that re-emits status pending (agents normalize a
missing/unknown status to pending, so OpenCode permission rounds resend
it after the call already ran) overwrote an earlier in_progress or
terminal status under the plain newest-non-null-wins merge.

Merge status by progression rank instead: pending < in_progress <
completed/failed. The merged row keeps the higher rank, so a running or
finished call never falls back to pending, and a terminal status always
wins over a non-terminal one in either direction. completed/failed share
the terminal tier and ties keep the newer value; unrecognized status
strings rank below every known state so they cannot regress one either.

Also pin the behaviors the upsert relies on with tests: the 200-row
lookback boundary on both sides, a tool-call-result for a different
callId not stopping the scan, nativeName/nativeArgs/progress merging,
and the handler re-broadcasting the existing row id/seq through both the
session-room update and web message-received without storing an extra
row.

* fix(hub): stamp derived tool state at merge time and skip no-op tool-call writes

A merged tool-call row keeps its first snapshot's createdAt for stable
ordering, but the session's derived TodoWrite/team versions gate on
strictly advancing timestamps (todos_updated_at and team_state_updated_at
only accept candidates greater than the stored watermark), so a refined
snapshot arriving on a later tick of the same callId was rejected and the
session's todo list stayed at its first snapshot. Stamp those versions at
merge time instead.

A re-emitted tick whose payload changes nothing now skips the row write
entirely: only observable content changes touch the database.

* fix(web): recover merged tool-call rows after an SSE replay gap

A gap resume (resume: 'gap') cannot prove continuity, and in-place
tool-call merges keep the row's original cursor position, so the
cursor-based tail sync after a gap re-delivered new rows but never the
merged content of rows the window already held. Tool cards could stay
stuck on their first snapshot until a reload.

On the gap path of both connect handlers, reconcile the window from an
authoritative latest page applied as an upsert: rows in the response
replace the held rows by id, while already-loaded rows older than the
latest page and the hasMore/oldest cursor and context survive; an older
load caught in flight is invalidated like on every tail sync and is
re-requested by the user's scroll. Replacing the whole window is not an
option here: a fresh session subscription is always a gap verdict, so
every session switch-back would throw away the user's scrolled-up
history. Rows older than the latest page are not re-fetched; a live
tool-call tick always updates a row inside the newest page, and a
failed recovery fetch leaves the flag set so the next sync retries the
latest page. Cold and structurally invalidated windows keep the plain
reset choreography.

* fix(web): catch up the disconnected interval before the gap-recovery upsert

Gap recovery fetched only the newest page and applied it as an upsert,
so a warm window whose cached tail sat below the page's oldest row kept
a permanent hole: rows that arrived while disconnected between the
cached tail and the page vanished, and the advanced newest cursor never
filled them (cursor syncs only return rows after their cursor).

Run a plain cursor sync first so the window catches up every row it
missed, then apply the authoritative latest page as an upsert to
refresh in-place merged rows. One extra round trip on reconnect; the
upsert alone stays correct for windows that are already contiguous.

* fix(web): replace retained rows when gap recovery observes a different epoch

The recovery upsert requested the latest page without an epoch and the
hub always answers reset:false for latest requests, so rows deleted
while disconnected survived: another client's rewind deletes rows and
bumps the epoch, but the missed messages-invalidated event left the
window's requiresLatestReset false and nothing detected the change.

Compare the response's epoch with the window's epoch in the latest-page
branch and fall back to a full replacement on mismatch. The cursor
catch-up that now precedes the upsert already carries the window epoch
and gets the hub's reset verdict, so this closes the remaining window
where the upsert runs without a preceding successful epoch-carrying
sync.

* fix(web): require a successful catch-up before the gap-recovery upsert

runTailSync resolves normally after catching a request error, so the
recovery continued to the latest-page reconciliation even when the
catch-up failed. With a cached tail at row 10 and the server head at
310, a failed after request followed by a successful latest request
retained row 10 alongside rows 111-310 and advanced the newest cursor
to 310: rows 11-110 became unreachable through ordinary tail or older
paging, and the successful latest response cleared the failure warning.

Fold the recovery into the tail sync itself: the pendingGapRecovery run
catches the window up through the ordinary cursor phase and only
reconciles the latest page once that phase completed without error. A
reset verdict inside the catch-up already replaced the window
authoritatively, so the recovery flag is simply consumed there. On a
catch-up failure the catch skips the reconciliation, keeping the
original cursor, the flag for the next sync's retry, and the visible
warning.

* fix(web): keep the loaded history budget across the gap-recovery upsert

applyLatestResponse always trimmed the merged window to the 400-row
tail budget, even when only refreshing it in place. A reader with 600
loaded history rows therefore lost the oldest rows on a same-epoch
reconnect with no new messages, shifting their reading anchor even
though nothing on the server changed.

Size the recovery upsert's trim to the window's own history budget,
capped at the 800-row older-load ceiling: rows the reader already
loaded are preserved on a no-news recovery instead of being re-evicted.
Full replacements keep the tail budget, since a replaced window holds
only the response rows anyway.

* fix(web): run the catch-up when gap recovery overlaps a cached activation

A cached session's activation asks for a direct latest page
(preferLatestOnActivation), and runTailSync's canIncrement excluded that
flag unconditionally. When gap recovery was requested on top of such an
activation, the recovery therefore took the activation shortcut: a
direct latest-page fetch with no cursor catch-up. With cached rows 1-10
and the server head at 310, the window retained rows 1-10 plus the
latest page 111-310 and advanced its newest cursor to 310, leaving rows
11-110 unreachable through ordinary tail or older paging; the recovery
flag was consumed without ever catching the window up.

Let a pending recovery claim the cursor path even when an activation
shortcut is pending, and defer the activation flag for that run: the
recovery's catch-up + latest-page reconciliation subsumes the
activation's refresh-from-latest, so consuming it there is equivalent.
The flag is also cleared when the recovery finishes through a reset
verdict or its latest-page reconciliation, so a mid-run activation
cannot linger into a later full replacement.

* fix(web): refresh out-of-page tool-call rows during gap recovery

A tool-call row cached before a disconnect can be enriched in place
afterwards; when more than a latest page of newer rows follows before
reconnect, neither the catch-up (newer rows only) nor the latest page
reaches it, and the cached card keeps its stale input/status until the
session is reopened (review finding on hub messages.ts:378, the web
half of the documented jkRY limit).

After the recovery's latest-page reconciliation, sweep the window for
retained non-terminal tool-call rows older than the page bound and
older than the recovery cursor, and refresh each by id through the
existing message-context endpoint. Bounded at 20 (newest first),
best-effort (a failed or epoch-mismatched refresh leaves the row to the
next recovery), and generation-guarded like the rest of the run.

* fix(web): surface gap-recovery refresh failures as the usual sync warning

The out-of-page tool-call refresh sweep swallowed per-row context-fetch
errors, leaving a stale row silently. Let a rejected refresh propagate
to runTailSync's catch so the run's usual warning surfaces; the row
stays as is and the next sync retries the sweep. A refresh answered
under a different epoch, or one that no longer contains the row, stops
the sweep without touching the window. Terminal rows are never swept
(merge status only advances); tests pin the zero-request skip and the
warning on failure.

* fix(android): recover merged tool-call rows through the gap-recovery upsert

The Android window store's gap path recovered through a cursor sync
only: merged tool-call rows keep their original cursor position, so a
row enriched while disconnected kept its stale input/status until a
fresh page happened to include it (the same hole the web recovery
closed).

Port the web choreography: the gap entry point (resume: 'gap' on the
session pipe) flags the window (pendingGapRecovery) and runs
recoverAfterGapResume; the next tail sync catches up the missed
interval with the cursor sync, then fetches an authoritative latest
page and applies it as an upsert — rows present in the page are
replaced by id while rows older than the page, the hasMore/oldest
cursor and the loaded history budget (up to the 800-row older-load
ceiling, mirroring the web trim) survive. An epoch mismatch under the
page falls back to full replacement, a reset verdict during the
catch-up consumes the recovery, and a failed catch-up keeps the flag
and the original cursor so the next sync retries the whole recovery. A
recovery requested while a cached activation's preferLatestOnActivation
is set claims the cursor path and defers the activation shortcut, and
the tail-sync coalescing joins or replaces in-flight runs by their
snapshotted recovery/activation mode like the web does. The queued
-state reconciliation keeps its own ensureAfterCurrent drain and runs
concurrently with the recovery, mirroring the web's two post-gap calls.

The bounded by-id refresh of out-of-page non-terminal rows stays
web-only (Limits follow-up; it needs the message-context endpoint in
the native API seam).

* fix(ios): recover merged tool-call rows through the gap-recovery upsert

Mirror of the Android recovery port for the HapiKit window controller:
the session layer's resume: 'gap' handling now flags the window
(pendingGapRecovery) and runs recoverAfterGapResume alongside the
queued-state reconciliation, and the tail sync catches up the missed
interval with the cursor sync, then fetches an authoritative latest
page and applies it as an upsert — rows present in the page are
replaced by id while rows older than the page, the hasMore/oldest
cursor and the loaded history budget (up to the 800-row older-load
ceiling, mirroring the web trim) survive. An epoch mismatch under the
page falls back to full replacement, a reset verdict during the
catch-up consumes the recovery, and a failed catch-up keeps the flag
and the original cursor so the next sync retries the whole recovery. A
recovery requested while a cached activation's preferLatestOnActivation
is set claims the cursor path and defers the activation shortcut, and
syncTail coalescing joins or replaces in-flight runs by their
snapshotted recovery/activation mode like the web does.

Tests run in CI (Swift toolchain is not available on this machine):
recovery converges the merged row through catch-up + latest page, and a
failed catch-up stops before the latest page and retries on the next
recovery. The bounded by-id refresh of out-of-page non-terminal rows
stays web-only (Limits follow-up).

* test(ios): read the window-message envelope from content, not wire

The new gap-recovery tests compared the merged tool-call row through a
`.wire` accessor that does not exist on WindowMessage (the
role-wrapped envelope lives on the public `content` field; `wire` is
only the convenience initializer's parameter name), which failed to
compile the whole HapiKit test target in CI. Compare the envelope
content values directly — still by value, not by WindowMessage
identity.

* test(ios): read the retry requests off the cumulative request list

provider.requests accumulates across the whole test: the failed first
catch-up stays at index 0, so the retry's catch-up and latest page sit
at indices 1 and 2 — the assertion counted from the retry point and
failed in CI even though the retry behaved exactly as pinned
([after, after, latest]).

* fix(web): keep the reset requirement when the recovery catch-up overflows

A recovery catch-up page can overflow the window's history budget:
history-mode trimming keeps the reading anchor, drops the newer
caught-up rows, and marks the window for a reset
(mergeIntoWindow's prepend trim). The loop breaks on
requiresLatestReset without distinguishing that overflow from a
completed catch-up, and the recovery then reconciled the latest page
on top anyway and consumed the recovery flags — stranding the rows
between the reset-marked window and the page, unreachable from either
cursor (older paging descends from the window edge, the newest cursor
has already passed them).

When the catch-up ends with the window reset-marked, leave the reset
requirement and the recovery flags intact: the next sync's
authoritative replacement closes the hole and consumes the flags, the
same choreography as every other reset-marked window.

* fix(web): finish the sync when the gap-recovery refresh sweep stops early

The out-of-page tool-call refresh sweep early-returned when a context
response no longer contained the row or answered under a different
epoch, bypassing finishTailSync and leaving the window marked syncing
after the controller promise resolved — suppressing tool-history
hydration and read receipts until another sync ran.

Complete the run's bookkeeping on both exits: a missing row finishes
with the usual warning and the row as is; an epoch mismatch marks the
window for the authoritative replacement (server rows may have been
deleted since the page was fetched) and finishes with the warning
instead of reconciling against a stale snapshot.

* fix(android): keep the reset requirement when the recovery catch-up overflows

A recovery catch-up page can overflow the window's history budget: the
history-mode prepend trim keeps the reading anchor, drops the newer
caught-up rows, and marks the window for a reset. The catch-up loop
breaks on requiresLatestReset without distinguishing that overflow from
a completed catch-up, and the recovery then reconciled the latest page
on top anyway and consumed the recovery flags — stranding the rows
between the reset-marked window and the page, unreachable from either
cursor.

When the catch-up ends with the window reset-marked, leave the reset
requirement and the recovery flags intact: the next authoritative
replacement (on returning to the tail view, or on a sync that may reset
history) closes the hole and consumes the flags, the same choreography
as every other reset-marked window. Mirrors the web fix.

* fix(android): keep the earlier older cursor when the recovery upsert retains rows

When the recovery's latest-page upsert retains rows older than the
page (no trim), applyLatestResponse still preferred the response page's
own bound as the older-paging cursor, so an 800-row no-news recovery
re-pointed older loads at the page's oldest row and left the held rows
1-600 unpaged. Keep whichever side is older, like the web has since the
loaded-history-budget fix.

* fix(android): refresh out-of-page tool-call rows during gap recovery

Port the web sweep: after the recovery's latest-page reconciliation, the
window re-reads its retained non-terminal tool-call rows that sit older
than the page bound and were not delivered fresh by the catch-up through
the existing message-context endpoint — bounded at 20 newest-first, with
the same exit semantics the web sweep carries (a missing row finishes
the run with the usual warning and the row as is; a refresh answered
under a different epoch marks the window for the authoritative
replacement and finishes with the warning).

The seam gains getMessageContext (wire types MessageContextPage/
MessageContextResponse; the hub answers a bare null when the message
does not resolve), implemented by HapiApi and scripted null in the
fakes.

* fix(ios): keep the reset requirement when the recovery catch-up overflows

Mirror of the Android/web recovery overflow fix: a recovery catch-up
page can overflow the window's history budget — the history-mode
prepend trim keeps the reading anchor, drops the newer caught-up rows,
and marks the window for a reset — and the recovery then reconciled the
latest page on top anyway and consumed the recovery flags, stranding
the rows between the reset-marked window and the page, unreachable from
either cursor.

When the catch-up ends with the window reset-marked, leave the reset
requirement and the recovery flags intact: the next authoritative
replacement (on returning to the tail view, or on a sync that may reset
history) closes the hole and consumes the flags. Test rides CI — no
Swift toolchain on this machine.

* fix(ios): keep the earlier older cursor when the recovery upsert retains rows

Mirror of the Android/web cursor fix: when the recovery's latest-page
upsert retains rows older than the page (no trim), applyLatestResponse
still preferred the response page's own bound as the older-paging
cursor, so an 800-row no-news recovery re-pointed older loads at the
page's oldest row and left the held rows 1-600 unpaged. Keep whichever
side is older, like the web has since the loaded-history-budget fix.
Test rides CI.

* fix(ios): refresh out-of-page tool-call rows during gap recovery

Port the web sweep: after the recovery's latest-page reconciliation, the
window re-reads its retained non-terminal tool-call rows that sit older
than the page bound and were not delivered fresh by the catch-up through
the message-context endpoint — bounded at 20 newest-first, with the same
exit semantics the web sweep carries (a missing row finishes the run
with the usual warning and the row as is; a refresh answered under a
different epoch marks the window for the authoritative replacement and
finishes with the warning).

The transport gains the endpoint end to end: MessageContextPage/
MessageContextResponse wire types (the hub answers a bare null when the
message does not resolve), APIClient.messageContext, the MessagesProviding
requirement, and the row-swap helper on the window logic. agentMessage-
PayloadType becomes public so the controller can classify rows like the
web does. Tests ride CI — no Swift toolchain on this machine.
2026-11-11 13:05:04 +08:00
AnanovoandGitHub 5e76af5615 feat(codex): fork running sessions through the last completed turn (#2369) 2026-11-11 13:04:43 +08:00
AnanovoandGitHub f11f7097ef fix(cli): respect workspace image delivery preferences (#2368) 2026-11-11 10:03:57 +08:00
weishu 35898c09cd feat(android): web-parity presence badges, sort/filter and attached jobs
The home list showed presence only for connected sessions, offered no
sort or status choices, and ignored session-attached jobs. Its strict
SessionPatch parser also rejected every `attachedJob` SSE patch, so each
job heartbeat fell back to a REST list refetch.

- Presence badge follows web #2296: solid green pulsing while working,
  solid blue pulsing for background tasks only, a green ring when
  connected and waiting, and a power mark when stopped or archived.
- The Sort & filter sheet adds Show (all / active only / archived only)
  and Unread only next to machines and dates, then Sort by (last message
  or date created) and Active first (on by default; manual pins still
  lead). Sort and Active first persist app-wide in hapi_prefs; filters
  stay transient, keep the open session listed, and Reset leaves the
  order alone. Search keeps relevance with the base tie-break. The share
  picker keeps the base order.
- Decode AttachedJob on summaries and the versioned `attachedJob` patch,
  applied only when strictly newer, as on web. Full-session events keep
  the row's job. A running job counts as working on the badge and as
  active for the Show filter (web #1404), and adds a row line with
  label, remaining or percent, elapsed time and a thin bar, amber with
  "no heartbeat" after 15 minutes.
- HomeFilterWindowTest's click helper now scrolls back once it reaches
  the end; the taller sheet otherwise stranded targets above the
  viewport.
- Docs describe the Android sheet, row and job display.
2026-11-11 09:40:45 +08:00
a29fe7b32f feat(web): fade non-resident session rows alongside the presence badge (#2362)
832c5922f moved liveness onto the agent icon and dropped the row fade; #2296
then gave every state its own mark, so stopped is no longer shown by an absence.
That fixes identity. It doesn't fix scale.

The badge answers "what state is this row in?" once you look at it. It can't
answer "which of these sessions is still held in memory?" across a long list,
because that's a whole-list scan and a 10px mark doesn't survive one. At a
handful of sessions the badge covers both jobs. At ~30 active, a stopped row and
a resident idle row are the same shape of row until you inspect each badge.

So restore the fade on `!active` — the same predicate the stopped badge uses,
rendered at the other scale. Shape carries which state; dimming carries which
rows.

The fade covers the title line only. The presence badge and the attached-job
meter sit outside it deliberately: a job outliving its agent is exactly the case
where the row is non-resident but the work is live, and both facts have to stay
readable at once. #2296 already marks that session's badge as working; this
keeps the row dim underneath it.

via [HAPI](https://hapi.run)

Co-authored-by: HAPI <noreply@hapi.run>
2026-11-11 08:58:25 +08:00