Commit Graph
979 Commits
Author SHA1 Message Date
wushenghua 7ac5bd3f02 chore: track fixes already present in the deployed 0.36.5 build
Hub session-list stats now use the combined getFutureScheduledMessageStats call; web icon sizing and machine-filter breakpoints corrected; iOS build version bumped; Windows host install docs added.
2026-11-24 18:16:04 +08:00
wushenghuaandClaude 5e4f91ddc9 fix: stabilize shared session guest auth
Cache the session-storage auth object so guest API consumers keep a stable client across renders and do not restart their sync effects.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-23 11:20:46 +08:00
283e901d9d fix: repair post-merge hub routes and web feature regressions
Reviewing the v0.36.5 merge against the per-package suites (the root
script short-circuited at the known CLI disclaim failures) exposed
several real regressions:

- Restore the machine-level Claude/Codex model routes dropped from
  createMachinesRoutes; both returned 404.
- Route Codex imports through ListLocalSessions when the runner
  advertises it, keep the legacy RPC for older runners, avoid reading
  the hub's own CODEX_HOME when a runner is available, honor the
  200-session cap, apply model/effort through applySessionConfig, and
  roll back a session created by a failed first import.
- Repair usage_scan_state for fork databases: add the missing namespace
  column and keep the scan cursor independent of session deletion, as
  the durable usage ledger requires.
- Pin KaTeX to `trust: false`; an inherited Object.prototype.trust
  could emit javascript: links from user Markdown.
- Reintegrate upstream fork preview/rewind flow, branch conversation
  UI, system notes, pending-request navigation, PR header, search
  match-mode dropdown, and machine-scoped session dedup in the web app.
- Restore the global Skip action for ask-user questions, queued-message
  steer labels, image preview attributes, and settings-transfer key
  classification.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-20 14:36:21 +08:00
1473fa1dfa merge: hapi upstream v0.36.5
Adopt fork preview/boundary and branch endpoints, GitHub PR awareness,
session external refs, queue batch aliases and the attached runtime's
history validation. The fork keeps its Session List/Row/Chat surfaces,
Claude/DSH import dialogs, goal controls and DSH Web runtime.

Notable resolutions:
- Codex projection compares replay payload identity while still carrying the
  fork's Hub persistence options; queue committed() now uses upstream's batch
  alias matching
- user messages are ACKed per accepted batch member, with the fork's replay
  createdAt/verifyPersistence path retained
- server keeps the fork's public studio/share middleware and one gzip
  middleware; upstream's static cache headers and HEAD handling are adopted
- settings keeps the fork's session-summary/teams/unavailable-agents rows and
  adds GitHub PR awareness
- iOS keeps the personal bundle id and local string catalog (Japanese catalog
  from upstream is not merged)

Validation: typecheck passes; suite 5971 pass, failures limited to the four
machine-specific macOS responsibility probes.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-20 13:33:58 +08:00
81f0c0215c merge: hapi upstream v0.36.0
Adopt passkey login/management endpoints, attached Codex runtime gating and
the generic local-session RPC registry. The fork keeps its per-flavor Claude/
DSH/Pi/OpenCode import routes and dialogs, DSH Web runtime and custom Session
List/Row UI.

Resolutions worth knowing:
- schema is v36 with both passkey_credentials and the fork's studio/share
  tables; local stores remain alongside upstream PasskeyStore
- server mounts passkey login before auth and passkey management after, with
  the fork's guest/share middleware intact
- Codex root keeps local history sync/compaction and goal metadata while
  honoring host.attached: no bridge, read-only forks, attached refresh
- generic ListLocalSessions is registered in addition to the fork's per-flavor
  handlers; Claude transcript conversion accepts the fork's localId shape
- web keeps the local Claude/DSH import dialogs and manual upload path

Validation: typecheck passes; suite 5689 pass, failures limited to the
machine-specific macOS responsibility probes.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-20 13:26:16 +08:00
1638bb8577 merge: hapi upstream v0.35.1
Keep the fork's DSH Web runtime, OpenCode goal/native-variant paths and
media uploads; adopt upstream model-error notifications, OpenCode rewind
gating, chunked upload endpoints, hub settings split and the ACP shouldSend
guard.

Notable resolutions:
- ACP prompt keeps the local runPrompt request hook, now with upstream's
  shouldSend option, numTurns and boolean result
- OpenCode dequeue keeps local goal-aware thinking and native variants inside
  upstream's runtime gate / conversation-history flow
- web attachment adapter intentionally stays on the local 50 MiB single
  upload path; hub/client chunked endpoints remain available
- removed the upstream DSH ACP model-probe test because the fork uses the
  Web runtime catalog

Validation: typecheck passes; suite 5600 pass, 6 fail (five macOS
responsibility probes in disclaimExec.darwin are environment-specific; one
obsolete DSH probe test removed).

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-20 13:19:03 +08:00
ed517bfc1f merge: hapi upstream v0.35.0
Preserve the fork's teams, session groups, widgets/Live Activities, skins,
DSH steering and custom Claude models while adopting upstream session-attached
jobs, tri-state pin policy, presence badges, ACP prompt timing, agent quotas
and the usage parser version.

Resolutions worth knowing:
- schema ladder is now v35; local v31→v32 chat attachments and upstream's
  session-jobs step coexist, and v32→v33 installs jobs for existing fork DBs
- store keeps local Studio/live-activity/share/attachment stores alongside
  upstream SessionJobsStore and SessionRedirectStore
- DSH steering stays enabled through upstream's capability map
- iOS keeps personal bundle ids, grouped sections and widgets; upstream's
  presence badge, job line, sort order and Filter menu are integrated
- team tools and peer spawn remain, now gated by enabledTools

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-20 13:06:05 +08:00
wushenghua d7a59b8931 feat(sessions): pick existing groups instead of retyping 2026-11-20 00:51:57 +08:00
wushenghua 6d333a4df5 feat(sessions): user-defined groups across web, iOS and Android 2026-11-20 00:08:01 +08:00
weishu f40a472fa2 feat(web,ios,android): add native Japanese localization
Add ja locale to the web app (ja.ts, detection, language pickers, date
format), Android (values-ja, AppLanguage.JAPANESE, locales_config) and iOS
(ja in Localizable.xcstrings, AppLanguage.japanese, knownRegions).
2026-11-18 12:55:02 +08:00
weishu a21b3db02d feat(web): add native app promo for desktop and phone web
Nudge web users toward the paid App Store / Google Play apps, framed as
support for a fully open-source project whose web app stays free and
fully functional.

- Desktop: dismissible "Get the app" pill in the top-right of the session
  header / empty pane; popover with QR code, store links, and a pairing link.
- Phone: one-time bottom sheet on the session list, never on the first
  visit, with platform-matched store buttons.
- Settings > About: permanent store links.
- Dismissal holds for the release line (major.minor) so patch releases
  never re-prompt, plus a 14-day cooldown across minor releases.
2026-11-18 12:55:02 +08:00
e55d29c056 feat(session): opt-in GitHub PR awareness + explicit attach (#1163)
* feat(session): structured externalRefs + list PR chip

Add optional metadata.externalRefs for durable session↔GitHub PR
identity and a clickable primary-PR chip on session list rows, plus
GET /api/sessions/:id/external-refs. Fixes titles-as-identity hacks
without title parsing (tiann/hapi#1160).

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

* fix(session): validate external PR URL identity

Prevent structured PR chips from linking outside the declared GitHub repository and pull request.

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

* fix(session): preserve externalRefs on merge + restore row focus group

Carry forward metadata.externalRefs when consolidating into a replacement
session row that omitted them (explicit new values still win). Move
group/session-row back onto the focusable list button so keyboard tooltips
reveal correctly (PR #1161 review).

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

* fix(session): carry forward externalRefs on bootstrap/metadata write

Preserve metadata.externalRefs when CLI pickExistingSessionMetadata and
hub updateSessionMetadata receive sparse replacements that omit the
field; explicit incoming refs (including []) still win. Closes the
resume/bootstrap data-loss path left after mergeSessions (PR #1161).

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

* feat(session): opt-in GitHub PR awareness and explicit attach

Add hub githubPrAwareness (default off), features API, PUT/CLI external-refs
write path, Settings toggle, link dialog, hapi link-pr, and MCP link_pr so
sessions can attach to PRs without title scraping. Depends on #1161 schema.

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

* feat(session): cache PR status on externalRefs for chip display

Extend GithubPrExternalRef with optional status/statusCheckedAt/statusAction
so Meta can write classifier health onto the attachment. Chip renders emoji
+ #N with status tone. Fixes link_pr tool-list expectations in MCP tests.

Part of tiann/hapi#1162 / #1163 (awareness + state in one PR).

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

* test(web): mock AppContext for General settings language test

SettingsGeneralPage now reads githubPrAwareness via useAppContext /
useFeatures; wrap the settings page suite with mocks so the language
inline test stops throwing AppContext is not available.

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

* fix(web): put PR chip left of session list time

Chip was a trailing sibling outside the row button, so rows with chips
shoved the relative-time column left. Keep time as the stable trailing
meta; optional chip sits immediately before it.

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

* fix(web): mute PR chip when statusCheckedAt is older than 2h

Cache honesty for Meta-filled externalRefs — never live-query GitHub from
the browser; stale chips show ? and a muted tone.

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

* fix(web): use relative ago in PR chip tooltip title

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

* test(web): keep companion baseUrl when mocking AppContext for features

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

* feat(session): forge-native PR chip snapshot + estate display profile

Replace Meta babysit status enums with GitHub-shaped openState/checks/merge
plus opaque estateCode. Chip terms (emoji, action prose) come from
$HAPI_HOME/pr-chip-display.json served on GET /api/features.

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

* fix(hub): use bun:test in prChipDisplay tests

Hub package typechecks include *.test.ts and has no vitest types;
CI failed resolving 'vitest' from the forge chip display suite.

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

* feat(web): compact PR chip to emoji; details on hover/long-press

Session list chips show status glyph only (estate emoji, or PR/?) so
multi-digit numbers stop crowding the row. Full repo#N + status copy
moves to HoverTooltip (desktop hover/focus) and touch long-press.

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

* fix(web): show PR detail in session action menu, not chip long-press

Keep desktop HoverTooltip on the compact emoji chip. Mobile long-press
stays on the session row; linked PR identity/status now tops that menu.

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

* fix(web): chip-specific hover tooltip + emoji in PR menu header

Keep HoverTooltip scoped to the PR chip (not row), unclip overflow, and
front the same status glyph in list long-press and session ⋯ menus.

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

* fix(cli): give claudeRemote first-result test a 15s CI timeout

Same flake as sibling cases under full-suite load; default 5s timed out
twice on #1163 after upstream merge.

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

* fix(cli): drop duplicate vitest timeout after merge

Upstream #1493 uses it(name, { timeout }, fn); the merge also kept the
legacy third-arg timeout, which Vitest 4 types reject.

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

* fix(hub,cli): address Codex Majors on PR awareness

Owner-gate PATCH /features, persist githubPrAwareness via updateSettings,
and fail MCP link_pr unless flushMetadata keeps the ref.

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

* fix(cli,web,shared): close remaining Codex findings on #1163

Gate MCP link_pr on hub awareness, upsert externalRefs, mark undated
chip snapshots stale, and hide the settings toggle from tenants.

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

* fix(hub,cli,web): CLI features probe + preserve secondary PR refs

Expose GET /cli/features and /cli/sessions/:id/external-refs for CLI
auth, upsert primary links in hapi link-pr and the web dialog, and tick
chip/menu staleness on a minute clock.

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

* fix(hub,cli,web): atomic external-ref upsert + create-session gate

Hub merges refs inside the metadata-version retry loop; CLI/web call
upsert/remove-primary instead of snapshot PUT. Strip externalRefs on
CLI create when awareness is off; list chips are display-only in the
row button.

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

* fix(shared,hub,cli): preserve PR health cache on same-identity upsert

Re-linking an already-linked github_pr was wiping openState/checks/merge
snapshots. Merge identity fields instead of replace-on-upsert.

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

* fix(shared,cli): case-insensitive PR identity + valid source fixtures

Treat owner/repo as case-insensitive on upsert/re-link so cached health is
not dropped, and keep regression fixtures within agent|user|inferred.

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

* fix(cli): initializeToken before hapi link-pr hub calls

Match ping-peer/inspect-peer so settings.json auth and apiUrl load
before getAuthToken/axios; keep --help free of prompts.

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

* fix(cli): omit link_pr from standalone hapi mcp defaults

Keep awareness opt-in: internal bridges still pass --tools after hub probe.

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

* test(cli): match default MCP tool registration order

list_peers registers after ping/inspect on the stdio bridge.

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

* fix(cli,shared): exact link_pr auto-approve + single primary refs

Stop substring/call-id matching for link_pr, and reject multi-primary
externalRefs at the Metadata/PUT schema boundary.

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

* fix(web): drop duplicate showSessionSummaryInChat in markdown-a test

Upstream merge left a duplicated mock field that broke tsc.

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

* fix(#1163): cap externalRefs count and disable env-pinned PR toggle

Bound externalRefs at 32 in schema + socket update-metadata ingress;
forward disabled on SettingsSwitch when HAPI_GITHUB_PR_AWARENESS pins the hub.

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

* fix(#1163): validate mutate externalRefs + hapi-scoped link_pr approval

Re-parse upsert transforms with ExternalRefsSchema before persist; only
auto-approve link_pr when MCP server provenance is hapi or the tool name is
a verified HAPI bridge identity.

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

* fix(#1163): trust HAPI link_pr provenance from envelope only

Auto-approve link_pr variants only when trustedHapiMcp is set from MCP
elicitation envelope serverName, not from tool arguments. ACP no longer
reads forged serverName from rawInput; HAPI mcp_tool_call approvals route
through the permission handler instead of blanket bridge auto-accept.

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

* fix(#1163): outer envelope only for trusted HAPI MCP provenance

Do not treat nested elicitation request.serverName as trusted identity;
poll features query so hub-global githubPrAwareness updates reach other tabs.

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

* fix(#1163): reject duplicate external ref identities in schema

Case-insensitive github_pr repo+number pairs cannot appear twice in
externalRefs; prevents upsert health merge depending on array order.

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

* fix(#1163): bound repo slugs, hoist PR polling, toggle errors

Cap GitHub repo slugs at 140 chars; share one features query and minute
clock across session list rows; surface githubPrAwareness toggle failures.

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

* fix(#1163): hub upsert link_pr + read-only untrusted gate

MCP link_pr uses atomic hub upsert (no metadata flush retry loop); block
untrusted link_pr auto-approve in read-only mode.

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

* fix(#1163): authoritative hub upsert + merge retry + 400 invalid refs

Stop replaying stale externalRefs through CLI metadata after hub upsert;
recompute merge metadata from the latest target row on version retry;
map ExternalRefsSchema failures to 400 on upsert routes.

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

* fix(#1163): fail merge before deleting source on metadata contention

Use METADATA_RETRY_ATTEMPTS for carry-forward metadata during session
merge; throw if externalRefs never commit so the source row is not deleted.

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

* fix(#1163): merge metadata before moving source-owned rows

Run carry-forward metadata merge before messages, scratchlist, and
attachments transfer so a failed merge leaves the source intact.

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

* fix(#1163): validate externalRefs on CLI session create

Share externalRefsInMetadataValid between socket and REST session
ingestion so malformed metadata.externalRefs returns 400 before persist.

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

* fix(#1163): reject non-boolean githubPrAwareness in settings.json

Match serverChanBackgroundOnly: Boolean("false") is true and would
silently enable the opt-in PR-awareness flag from a hand-edited file.

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

* fix(#1163): reveal nested PR chip tooltip on session-row focus

Non-interactive chips sit inside the row button as spans; wire
SESSION_ROW_TOOLTIP_FOCUS_CLASS so keyboard focus shows the tooltip.

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

* fix(#1163): keep raw metadata when linking PR on unparsed rows

mutateSessionExternalRefs reads the on-disk metadata blob instead of
cache-null fallback so link/unlink cannot wipe name/summary/worktree.

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

* fix(#1163): prefer merge conflicts over passing checks on PR chip

Candidate forge keys now rank conflicting/blocked merge ahead of
checks.pass/pending so the chip cannot look healthy when unmergeable.

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

* fix(#1163): localize PR chip detail strings for zh-CN

Map default forge labels and checked/stale/linked through i18n so tooltips
are not mixed-language; pass estate labels through unchanged.

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

* fix(#1163): prefer terminal PR openState over clean/pass chip

Merged/closed/draft snapshots must not show "ready to merge" when the last
poll still has clean+pass. Also localize aria-label status via the same
forge-label map as tooltips.

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

* fix(#1163): a11y label and i18n for Link PR invalid input

Give the PR field an aria-label and show localized invalid-input copy
instead of English parseGithubPrInput errors in the dialog.

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

* fix(#1163): gate PR awareness switch; expose nested chip to AT

Disable the settings toggle until features load so owners cannot flip a
placeholder off state. Nested session-row chips use sr-only detail so the
focused row announces PR identity and status.

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

* fix(#1163): refresh MCP link_pr catalog when awareness flips

Re-fetch hub githubPrAwareness for each new HTTP MCP session and invalidate
stale sessions so listTools picks up the toggle without restarting the
Happy server. Stdio --tools remains spawn-scoped.

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

* fix(#1163): gate link_pr at call time without killing MCP sessions

Keep link_pr in the HTTP and stdio catalogs under dynamic awareness, and
re-check the hub flag on each call. Avoids 404ing the stdio bridge session
when Settings toggles awareness mid-run.

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

* fix(#1163): hide MCP link_pr via enable/disable when awareness flips

Keep HTTP/stdio transports alive; toggle RegisteredTool visibility from hub
settings and sync the Codex stdio catalog without killing cached sessions.

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

* fix(#1163): avoid link_pr list_changed loops; poll idle HTTP clients

Only call RegisteredTool enable/disable on actual visibility transitions.
Add a bounded awareness poll so Claude HTTP MCP learns Settings flips
without a client request, and cover idempotent + poll-only transitions.

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

* feat(#1163): accept GHES hosts for GitHub PR external refs

Fold the upstreamable multi-host parser core into PR awareness: validate
github.com and *.ghe.com (plus configureGitHubHosts inject), preserve forge
host in parse/build/upsert, and relax schema URL matching accordingly.
Browser-safe — no operator YAML or Meta tooling in this change.

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

* fix(#1163): keep GHES host through attach + PR identity

Pass parsed.url from UI/CLI/MCP builders, and key identity/dedupe on
host+repo+number so github.com and Enterprise PRs with the same slug
do not collide or share cached health.

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

* fix(#1163): typecheck link-pr GHES attachment test

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

* fix(#1163): assert GHES link-pr body via toHaveBeenCalledWith

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

* fix(#1163): do not auto-approve link_pr in read-only mode

Trusted HAPI MCP provenance must not bypass read-only permission mode
when linking a PR; leave the write pending for user approval.

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

* fix(#1163): make list PR chip open its PR and show #N

Render the session-list chip as a sibling link beside the row button
(no nested interactive content) and include the PR number in the
compact glyph so operators can tell which PR is linked at a glance.

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

* fix(#1163): drop invalid host from SessionList PR chip test

SessionSummaryMetadata has no host field; CI typecheck failed on the
fixture metadata literal.

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

* fix(web): put session-row focus group on the row button

Restore group/session-row on the focusable button so attention and
schedule HoverTooltips still reveal under group-focus-visible.

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

* fix(#1163): align stdio default-tool test with peer/session_job catalog

Standalone MCP defaults now include spawn_peer and session_job; keep
asserting link_pr stays opt-in.

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

* fix(#1163): match merge metadata failure tests to preserve contract

SessionCache throws "Failed to preserve session metadata during merge"
after exhausted retries / store errors; update hub expectations.

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

* fix(#1163): prompt for Codex link_pr instead of native auto-approve

Native approval_mode approve bypassed BasePermissionHandler's read-only
guard; prompt so linking a PR still requires permission in read-only.

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

* fix(#1163): satisfy typecheck on link_pr approval regression

Avoid optional tools property access that failed cli tsc under strict
null checks.

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

* fix(#1163): align archive timeout assertion with 503 Cloudflare contract

Upstream #2423 maps ArchiveCleanupError timeout to 503 (not 504) so
Tunnel keeps JSON bodies; update the missed singleflight assertion.

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

* fix(#1163): memoize session-list PR clock between minute ticks

Avoid sampling Date.now() every render so memoized SessionItem rows
do not rerender on unrelated SSE updates when awareness is off.

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

* fix(#1163): preserve machine-spawn stub when attaching a PR

External-ref metadata writes used to clear the preallocation tag, so
adoptPreallocatedSession failed after an early link. Pass
preservePreallocation and cover stub → link → adopt.

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

* fix(#1163): size PR chip padding from quick-action span

Pinned active rows show Unpin + Archive; reserve the CSS action span
so the chip no longer overlaps Unpin and steals clicks.

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

* fix(#1163): align quick-unpin unread focus test with #2434 panels

session-group-unread-peek was removed when collapsed groups kept unread
rows in per-row CollapsiblePanels; update the #2443 focus assertion.

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

* fix(#1163): unblock passkey browser CI after shared-RP rematch

Playwright route.fulfill drops Location fragments on 3xx, so the
callback never received #state/#code and the opener hung. Apply the
fragment via a document navigation in the harness. Also reuse the
parsed complete form body instead of reading the request twice.

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

* Revert "fix(#1163): unblock passkey browser CI after shared-RP rematch"

This reverts commit 0092ea4b8c69add993fdd2f4b3da411eca641364.

* Revert "Revert "fix(#1163): unblock passkey browser CI after shared-RP rematch""

This reverts commit 1094372855204375a72101c07fa06f70a1aefdd7.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 12:53:26 +08:00
Junmo KimandGitHub e57df1822a feat: preview forks and rewinds with the boundary the fork will use (#2421)
* refactor(hub): resolve fork and rewind boundaries in one place

Move selectForkTranscriptPrefix into forkBoundary.ts as the single home
for fork and rewind boundary resolution. Fork execution keeps calling
the same function with identical behavior; the forkTranscript module
and its tests move with it, so the next boundary consumers (preview,
token validation) extend one resolver instead of forking the rules.

* feat(shared,hub): read-only fork preview with a boundary token

Add POST /sessions/:id/fork-preview: the hub resolves the preview mode
from the live session (a running Codex with a verified completed turn
previews through it), runs the same admission guards as confirm without
taking the history-action lock, and answers with the kept tail rows,
the excluded rows, counts, and a boundary token.

Confirm accepts the token back on fork and rewind. The public wrappers
re-check it right after the history-action lock: an epoch change, new
invoked rows, or a source that started running since the preview reject
with 409 boundary_moved so the caller re-previews instead of forking a
transcript it never saw. Clients that send no token keep the legacy
behavior, and a latestCompleted preview fails closed on runners that do
not advertise the forkPreview capability, because answering it from hub
rows is the drift this replaces.

* feat(cli): codex shared runtime answers and pins its fork boundary

Add the PreviewForkBoundary RPC: the shared runtime reads its native
history and answers where each fork mode cuts - latestCompleted through
latestCompletedForkCutoff, current through the last turn (falling back
to the completed cut once a turn runs), message through the projected
turn with the steered-cut clientId rule - and names the first excluded
hub row so the hub cuts its preview tail at the same place.

Confirm accepts a preview-pinned lastTurnId: the runtime re-verifies the
turn still exists with a completed native prefix and forks through that
fixed inclusive cutoff instead of re-deriving a moving one, so a turn
that starts between preview and confirm cannot drift the boundary. The
capability is advertised as conversationHistory.forkPreview.

* feat(web): fork preview dialog fed by the hub

Replace the web-side fork boundary mirror with the hub's preview
answer: useForkFlow asks POST /sessions/:id/fork-preview, renders the
returned kept tail and excluded boundary through the regular
normalize/reduce pipeline, and confirms by echoing the boundary token.
A 409 boundary_moved refreshes the preview in place and demands a
re-confirmation, a source that starts running while the dialog is open
re-answers through the hub, and an older hub (404) falls back to the
legacy confirm dialog. forkPreview.ts keeps only the compact text
shaping; its cut rules are gone. SessionChat and SessionList share the
flow, the MessageActions fork button invokes it directly under the
message-fork testid, and the dialog's confirm stays accessible as
Fork. en and zh-CN locales and the e2e fixture/spec come along.

* feat(web): rewind preview dialog

Route rewind through the same hub-fed preview: the MessageActions
rewind button opens the rewind variant of the fork preview dialog,
which emphasizes the region the source would delete (destructive
styling, struck-through rows, and a truncation count) before confirming
with the boundary token. The runner-side fork-safe ambiguity still
offers the fork-at-boundary fallback, an older hub falls back to the
legacy rewind confirm, and the inline rewind confirmation dialog is
removed now that the preview gates the destructive action.

* test(hub): align archive cleanup timeout status with the 503 semantics

* fix(hub): reject the fork preview when the transcript moves during the boundary call

* fix(web): surface fork preview failures in the chat with a connect-error retry

* test(e2e): pin the list fork menu and opencode affordances to the preview flow

* fix(cli): make shared Codex fork previews respect forkable boundaries

The message-mode preview answered boundaries the confirm would refuse: a
historical cut whose completed-turn prefix contains an unfinished turn
only failed after the user confirmed. PreviewForkBoundary now applies
ForkConversation's terminal-status rule on the assertBoundary snapshot it
already fetched, so both sides inspect one history state.

The latestCompleted preview could also name an empty-text userMessage as
the cut row, but the projection never emits a hub row for those, so the
hub resolved a boundary that does not exist and failed with 'Fork
boundary message not found'. firstExcludedUserLocalId now skips items
without hub-visible display text, sharing the projection's rule through
userMessageDisplayText.

* fix(hub): gate the fork preview on the archived-fork admission rules

The inactive-session preview branch answered a boundary without any of
the guards the confirm enforces in forkArchivedCodexSession: an archived
Claude or OpenCode session, a diverged history, queued messages, or an
offline Runner all rendered a preview dialog that could only fail on
confirm. The admission guards now live in assertArchivedForkEligible and
run in both paths.

A latestCompleted token is only minted for a running source, so a runner
exit before the confirm used to fail with the unactionable 'No verified
completed turn' answer instead of refreshing; boundaryMovedReason now
returns boundary_moved when the source went inactive, and the client
re-previews under the archived rules.

* fix(web): replace a stale fork preview with the error dialog and honor the thinking edge

A preview refresh that failed with a non-404 error left the previous
ForkPreviewDialog mounted, so the error dialog — gated on
errorMessage && !preview — never appeared and the stale boundary token
stayed confirmable. The non-404 catch now drops the stale preview first.

The thinking-edge effect also consumed an edge that landed while the
first preview request was still in flight: neither the state nor the
legacy request existed yet, so the stale idle-time answer opened the
dialog after the turn had already started. The in-flight request intent
is now tracked in a ref the effect can re-issue from, and an edge during
a confirm RPC no longer mutates the dialog behind the mutation.

* fix(web): keep the legacy fork confirm locked while the RPC is in flight

confirmLegacy awaited the fork/rewind RPC without any pending flag, and
all three legacy confirm dialogs bind isPending to the preview-loading
state, so the confirm button never showed its confirming label and both
buttons stayed enabled: a double click submitted the fork twice and the
dialog could be dismissed mid-request. A dedicated confirming state now
covers the legacy RPC in useForkFlow and drives the three dialogs.

* fix(web): align the fork error dialogs between the chat and the list

SessionList's error dialog ignored the retry affordance the chat already
had: connect-level preview failures showed only Dismiss with the buttons
unbound to any pending state. Both components now share the same dialog
contract: Retry for connect failures, Dismiss otherwise, one action and
no duplicate Cancel, and the pending state bound to the retry fetch.

The chat's error dialog also introduced every failure as a fork even
when the failed request came from openRewind; useForkFlow now records
the failing intent and the dialog titles itself accordingly. Finally,
HappyThread's historyActionPending was hardcoded false after the preview
flow replaced the direct fork callbacks, so per-message Fork/Rewind
buttons stayed enabled while a preview request was in flight and another
click would supersede it via requestSeq; the loading state now locks them
like the pre-preview flow locked them during its RPCs.

* fix(web): clean up the fork preview dialog's confirm error and rewind footer

A failed confirm quoted the raw ApiError message ('HTTP 409 Conflict:
{...}') inside the dialog while the rest of the flow extracts the hub's
error text; the dialog now shares useForkFlow's apiErrorText. The error
also survived a background view refresh, quoting a stale boundary under
the refreshed one, and a rewind whose excluded rows were all non-text
hid the deletion summary because the section was gated on excludedTurns
being non-empty even though counts.excluded was not zero.

* fix(hub): reject the fork preview when the CLI answers a resolved error envelope

RpcHandlerManager serializes a thrown handler error as a RESOLVED
{error} envelope, so previewForkBoundary's cast answered the preview
with undefined nativeTurnId/cutBeforeLocalId and the runtime failure
was silently swallowed. Unwrap the envelope and throw so the hub
surfaces the failure like any other preview error.

* fix(web): honor the flattened summary capability on the legacy fork fallback

SessionSummary flattens conversationHistory onto metadata while the
full hub Session nests it under metadata.capabilities; the legacy
confirm only read the nested shape, so a 404 fallback from the list
sent a plain current fork for a running session that supports the
latest-completed fork. Accept both shapes.

* fix(web): offer the fork fallback when the legacy rewind is fork-safe

The legacy rewind confirm dropped the ambiguous-native-boundary fork
fallback that the preview confirm and the pre-preview dialog had: a
409 ambiguous_native_boundary_fork_safe surfaced as a dialog error
instead of offering fork-at-boundary. Mirror the preview confirm's
handling on the legacy path.

* fix(hub): catch source active transitions between fork preview and confirm

The boundary token did not record the source's active state, so a
transition between preview and confirm bypassed boundary_moved: a
stopped runner sent the confirm into the archived-fork path (uncoded
admission failure for non-Codex sources, or an archived fork that
silently ignores the previewed live cut), and a reopened session ran
the live fork with a token minted on the archived path. The rewind and
non-Codex message confirms also failed as uncoded 'Session must be
active' / 'Session is busy' on thinking edges.

ForkBoundary now carries sourceActive and boundaryMovedReason rejects
the mismatch across all modes; the rewind and live non-Codex message
cases also reject a thinking edge. latestCompleted keeps its existing
runner-exit guard for tokens minted before this field existed.

* fix(web): keep the preview confirm locked against thinking edges mid-confirm

confirmLegacy set confirmingRef but confirmPreview did not, so a
thinking edge landing while the confirm RPC was in flight re-answered
the preview behind the confirm: the dialog's view was replaced (or
unmounted into the error dialog) under a pending confirm, and the
confirm then navigated over it or threw against a dead dialog. Lock
the confirm the same way the legacy path does, and release it before
the boundary_moved re-preview so the refresh behaves like any other
in-flight preview.

* fix(web): mark the fork boundary on a current preview that excludes a running turn

A shared Codex runtime answers mode 'current' with the last completed
turn while a turn is already running in the CLI (before the hub saw
thinking), so the preview carries an excluded running turn and confirm
pins lastTurnId. The dialog gated the fork-point marker and boundary
box on kind !== 'current' and showed the full-copy footer, hiding the
cut the confirm would apply. Show the boundary section whenever the
preview carries a cut and use the latest-completed footer for a current
preview with exclusions.

* fix(hub): refuse the fork preview when the confirm's pending-fork guards would

forkConversation rejects a confirm outright while a Codex resume is
unconfirmed or an archived-fork child binding is pending on an active
source, but forkPreview ran neither check and opened a dialog whose
confirm always failed. The archived message preview also answered
without the conversationHistoryTurns entry (or pending attempt) that
forkArchivedCodexSession resolves the native turn from. Mirror all
three guards on the fork preview paths; rewind keeps its own, since
the rewind confirm runs different guards.

* fix(cli): answer the idle fork preview with a pin the confirm would accept

The idle current-mode preview pinned the last native turn without
checking its terminal prefix, so a thread holding a non-terminal turn
previewed a 200 whose confirm always failed verifyPinnedTurn with 'The
pinned fork turn no longer has a completed native history prefix'.
Validate the pin before answering and omit it when invalid: preview and
confirm then agree on the unpinned whole-history cut. Message mode also
fetched the thread twice per preview (once up front, once inside
assertBoundary); the up-front read now lives only in the branches that
need it.

* test(hub): pin the rewind route's coded 409 boundary_moved contract

The rewind route tests never sent a boundary token, so the claim that
the route maps a moved rewind boundary to a coded 409 had no coverage.
Mirror the fork route test: the boundary reaches the engine and the
structured code is returned on a 409.

* fix(hub): let a boundary-token rewind confirm reach the engine when the source went inactive

The rewind route answered 409 session_inactive before the engine ran
whenever the source had stopped, so the confirm's sourceActive
re-check was unreachable over HTTP and a confirm after the runner
exited dead-ended instead of refreshing the preview. Every rewind
token is minted on an active source, so an inactive confirm is always
a moved boundary: parse the body first and skip requireActive only
when a token is present, mirroring the fork route. Token-less legacy
rewinds keep the session_inactive 409.

* fix(web): keep the fork preview confirm locked while a refresh replaces the view

A boundary_moved refresh leaves the previous preview mounted until the
fresh answer lands, and the confirm's await only covers the refresh it
started: when a thinking edge fires a second re-preview behind that
refresh, the dialog's local pending resets and Confirm becomes
clickable on a view that is about to be replaced, re-sending the stale
boundary for another refresh. Gate Confirm on the flow's loading state
alongside the pending flag, in both the chat and the list dialogs;
Cancel stays available since closing discards the in-flight refresh.

* fix(web): refuse legacy fork dialog dismissal while the confirm RPC is pending

The legacy confirm dialogs lost the old handlers' pending guard when
they moved onto ConfirmDialog: its Cancel button honors isPending, but
Escape and the dialog's close button reach onClose unconditionally, so
dismissing mid-RPC unmounted the flow while the fork or rewind kept
running, and a later failure had nowhere to surface. Guard the legacy
fork and rewind dismissals with !confirming in the list and the chat;
the preview-route dialog already guards dismissal through its own
pending state.

* fix(hub): refuse archived-fork preview for attached runtimes

* fix(codex): name the original hub message when a fork cut starts at a queued batch
2026-11-18 10:12:23 +08:00
a9e4d445cc feat(hub,web,cli): work-scoped liveness — derive in-progress tool work so autonomous rounds stop rendering as waiting (#2470)
* feat(hub,web,cli): work-scoped liveness — derive in-progress tool work so autonomous rounds stop rendering as waiting

thinking is round-scoped, not work-scoped: a session running an
autonomous loop between turns reports thinking=false while its tool
calls are still open, so the client renders "waiting" for hours. The
hub now sweeps open tool-call rows (getLiveToolWork) and marks the
session with derivedToolWork while any live call exists; the web
session list and status row render it as working. Stale
backgroundTaskCount values are cleared by the same sweep, and the
claude backend re-bumps thinking on autonomous-round assistant frames.

Ported from the fork line; the queued-thinking-grace refinement is
dropped here because that feature does not exist upstream.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* test(web): assert the ticker-era presence badge class, not animate-pulse

The low-rate ticker refactor (#2447) removed animate-pulse from the
presence badge; the derived-work test still expected it. data-presence
plus the badge background class is the visible contract now.

Co-Authored-By: Claude Code <noreply@anthropic.com>

---------

Co-authored-by: miuiadmin <miuiadmin@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-11-18 08:12:48 +08:00
24153c3d37 feat(web): show a fetching-latest pill during cached session re-entry (#2474)
* feat(web): show a fetching-latest pill during cached session re-entry

Re-entering a session whose message window is served from the
sessionStorage cache renders the stale rows first, then swaps in the
authoritative latest page once the background tail sync lands — with no
affordance in between (the skeleton only covers empty windows and the
older-messages pill is suppressed while isSyncingTail is true).

Expose the store's internal preferLatestOnActivation flag through
MessageWindowState / useMessages (isCatchingUpFromCache) and render a
top-center "Fetching latest messages…" pill over the stale rows while
the catch-up fetch is in flight. The flag is true only between cached
activation and the first tail-sync landing, so visibility tickers and
reconnect resyncs never flash it.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(test): restore dropped describe closers lost in the port splice

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>

* test: harden v29.36 gap-audit edges (pill failure path, deliver-now guards)

- message-window-store: cover the cached re-entry failure path — a
  rejected tail sync settles (no endless syncing state), surfaces a
  warning, and deliberately retains preferLatestOnActivation so the
  retry still prefers the authoritative latest page; a successful retry
  then closes the catch-up window.
- messageService.deliverQueuedMessageNow: cover the four previously
  untested guards — CLI in-flight dispatch, cancel-ack timeout, shared
  concurrent-client sessions, and indeterminate rows (owned by the
  retry affordance). All leave the row unchanged and never emit.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>

---------

Co-authored-by: HAPI <noreply@hapi.run>
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-11-18 08:12:01 +08:00
OverbakerandGitHub 1690f315fc fix(web,hub): compress web static assets and survive transient auth outages (#2473)
* fix(web,hub): compress web static assets and survive transient auth outages

* fix(web): isolate stale auth epochs and throttle SSE-closed retries
2026-11-18 08:10:48 +08:00
OverbakerandGitHub 7210399d1f perf(web): cap retained inactive windows with reload-safe storage pruning (#2479)
* perf(web): throttle message window persistence and cap retained inactive windows

* test(web): cover inactive message window LRU eviction and reload protection

* fix(web): preserve sync generations across eviction and skip storage parse under limit
2026-11-18 08:09:36 +08:00
f6d7238607 fix(shared): hide and report near-miss AGENT_NOTIFY_SUMMARY footers (#2481)
* fix(shared): hide and report near-miss AGENT_NOTIFY_SUMMARY footers

A turn whose final line attempts the machine footer but does not parse -
most often truncated before the closing brace - fails twice over: the
status is dropped, and because the strict matcher found nothing to strip,
the raw `AGENT_NOTIFY_SUMMARY {...` line is rendered to the reader. The
second half contradicts the product intent `e2e/notify-summary.spec.ts`
already asserts, and the first half is silent: `extractNotifySummary`
returns null with no log, so the only detector is a human noticing.

Introduce the near-miss notion: the last non-empty line is positionally
eligible to be a footer (the existing glued/indented rules, unchanged) but
yields no summary. On that condition:

- `stripNotifySummaryFooter` removes it, keeping any glued prose prefix
  exactly as it does for a valid footer. The machine line is addressed to
  the harness, not the reader, and a truncated one is no more readable
  than a valid one. `NotifySummaryText` now falls back to the stripped
  body instead of re-rendering raw text when there is no summary to show.
- `detectNotifySummaryNearMiss` classifies why it failed - unterminated
  JSON, trailing content, invalid JSON, not an object - and the work-graph
  ingest logs one warn naming the reason, so a broken emitter is greppable
  instead of invisible. Mid-stream snapshots are excluded: a footer still
  being written is incomplete by construction, not malformed. The log
  carries the payload *length*, not the payload, to keep agent output out
  of hub logs.

What is accepted as a *valid* footer is unchanged, and so is what is left
alone: whitespace-delimited prose mentions (`Example: AGENT_NOTIFY_SUMMARY
{...`), mid-body quotes, non-final footers, and a bare token with no
payload all still render as written.

Deliberately not included: repairing a truncated payload by appending the
missing brace. Truncation cuts content, not only syntax, so a repaired
footer would write a silently shortened summary into the append-only
work-graph ledger as though the agent had meant it. The near-miss reason
makes repair a small follow-up if a maintainer wants it.

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

Co-Authored-By: HAPI <noreply@hapi.run>

* fix(shared): keep quoted footer examples out of near-miss matching

Review catch: the near-miss path inherited the strict matcher's "glued"
eligibility, which treats any non-whitespace character before the token as
glue - including a backtick or quote. A final line such as

    Use `AGENT_NOTIFY_SUMMARY {"status":"done"}` at the end.

therefore matched, the closing backtick read as trailing content, and
stripping left only `Use ` + the opening backtick, deleting the example and
the explanation after it. The Codex commentary path strips before storage
rather than before display, so that text was lost, not merely hidden.

Near-miss matching now skips occurrences inside an inline-code span and
occurrences immediately preceded by a quoting or opening delimiter. The
strict matcher is deliberately left as it was: a payload that parses as an
object through end of line is its own evidence that the line is a real
footer, so a backtick-glued valid footer is almost certainly an agent that
forgot the newline. A near miss has no such evidence, so it has to be more
conservative about what it will delete.

Genuine glued footers are unaffected, including after an earlier inline-code
span on the same line (``Ran `bun test`.AGENT_NOTIFY_SUMMARY {...``), which
is covered by its own regression test alongside the preserved examples.

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

Co-Authored-By: HAPI <noreply@hapi.run>

* fix(shared): treat near-miss quoting as a span, not one character

Second review catch, same class as the first: the guard added in 3fbda1e7e
inspected the single character before the token, but quoting is a property
of the *span*. A final line such as

    The agent wrote "Done.AGENT_NOTIFY_SUMMARY {"status":"done"}" verbatim.

has ordinary prose punctuation immediately before the token, and the
backtick-parity check only counted backticks, so a double-quoted span read
as unquoted. The line was stripped to `The agent wrote "Done.`, and the same
variant existed for every quote style the local check did not enumerate -
`('Done.AGENT_NOTIFY_SUMMARY {...}')` among them.

Replace both checks with one span test: is the token inside an open quoting
or code span on this line? Symmetric delimiters (backtick, double quote,
single quote) are counted by parity, so a *closed* pair earlier on the line
(`He said "hello".AGENT_NOTIFY_SUMMARY {...`) does not grant immunity;
bracketing delimiters are counted by depth. An apostrophe inside a word is
not treated as a quote, or `didn't` would hide a real footer.

Angle brackets are deliberately absent: `a < b` is far more common in agent
prose than an angle-bracketed footer example, and treating `<` as an opener
would hide real footers. That narrows the previous commit's delimiter set by
one character, by choice.

The strict matcher remains untouched, for the same reason as before: a
payload that parses as an object through end of line is its own evidence of
a real footer.

Regression coverage for the quoted-glue variants, plus three over-correction
guards that pass on both sides of the change - a closed inline-code span, a
closed quote or bracket pair, and an in-word apostrophe must all still strip
a genuine glued footer. The Codex commentary path gets the same cases, since
that path strips before storage rather than before display.

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

Co-Authored-By: HAPI <noreply@hapi.run>

* fix(shared): strip a near miss only when its payload runs to end of line

Three review rounds found three quoting constructs the near-miss guard did
not know about - a single-backtick span, a double-quoted span with glued
prose inside it, a double-backtick run - and each fix enumerated one more
piece of syntax. That was not converging, and the reason is visible in the
classifier: *every* reported false positive is `trailing-content`.

    The agent wrote "Done.AGENT_NOTIFY_SUMMARY {…}" verbatim.   → trailing-content
    ('Done.AGENT_NOTIFY_SUMMARY {…}')                           → trailing-content
    Use `AGENT_NOTIFY_SUMMARY {…}` at the end.                  → trailing-content
    Use ``Done.AGENT_NOTIFY_SUMMARY {…}`` at the end.           → trailing-content
    See [Done.AGENT_NOTIFY_SUMMARY {…}] above.                  → trailing-content

while every shape this feature exists to catch is not:

    …,"summary":"ok     → unterminated-json      {bogus}    → invalid-json
    {"ver               → unterminated-json      not-json   → not-an-object

So stop enumerating quoting syntax and gate on the payload region instead:
strip a near miss only when it runs to the end of the line. Truncation
terminates the line by definition, so it always qualifies; a quoted example
always closes its delimiter *after* the payload, so it never does. One rule
replaces the whole guard - no quote characters, no backtick runs, no in-word
apostrophe case - and `shared/src/messages.ts` is ~40 lines shorter for it.

`trailing-content` stays classified and logged, so a genuinely stray-text
emitter is still greppable; it simply is not deleted. The cost is one odd
line on screen when an emitter really does append text after a complete
object - and the status was dropped for that shape anyway, since the strict
matcher rejects it too, so the change is purely cosmetic. The alternative is
deleting a reader's example and the prose around it, which the Codex
commentary path does before storage rather than before display. Showing a
strange line beats destroying text.

Every preservation test from the previous two rounds still passes, now for
this one reason rather than per-syntax guards, and the Codex commentary
suite keeps the quoted and double-backtick cases the review asked for.

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

Co-Authored-By: HAPI <noreply@hapi.run>

* fix(shared): only delete a near miss when no prose shares its line

Two review points, both about not destroying text.

**The log wording was wrong for the one reason that is no longer stripped.**
`[work-graph] ignored a malformed AGENT_NOTIFY_SUMMARY footer` is untrue of a
`trailing-content` line: a quoted example is correct prose, and it is kept and
shown rather than ignored. Someone grepping that string for lost statuses
would read an example as a dropped one. The message is now
`no AGENT_NOTIFY_SUMMARY status recorded from the final line`, which holds for
every reason, and `removedFromDisplay` carries which of the two outcomes
happened. The reason is still logged - an emitter that appends stray text
after a complete object is genuine signal, and suppressing it to quieten the
noise would trade the wrong way.

**A quoted example of an *incomplete* payload was still being deleted.**
``Use `AGENT_NOTIFY_SUMMARY {"summary":` to reproduce.`` classifies as
`unterminated-json`, so the end-of-line rule could not protect it: an
unterminated payload has no object end to measure against. This was a known
residual of that rule and should have been on the record when it landed.

The fix is a second structural condition rather than a return to parsing
quote syntax: **the token must own the line.** Nothing but whitespace may
precede it. That covers every quoting construct at once, including the ones
earlier rounds enumerated and the ones nobody has thought of, because what it
tests is the presence of prose rather than the shape of quotes.

A *valid* footer still tolerates glued prose - a payload that parses as an
object through end of line is its own evidence that the line is a real footer.
A near miss has no evidence, so it must be sure the line is machine output
before deleting it.

The cost, stated plainly: a truncated footer glued to prose on the same line
now stays visible. That is a real sub-case of the defect this PR fixes, and it
is given up deliberately. The status is lost either way - the strict matcher
rejects that shape too - so the cost is one odd line on screen, against the
risk of deleting a reader's example and the prose around it, which the Codex
commentary path does before storage rather than before display.

The four syntax guards from the previous rounds are replaced by this one rule
and their tests collapse into it, alongside a contrast test that a valid glued
footer is still stripped.

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

Co-Authored-By: HAPI <noreply@hapi.run>

* test(shared): pin why line ownership, not payload shape, decides the strip

A payload-shape predicate - "the remainder must be a well-formed JSON prefix
that runs to end of line" - looks like it should separate a truncated footer
from a quoted example, and it does for most shapes. It fails on an open
string, because an unterminated string swallows everything after it:

    Use `AGENT_NOTIFY_SUMMARY {"summary":"` to reproduce the failure.

the payload of which is byte-for-byte the shape of a real truncation
(`"summary":"ok`). The signature of the defect and the signature of the
false positive are the same, so no test of the payload can tell them apart -
which is why the decision is made from the line instead.

Pins that case so the next person to reach for a payload-shape rule finds the
counterexample already failing.

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

Co-Authored-By: HAPI <noreply@hapi.run>

---------

Co-authored-by: HAPI <noreply@hapi.run>
2026-11-18 08:08:40 +08:00
wushenghua 8338c17e4c feat(opencode): expose goal through live RPC like Codex 2026-11-18 05:29:00 +08:00
wushenghua 0aac531f67 fix(web): read legacy OpenCode goal events as rounds, not tokens 2026-11-18 05:00:00 +08:00
wushenghua 09495f779b feat(opencode): bridge native /goal command, status and round output 2026-11-18 03:37:42 +08:00
OverbakerandGitHub 430ad66ceb fix(web): keep chat pinned to tail when switching sessions (#2456)
* fix(web): keep chat pinned to tail when switching sessions

* fix(web): preserve tail following when upward gesture has no older history
2026-11-17 15:15:48 +08:00
68a0c4f1a5 feat(web): smooth low-rate indicator motion behind a setting (#2457)
* feat(web): smooth low-rate indicator motion behind a setting

The 8 Hz ticker trades animation smoothness for style-recalc
savings: a 22.5-degree rotation jump every 125 ms reads as a stepped
spinner, and a square opacity flip between 1 and 0.5 reads as harsh
blinking rather than breathing.

Keep the ticker and its perf win, but let the browser fill in the
frames: writers now also set a 125 ms transform/opacity transition
(compositor-only properties, no main-thread style recalc — the cost
the ticker was designed to avoid) and the pulse interpolates as a
triangle wave instead of a square one.

Users who prefer the strictest power saving can turn smoothing off in
Settings → Display → Sessions; the off path restores the exact #2447
cadence (square flips, stepped rotations). Writers re-read the flag
every tick, so the toggle takes effect on the next 125 ms step with no
React state.

* =test(web): adapt badge assertion to the smoothing triangle wave

---------

Co-authored-by: miuiadmin <miuiadmin@users.noreply.github.com>
2026-11-17 15:15:23 +08:00
weishu 75aa277aac feat(auth): sign in to native apps with a single passkey ceremony
Hub discovery required two authenticator prompts plus a confirm step:
a local locator-only ceremony to read the Hub from the user handle, then a
Hub-issued login challenge. Native apps now sign their own fresh challenge
{v:2, operation:"login", channel:"native", iat, nonce}, read the Hub from
the selected credential's v2 user handle, and post the assertion straight to
POST /api/passkey/login/verify.

- hub: accept native self-issued challenges only within
  [now-5min, now+1min] and only once (replay guard keyed on the challenge,
  claimed synchronously after verification); remove
  /api/passkey/login/options. Browser ceremonies keep Hub-issued challenges.
- shared: createPasskeyNativeLoginChallenge / parsePasskeyNativeLoginChallenge;
  drop discovery helpers.
- ios/android: one system sheet from the pairing screen; manual Hub entry
  for long-address handles or an explicit Hub, which must match the
  credential before anything is sent. Assertions are only posted to the Hub
  named by the credential.
- web: revert address-free discovery; the web app signs in to its own Hub.
- docs: native single-ceremony contract and its security trade-off.
2026-11-17 15:09:53 +08:00
dff2d99fd6 fix: align Stop with the official agent TUIs (#1992)
* fix(cli): preserve queued user input on plain Stop across flavors

Plain Stop must abort only the active runtime turn and keep unconsumed
queued messages (localIds/order/isolate/mode) for the next drain. Previously
the per-flavor Abort handlers unconditionally called queue.reset(), dropping
pending messages, and an idle loop could collect/ACK a batch that arrived
during abort teardown.

- MessageQueue2.waitForMessagesAndGetAsString checks the abort signal before
  both batch collections, so an in-flight Abort can never collect/ACK (and
  therefore never replay) a pending batch.
- Add a serialized Abort barrier in RemoteLauncherBase with an optional
  synchronous entry callback: onAbortEntry aborts the current signal so an
  idle waiter fails closed, and waitForAbortBarrier holds the loop's next
  dequeue until teardown completes. A rejection during teardown no longer
  spins the loop with a stale aborted signal; it is boxed and propagated to
  the Abort RPC caller, the run loop, and clearAbortHandlers lifecycle.
- Launcher handleAbort resets the queue only on terminal cleanup
  (shouldExit/leavingRemote). BaseLocalLauncher Abort (switch to remote)
  preserves the shared queue. Cursor ACP soft-steer drain handles an already
  aborted signal without deadlock.
- Codex shared root Abort stays a pure turn/interrupt; native queue retained
  (control regression only, no resume-policy change).

Tests: Launcher-level Abort preservation (active/idle/concurrent/rejection),
enqueue-during-cancel, MessageQueue2 idle wake-then-abort and post-await
guard, base-local queue preservation, Codex abort/native-queue control.
Verified with Node22 (.sbx/node22) - full cli suite green; see
.sbx/REPORT.md.

* fix(web): settle Stop state with the abort request

* test(web): cover Stop request settlement without an idle render

* feat(cli): batch compatible Codex queued input

* fix(codex): preserve batch recovery and fork boundaries

* test(cli): cover idle and overlapping Stop teardown

Keep queued input unacknowledged while an idle Stop or a later Stop is still tearing down. Gate cancellation acknowledgements independently from prompt completion to exercise both ordering races.

* fix(codex): keep queue preflight failures retryable

Persist a retryable state during the read-only tail lookup, then journal uncertainty with the native mutation. Preserve released native edits and avoid replay when acceptance arrives during preflight.

* fix(cli): honor exit requests after abort teardown

* test(cli): cover terminal handoff during overlapping stops

* fix(codex): retain uncertain batch append ownership

* fix(dsh): stop queued dispatch during process cleanup

* fix(dsh): stop idle queue waits before process cleanup

* fix(codex): preserve removal intents across native edits

* test(codex): resolve native batch inputs in full-stack checks

* test(copilot): stub session metadata on the abort test client

The ACP session title sync now reads client.getMetadata() when a launcher is
created, so the abort test client needs a getMetadata stub next to its existing
updateMetadata stub. Without it every case built on createAbortSession fails
with "client.getMetadata is not a function".

* fix(opencode): keep the dequeue signal usable after a Stop that only abandons round metadata

The abort barrier aborts the dequeue signal when a Stop arrives so an idle wait
wakes up. A plain Stop during the post-prompt round-summary settle phase only
abandons metadata and returns before performAbort, which is what replaces the
controller. The loop then re-read the aborted signal in a tight microtask loop
and never reached the queued input, pinning a CPU. Recycle the controller on
that early return so the queued input is dequeued on the next iteration.

* fix(cli): keep launchers running when a native cancel is rejected

The abort barrier aborts the dequeue signal when a Stop arrives and, when the
teardown rejected, boxed the failure so the run loop threw it at the next
dequeue. Every launcher that uses the barrier therefore stopped surviving a
rejected native cancel, which it did before the barrier: a rejected cancel left
the controller untouched and only the Abort caller saw the error.

setupAbortHandlers now takes an onAbortRejected callback next to onAbortEntry.
On a teardown rejection the base restores the dequeue signal through it and
rethrows to the Abort RPC caller only; the boxed failure is gone. Each launcher
passes a one-line callback that replaces the controller only when it was
aborted. Queue preservation and the barrier's ordering are unchanged.

* fix(codex): restore the applied batch version after definite rejections

A definite native rejection left the rejected proposal in versions and
rolled batch.current back positionally (length - 2), so a second
consecutive rejection selected the earlier rejected proposal instead of
the applied version; the stale current survived reconciliation and a
later member cancel could submit rejected content for execution.

Capture batch.current before each append and restore that saved index
on definite rejection across nativeUpdate, extendBatch,
cancelBatchMember and steerBatchMember.

Covered by failing-first regression tests: consecutive rejected appends
followed by a member cancel, and consecutive rejected native edits.
See tiann/hapi#1992 review discussion.

* fix(hub): align archive cleanup status assertion with the 503 mapping

tiann/hapi#2423 changed ArchiveCleanupError to return 503 instead of 504
(Cloudflare Tunnel replaces 502/504 bodies; the code field distinguishes
timeouts) and updated one assertion, but the overlapping-archive
singleflight test still expected 504, which the 409 | 503 status union
can never produce.

* fix(opencode): preserve queued input on a plain Stop

tiann/hapi#1992 promises pending input survives a plain Abort on the
queue-backed launchers. Upstream #2424's performAbort reset the queue
unconditionally, dropping not-yet-dispatched input on a plain Stop. Reset
only when leaving the session (switch/exit), and let a terminal request
joining an in-flight plain Stop promote its cleanup intent onto the
operation so the reset still lands exactly once, after the shared
cancellation restore drain.

* fix(opencode): terminal drain ordering, dequeue fence, teardown escalation

Hydrogen pre-review of the preserve-on-plain-Stop round surfaced six
defects in the Stop/terminal paths, all adjudicated valid, and its
re-review surfaced three more:

- A direct switch/exit reset the queue before the v2 cancellation drain,
  so a proven-cancelled steer restored back into the queue after the
  reset and a switch bounced straight back into remote mode. Run the
  terminal reset after the drain, where a terminal joining a plain Stop
  already applied its promoted reset.
- The dequeue loop could dequeue, ACK, and then drop a preserved row on
  the prompt-prep aborted-continue while a plain Stop was still awaiting
  its native cancellation. Park the dequeue on the runtime gate's
  cancellation-idle fence and refuse beforeDequeue while a cancellation
  drain is in flight.
- restoreQueuedReservation ignored shouldExit, re-admitting a steer
  parked before its v2Steers entry after the terminal reset. Leaving
  remote never re-admits.
- performAbort's finally escalated every steer to 'teardown' when the
  teardown threw, stranding a proven-cancelled steer indeterminate on a
  plain Stop that keeps running. Escalate only when leaving remote.
- A terminal joining a plain Stop lost its promoted cleanup intent when
  the owner's performAbort rejected: the queue kept its rows and an idle
  dequeue waiter was never woken. Run the reset and the abort in the
  rejection handler.
- dispatchV2Steer removed its entry only after awaiting the restore, so
  a Stop landing mid-restore ran a second concurrent restore whose
  failed restoreReservation falsely reported the row indeterminate.
  Detach the entry before the restore.
- A plain Stop landing between the dequeue and the prompt (model/effort
  setup, round snapshot, or the native history read) still dropped the
  already-dequeued, hub-ACKed batch on the pre-dispatch bail-outs.
  Requeue the batch there in its original order with each localId
  intact, and echo it at the dispatch commit point so the retry does
  not double-echo; compact keeps its early echo.
- restoreQueuedReservation's leaving-remote path returned false without
  undoing its work: the steer stayed stuck 'dispatching' in the shared
  queue (Cancel answered 'in-flight' forever) and the hub stamp never
  reverted. Persist 'queued' and release the held reservation instead.
- The v1 terminal path had no rejection cleanup: a performAbort(true)
  that threw left the queue unreset and the dequeue signal un-aborted,
  parking the idle loop forever. Mirror the v2 rejection cleanup.

* fix(cli): preserve queued input across pre-prompt Stops in every queue-backed launcher

The whole-PR review surfaced the OpenCode preserve class defect in every
other queue-backed launcher, plus teardown and batching gaps:

- dsh, cursor ACP, copilot, grok and kimi dequeued and hub-ACKed a batch
  and then dropped or dispatched it when a plain Stop landed during the
  pre-prompt setup awaits. Requeue the batch at every pre-dispatch
  bail-out (requeue never fires for terminal switch/exit, whose reset
  already cleared the queue) and defer the cursor ACP hub ACK and user
  echo to the dispatch commit point so a retry never double-ACKs or
  double-echoes. The shared requeue lives in MessageQueue2.unshiftBatch;
  OpenCode's helper delegates to it.
- cursor ACP requeued into the shared queue without a shouldExit check,
  bouncing a switch straight back into remote mode, and its soft-steer
  restoreQueuedReservation re-admitted a 'dispatching' steer after the
  terminal reset. Guard the requeues and release the steer the same way
  OpenCode does: persist 'queued' and release the held reservation.
- A rejected handleAbort(true) skipped the queue reset everywhere and
  the dequeue-signal abort outside DSH, parking an idle runMainLoop
  forever. requestExit now invokes an onTerminalTeardownRejected hook on
  rejection; copilot, grok, kimi and cursor ACP override it with their
  reset+abort, OpenCode and DSH are no-ops (their teardowns guarantee
  the cleanup on every path), and DSH moves its reset into a finally so
  a rejected cancel cannot skip it.
- runAbortUnderBarrier overwrote an in-flight abort barrier instead of
  chaining onto it, letting dsh kill() unblock the loop's dequeue while
  an earlier plain-Stop teardown was still running. The release now
  chains onto the prior barrier.
- codex/shared/root captured the message batch key from this.settings at
  callback arrival, merging queued messages across a settings-changing
  slash command and splitting around cold-start hydration. The key is
  now computed inside the work continuation, after bound and after
  earlier queued commands ran.

* fix(cli): keep origin-indeterminate steers resolvable and skip dead prep on Stop

The round-4 confirm review surfaced three residual steer/teardown gaps:

- restoreQueuedReservation's terminal-exit branch deleted an
  origin-indeterminate reservation and left the hub steerDeliveryState
  stuck at 'dispatching'. An origin-indeterminate row cannot be honestly
  reverted to 'queued': stamp 'indeterminate', emit it, and keep the
  reservation for explicit Cancel/Retry in local mode (opencode and the
  same newly added cursor ACP branch).
- restoreQueuedReservation now returns 'restored' | 'dropped' |
  'indeterminate' so dispatchV2Steer can tell a clean terminal drop from
  an unknown outcome: the rejected-admission branch reports 'Active turn
  changed' instead of a false 'Steer state is indeterminate', and the
  stop-cancellation path treats the drop as definitive removal.
- A plain Stop landing during the inline setModel/setConfigOption awaits
  no longer runs captureOpencodeRoundSnapshot or toggles
  thinking/steeringActive for a prompt that never starts; the already-
  dequeued batch requeues before the round-snapshot setup.

* test(cursor): cover legacy queue preservation across Stop and terminal exits

The PR changed cursorLegacyRemoteLauncher's abort handling (+10: the
leavingRemote queue reset and the rejected-cancel signal restore) without
any behavioral test. Mirror the Cursor ACP coverage: a plain Stop during
an in-flight turn keeps the queued row and drains it after the Stop
settles, a terminal switch/exit resets the queue exactly once with no
further dispatch, and a Stop landing during the dequeue wait preserves
the not-yet-dequeued row. The launcher already behaved correctly on all
three paths; the tests guard them.

* fix(launchers): close abort-window races across teardown and pre-dispatch setup

Four launcher loops (cursorAcp, copilot, grok, kimi) plus dsh and
opencode kept a live dequeue signal and a dequeue-time hub ACK across
their pre-prompt setup awaits, so a batch arriving behind a terminal
switch/exit teardown was dequeued, stamped invoked at the hub, run
through ACP model/mode mutations, and dropped unprompted; and an abort
that landed mid-setup could be erased by a later state reset and still
dispatch the canceled turn.

cursorAcp
- single userAbortRequested reset per turn window: an abort that lands
  during model/mode setup survives to the pre-dispatch gates
- hub ACK moved to the dispatch commit point, after every pre-dispatch
  bail-out: an aborted batch is never stamped invoked nor dropped with
  a false ready
- new requeueAbortedBatch helper: abort-path requeues carry only user
  content, so a Stop-canceled model-error-bridge item is dropped
  instead of resurrecting after the Stop settles
- durable Bridge mutations (user-turn supersede, replay-gate persist)
  deferred to the dispatch commit point with post-persist abort/exit
  guards; guard added after the harness-resume buffer discard
- soft-steer restoreQueuedReservation re-checks shouldExit after the
  'queued' persist and releases the held reservation instead of
  restoring it into the queue, which would bounce a terminal switch
  straight back into remote mode; 'Active turn changed' when the turn
  changed during the restore
- handleAbort aborts and replaces the dequeue signal at entry when
  leavingRemote, unparking the wait before the teardown's own awaits
- lastUserMessage recorded at the dispatch commit point

copilot/grok/kimi
- handleAbort entry abort-and-replace when leavingRemote
- shouldExit break right after the dequeue resolves, before any state
  mutation
- hub ACK deferred to the dispatch commit point
- intermediate shouldExit/aborted checks after each setup await;
  isClosed guards on every unshiftBatch
- grok: thinking deferred to the commit point, history busy kept early

dsh
- hub ACK deferred to the dispatch commit point
- a failed top-of-loop reconnect requeues the un-ACKed batch when a
  plain Stop landed inside it; isClosed guards on every unshiftBatch
- generation checks after the model/effort switch awaits; thinking
  deferred to the commit point
- kill() batch drop emits the sibling idle 'ready' signal

opencode
- display-mode state applied below the pre-snapshot Stop/exit check

Each loop change is covered by a behavioral regression test that fails
against the pre-fix dequeue-time ACK / live-signal teardown behavior.

* fix(launchers): close bridge supersede, cancel-window, and teardown races

- cursorAcp: markModelErrorSupersededByUserTurn now drops the pending
  bridge row, and the replay gate fails closed once superseded, so a
  manual Bridge enqueued mid-setup can no longer replay after the user
  turn that superseded it
- cursorAcp/dsh: a batch resolved while the terminal teardown flips
  shouldExit breaks before reconnect or mode/model setup instead of
  mutating ACP state on a closing backend
- MessageQueue2: cancelByLocalId answers 'in-flight' for dequeued-but-
  uncommitted localIds, closing the deferred-ACK window where a cancel
  could double-deliver a message or deliver one after an explicit
  cancel
- MessageQueue2: unshift forwards internal provenance; unshiftBatch and
  the cursorAcp requeue helper keep it on non-isolated requeues
- dsh: a plain Stop racing a failed acpSessionEnded restart requeues
  the dequeued batch instead of dropping it in the recovery catch, and
  the null-model switch path gains the same abort-generation guard as
  its sibling branch
- copilot/kimi: the switched model's effort baseline is captured before
  the plain-Stop bail so the requeued turn takes the new baseline
- tests: failing-first regression tests for each sequence; grok/kimi
  requeue tests drop unused spies, fix stale deferred-ACK comments, and
  assert the commit-time ACK exactly once

* fix(cli): scope in-flight cancel tracking to deferred-ACK launchers

* fix(opencode): commit hub consumption only when the prompt is dispatched

* fix(codex): persist batch uncertainty after an unconfirmed shrink

* fix(codex): journal batch uncertainty before dispatching a shrink

* fix(codex): journal batch uncertainty before every native batch write

Every native RPC that can change the content or existence of a batch's
queued submission now persists the batch as unknown, together with the
proposal that motivated it, before it is dispatched. Only a confirmed
response or a definite rejection settles the batch back, and that
transition is persisted.

Previously the whole native edit (nativeUpdate), the append edit
(extendBatch), the restoration after a rejected steer and the suspend
delete left the batch queued while an unconfirmed proposal was current.
A crash before the edit applied, followed by canceling a member, could
then delete or rewrite the native submission from a version it never held
and silently drop sibling input.

---------

Co-authored-by: sbx <sbx@agent-sandbox.invalid>
2026-11-17 14:58:11 +08:00
weishu c63dc4e043 feat(auth): discover Hub from passkeys across web and native 2026-11-17 13:09:07 +08:00
KiyoshiandGitHub 4d1a12b5a3 feat: branch a conversation at a user turn with harness and model selection (#2247) 2026-11-17 12:06:26 +08:00
weishu ee3d7eed4c feat(auth): share passkeys across web and native apps
Use auth.hapi.run as the shared RP with an isolated static browser bridge, Hub-bound challenges and accounts, and one-time PKCE code exchange.

Update iOS and Android validation, app associations, deployment documentation, and bidirectional browser regression coverage.
2026-11-17 11:39:01 +08:00
437469442a feat(web): preview HTML files in a sandboxed iframe (#2453)
* feat(web): preview HTML files in a sandboxed iframe

.html/.htm files get the same Source / Preview toggle as Markdown. The
preview renders in an iframe with sandbox="allow-scripts" (no
allow-same-origin), so page scripts run in an opaque origin and cannot
read HAPI's storage, cookies or parent window, open popups, or navigate
the top page.

Relative assets are inlined through the existing session file API so
typical multi-file pages render: <link rel=stylesheet> (.css), <script
src> (.js/.mjs), images, and fonts/images referenced via CSS url(). To
keep secrets out of the preview, only the HTML file's own directory
subtree is reachable, dot files/directories are refused, and each
reference kind only reads its own web-asset file types. Inlining is
capped (64 assets, 12 MB, 4 MB per file); anything beyond stays as-is.

The preview can also go fullscreen or open in a new tab; the tab is an
inert shell that hosts the same sandboxed iframe.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(web): harden HTML preview asset inlining

- Refuse assets reached through a symlink. The file read API only checks
  that the real path stays inside the workspace, so a link such as
  `style.css -> ../.env` bypassed the preview's directory, dot-file and
  type limits. Each path component below the HTML file's directory must be
  listed as a plain directory/file (listings report symlinks as `other`).
- Keep inlined scripts external via a data: URL src instead of inline text,
  so `defer` / `async` scheduling is preserved.
- Resolve stylesheet url() relative to the stylesheet but bound it by the
  HTML file's directory, so `css/main.css` can use `../fonts/a.woff2`.

Addresses review feedback on #2453.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(web): keep URL fragments on inlined preview assets

url("sprite.svg#icon-view") and <img src="x.svg#frag"> lost their
fragment when replaced by a data URL, so SVG named views rendered the
default view. Append the original fragment to the generated data URL in
both CSS url() and markup replacements.

Addresses review feedback on #2453.

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

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: HAPI <noreply@hapi.run>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:06:58 +08:00
Haoyuan WangandGitHub 02d1bf15b8 feat(web): show plan quota next to the composer context meter (#2452) 2026-11-17 07:27:31 +08:00
Junmo KimandGitHub 47b3fb6b7d perf(web): drive session-list activity indicators from one low-rate ticker (#2447)
* perf(web): drive session-list activity indicators from one low-rate ticker

* fix(web): keep one reduced-motion query for the ticker's lifetime

* fix(web): keep the model-error halo pulsing on the low-rate ticker

* fix(web): start each ping subscription at its own first frame
2026-11-16 19:51:31 +08:00
Ethan WangandGitHub 21e3dae860 fix(web): prevent translated confirmation submit buttons from crashing (#2448) 2026-11-16 19:51:01 +08:00
weishuandHAPI 6cd6d375c0 fix(jobs): stop waking busy agents and gate session jobs to long work
Job wakes interrupted running turns: `deliverJobTerminalWake` only
special-cased inactive sessions, so an opted-in terminal job posted a
user message into whatever the agent was doing. Drop the wake when a
turn is running and settle the claim so a later idle flip cannot re-fire.

Those wakes also impersonated operator input — `sentFrom: 'webapp'`, a
bare user message with a "Verify the outcome and continue" imperative.
Tag them `hapi-system` and render them as a quiet status line in the web
chat instead of a user bubble with fork/retry actions. Drop the default
imperative; a prescription now has to come from `--wake-prompt`.

Agents attached jobs to short work (tests, builds, typechecks) because
the injected prompt was 2.1k chars of REQUIRED / MUST / FORBIDDEN. Replace
it with a decision rule: default is not to attach, never for work that
finishes in this turn, and run `hapi job --help` for the mechanics.

Co-Authored-By: HAPI <noreply@hapi.run>
2026-11-16 19:05:38 +08:00
weishu 809967b7c6 feat: sign in to the web app with passkeys
Add WebAuthn passkeys as another way to obtain a web JWT, so the browser
no longer has to keep CLI_API_TOKEN after the first sign-in.

- hub: passkey_credentials table (schema v36), register/list/delete
  routes behind the JWT, unauthenticated login routes with one-time
  challenges, and a 30-day passkey session exchanged via POST /api/auth.
  Passkeys are bound to the registering namespace, the browser origin
  (same host or an explicit CORS origin; HTTPS or localhost), and an
  HMAC fingerprint of CLI_API_TOKEN, so rotating the token revokes them.
- web: "Sign in with a passkey" on the login screen, Settings → Passkeys,
  passkey auth source with silent JWT refresh, en/zh-CN/ru strings.
- docs: client contract, hub README, PWA guide.
2026-11-16 16:48:05 +08:00
Junmo KimandGitHub b9a2869f4e fix(web): collapse the Codex question note field until it is needed (#2446) 2026-11-16 06:57:36 +08:00
Junmo KimandGitHub 020b74bc95 test(web): locate the unread row the way collapsed groups now render it (#2445) 2026-11-15 20:57:37 +08:00
SSU-WEI HUANGandGitHub 6c38c50f1b fix(web): keep unread rows mounted when a collapsed project group is toggled (#2434)
* fix(web): keep unread rows mounted when a collapsed project group is toggled

A collapsed group drew its unread rows in a separate peek list and the
expanded group drew every row inside its CollapsiblePanel, so toggling the
group remounted those rows: on expand they faded in from opacity 0 and their
icon and spinner restarted; on collapse they showed twice while the panel
closed.

Render each group's rows once, each in its own CollapsiblePanel that is open
while the group is expanded or the row is a kept unread row. Toggling the
group now only folds the other rows. Spacing moves inside the panels so
folded rows take no room.

Fixes #2433

* test(e2e): count expanded project groups by header, not by open panels

Rows now have their own collapsible panels, so open panels no longer map
one-to-one to expanded groups.
2026-11-15 17:32:40 +08:00
Junmo KimandGitHub 6237e90b37 feat: import local sessions through one registry (Pi, OpenCode, Codex, Claude) (#2435) 2026-11-15 17:06:21 +08:00
Junmo KimandGitHub ef20ef8cc2 fix(web): keep keyboard unpin focus when the row reappears as an unread preview (#2443) 2026-11-15 17:05:44 +08:00
Junmo KimandGitHub 2d0c8a7695 fix(opencode): show each OpenCode v2 model's real effort options, with one Default (#2439)
* fix(web): drop provider-default entry from dynamic reasoning effort options

* fix(cli): support OpenCode v2 /api/model variant lookup and Basic auth
2026-11-15 08:00:10 +08:00
9e85428913 test(web): use jsdom Web Storage under Node 25+ (#2438)
Node 25+ exposes its own localStorage/sessionStorage globals, which shadow
jsdom's in the Vitest environment. Tests that spy on Storage.prototype or
pass localStorage to StorageEvent then fail (5 tests in markdown-a and
sessionLastSeen). Bind both globals to the jsdom window's storage instead of
the memory fallback that only kicked in when methods were missing.

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

Co-authored-by: HAPI <noreply@hapi.run>
2026-11-15 07:59:57 +08:00
Junmo KimandGitHub c180dd2544 feat(web): unpin a session from the list on hover (#2440)
* feat(web): unpin a session from the list on hover

* fix(web): preserve focus when unpinning into a collapsed project

* fix(web): reserve width for visible row quick actions

* fix(web): harden keyboard-only unpin focus handoff and simplify reveal logic
2026-11-15 07:59:43 +08:00
9435b9aac2 feat(web): export and import browser settings (#2442)
* feat(web): export and import browser settings from Settings → About

Browser-local settings (theme, display, chat, voice, machine labels, ...)
can now be exported to a JSON file and imported in another browser.
Only an explicit allowlist (SETTINGS_STORAGE_KEYS) moves; credentials,
hub URL, drafts, UI state and trust grants never do. Import replaces the
allowlisted keys and reloads so every hook re-reads its value.

A test scans web/src and shared/src storage code and fails on any hapi*
key that is not classified as a setting or not, so new keys get decided
by whoever adds them.

Closes #2441

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

Co-Authored-By: HAPI <noreply@hapi.run>

* fix(web): reject malformed settings files and carry legacy fallback keys

Addresses Swear Review on #2442: reject array settings and unknown
versions before touching storage, and move legacy keys that settings
still fall back to (tool-card display, active-only list filter,
ElevenLabs voice) along with them. The session-list status filter is a
Display setting, so it and unread-only are now settings too.

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

Co-Authored-By: HAPI <noreply@hapi.run>

---------

Co-authored-by: HAPI <noreply@hapi.run>
2026-11-15 07:59:17 +08:00
AnanovoandGitHub d27e276a65 fix(web): show background-only work as a static blue dot (#2412) 2026-11-14 20:13:42 +08:00
OverbakerandGitHub 30835911fb feat(uploads): stream large session attachments via chunked uploads (#2429) 2026-11-14 07:48:04 +08:00
AnanovoandGitHub 58c9e80d85 feat(web): add include and exclude session search modes (#1801)
* feat(web): add include and exclude session search modes

* fix(web): restore focus after session search mode changes

* fix(web): keep session search popovers exclusive

* refactor(web): share session search mode matching

* fix(web): keep session search date-free
2026-11-13 18:51:15 +08:00
f0ab4ba79d feat(cursor): detect inline model errors, surface, notify, and bridge (#878) (#987)
Cursor ACP sessions can fail mid-turn with a transient model error that the
agent reports inline rather than as an RPC rejection. HAPI treated those turns
as successful, so the session went quiet with no banner, no push, and no way to
resume without retyping the prompt.

This adds the full path:

- detect: classify inline/stderr model errors from the Cursor ACP stream,
  requiring strong signatures before typing a failure as a model error
- surface: persist `lastModelError` on session metadata; render a chat banner
  and a session-list indicator, with the prompt text kept out of list/SSE
  summaries so they never ship up to 32 KB of user prompt
- notify: deliver a push for an unacknowledged error, watermarked on the hub
  copy so a restart does not re-page the same eventId
- bridge & retry: offer a one-shot recovery prompt that replays the failed
  turn, bound to the originating eventId and gated so a real user turn always
  supersedes it. Auto-bridge is opt-in and defaults to OFF, persisted in hub
  settings and fanned out to live Cursor CLIs.

Re-cut onto current upstream/main. The branch had accumulated 108 iterative
hardening commits against a 289-commit-older base; replaying them individually
would have re-resolved the same conflicts ~100 times. The pre-re-cut tip was
2c28a1365 if the granular history is ever needed.

Absorbing upstream required adapting to three refactors that landed meanwhile:

- `MessageQueue2` grew an `internal?: boolean` control-message flag upstream
  while this branch added richer `internal` provenance. Unified on a tagged
  `QueueItemInternal` union (`control` | `model-error-bridge`) so one field
  carries one concept. `hasPendingNonBridgeTurn()` now treats *any* internal
  item as non-user: otherwise a queued `/auto-review` control slash would have
  counted as a user turn and wrongly superseded a live bridge.
- `AcpSdkBackend.prompt()` gained a `timing` callback upstream; merged it with
  this branch's `shouldSend` gate into a single options object.
- The hub settings route moved to a unified `updateSettings` transaction.
  `autoBridgeTransientModelErrors` is applied outside that transaction because
  SyncEngine owns its CLI fan-out and rollback under its own lock.

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

Co-authored-by: HAPI <noreply@hapi.run>
2026-11-13 18:50:09 +08:00
AnanovoandGitHub 6f959bbb00 fix(web): hide redundant machine labels on single-machine pinned rows (#1414)
* fix(web): hide redundant machine label on pinned rows

* fix(web): hide machine labels for filtered pinned rows

* fix(web): hide redundant machine label on pinned rows

* fix(web): hide machine labels for filtered pinned rows

* fix(web): hide machine labels on global pinned sessions
2026-11-13 18:49:20 +08:00
AnanovoandGitHub d832165073 fix(web): reuse existing PWA window for notification clicks (#1616)
* fix(web): reuse existing PWA window for notifications

* fix(web): restrict notification reuse to PWA scope

* fix(web): resolve notification routes within PWA scope

* fix(web): respect PWA subpath in router

* fix(web): always deliver notification routes to SPA
2026-11-13 18:48:57 +08:00
AnanovoandGitHub decbd58bb4 feat(web): add Alt+S shortcut to send messages (#1658)
* feat(web): add Alt+S send shortcut

* chore: retrigger PR checks

* fix(web): preserve printable Option characters for Alt+S

* fix(web): support logical Alt+S across layouts

* test(web): cover Alt+S during IME composition
2026-11-13 18:48:42 +08:00