Commit Graph
11269 Commits
Author SHA1 Message Date
Neil 9ed7b45fe7 fix(editor): harden Markdown scanners and fixtures 2026-09-18 16:43:15 -07:00
Neil 3ad7b36afb fix(editor): bound markdown table column padding 2026-09-18 03:21:21 -07:00
Neil 95b121cac2 fix(editor): handle tilde fences in ordered items 2026-09-18 02:40:51 -07:00
Neil bf8c14df78 fix(editor): stabilize fenced code in ordered lists 2026-09-18 02:36:00 -07:00
Neil ce8f93cb56 fix(editor): preserve zero-start ordered lists 2026-09-18 02:04:20 -07:00
Neil ba7e4dc85b fix(editor): preserve prose markdown entities 2026-09-18 01:56:06 -07:00
Neil 45fcfef994 fix(editor): preserve ordered list continuation columns 2026-09-18 01:42:46 -07:00
Neil 150f834fe6 fix(editor): satisfy code span serializer type checks 2026-09-18 01:32:20 -07:00
Neil 549e93cb26 fix(editor): preserve inline code span padding 2026-09-18 01:30:28 -07:00
Neil 3dd62ec141 Revert "fix(editor): keep emphasis outside a code span on serialize"
This reverts commit 22eda4ba82.
2026-09-18 01:25:22 -07:00
Frederic Barthelemy 22eda4ba82 fix(editor): keep emphasis outside a code span on serialize
Bold wrapping a code span came back inverted: ``**`B93934206`**``
serialized to `` `**B93934206**` ``, turning bold text into literal
asterisks.

ProseMirror ranks a text node's marks by schema order, which Tiptap
derives from extension priority, so the parser's correct order was
renormalized. Raise code above emphasis; link stays below code so
linked code labels keep serializing.
2026-09-18 01:25:01 -07:00
Frederic Barthelemy b22fc02610 fix(editor): require non-space delimiters for inline math
The upstream tokenizer matched `$([^$]+)$` with no delimiter rule, so a
second dollar sign anywhere in the paragraph turned prose into a math
span: `Costs are US$ 5,000 and R$ 40,000` lost the space after `US$`.

Require a non-space next to each delimiter and forbid a newline inside,
matching the common dialect. Real math still parses.
2026-09-18 01:22:20 -07:00
Neil fd1c8847bb fix(editor): preserve bare details source tags 2026-09-18 01:14:06 -07:00
Frederic Barthelemy 80a4d0660f fix(editor): preserve the legacy details styling class on round trip
A file saved by an earlier Orca version carries class="orca-details"
in its markdown source. The prior commit stopped the serializer from
ever writing that class, which also stopped it from preserving one a
source already had, so re-saving such a file dropped the class and
the round-trip eligibility check then failed to recognize the file as
its own, regressing it back to Source mode. The details node now
carries a flag set only when its source opening tag had the class, and
the serializer re-emits the class only when that flag is set.
2026-09-18 00:58:57 -07:00
Frederic Barthelemy 68cf9ea08a fix(editor): keep rich mode for documents with details blocks
The markdown serializer always injected class="orca-details" into
saved <details> tags. The rich-mode round-trip check compares the
serialized output against the source's literal opening tag, so any
user-authored <details> without that class failed the comparison and
fell back to Source mode, making the details extension unreachable
from a file. The class is already applied to the rendered DOM node
independently, so the serializer no longer needs to write it into the
markdown source.
2026-09-18 00:58:47 -07:00
Neil be766569bd fix(editor): validate reference syntax tree nodes safely 2026-09-18 00:55:38 -07:00
Neil 1735bcb1b1 fix(editor): classify reference syntax outside HTML comments 2026-09-18 00:53:44 -07:00
Frederic Barthelemy 5f636c1a93 fix(editor): make the reference-link pre-filter linear-time
The nested (?:[ >]*(...)?)* quantifier let a long run of leading
spaces or > with no closing [ trigger catastrophic backtracking,
freezing the renderer on any document with such a line. Replace it
with a single non-nested character class, which is linear and safe
to over-admit since the parser confirms every candidate.
2026-09-18 00:49:32 -07:00
Frederic Barthelemy 0c7661700b fix(editor): cap the reference-link definition parse like the HTML round-trip
hasLinkReferenceDefinition ran a full remark parse on every content
change with no size guard, unlike the HTML round-trip check beside it.
Above the same 50,000-char cap, the pre-filter match is now trusted as
a definition, keeping rich mode blocked rather than risking an
unparsed document opening in it.
2026-09-18 00:49:25 -07:00
Frederic Barthelemy c76729452c fix(editor): admit arbitrarily nested containers in reference-link pre-filter
The pre-filter only matched one list-or-blockquote transition, so a
definition under e.g. list-then-blockquote or three-level nesting
skipped the parser confirmation and rich mode stayed on for content it
cannot round-trip.
2026-09-18 00:48:49 -07:00
Frederic Barthelemy 2feea7ce4a docs(editor): tighten reference-link detection comments 2026-09-18 00:48:06 -07:00
Frederic Barthelemy d4f84320ad fix(editor): stop treating prose after [label]: as a link definition
The reference-links check only looked for a line starting with
[label]: followed by non-whitespace, so prose like "[Bug]: steps to
reproduce…" tripped rich-mode's fallback to Source mode. CommonMark
only treats [label]: as a link reference definition when the rest of
the line is a destination plus optional title, so detection now
parses the document with remark-parse/remark-gfm and checks for an
mdast definition node instead of guessing the shape with regex.
2026-09-18 00:48:02 -07:00
Neil a44ab995f9 fix(editor): preserve transport-protected table content 2026-09-18 00:46:43 -07:00
Jinjingandaverydev 93ee27ca2e fix(editor): preserve markdown backslash escapes that change meaning on save
Re-parse each block after serialize and keep the candidate that still
matches the document, preferring fewer escapes. Restores \# / 1. / \| /
\$HOME\$ / link dests that 3.31.3's escapeMarkdownSyntax drops.

Co-authored-by: averydev <averybloom@gmail.com>
2026-09-18 00:43:05 -07:00
Jinjingandaverydev 7b33cd573d fix(editor): preserve source bytes and trailing newline on end-of-file saves
Align the canonical diff inputs with the source final newline when getMarkdown omits it, so EOF edits land before that newline and keep untouched source bytes. Preserve the source line-ending style on every canonical fallback.

Co-authored-by: averydev <averybloom@gmail.com>
2026-09-18 00:42:47 -07:00
Neil 34651306f3 chore(editor): keep details parser within lint limits 2026-09-18 00:38:41 -07:00
Neil 56fb61d02b fix(editor): recognize uppercase details tags in markdown scans 2026-09-18 00:36:08 -07:00
Frederic Barthelemy df20f32fc3 fix(editor): close a fence only on spaces or tabs
The closing-fence pattern used `\s`, which also matches non-ASCII
whitespace such as U+00A0. A closer followed by one ended the fenced
range early, so a `<details>` block still inside the fence reached the
details tokenizer and was rewritten as editable markup.
2026-09-18 00:35:28 -07:00
Frederic Barthelemy a070b00dda test(editor): guard the details start hook's early exit by scan count
The 1000ms ceiling passed even with the early return removed, since the
guarded per-paragraph scans cost far less than the bound on this input.
Assert markdownFenceRanges/markdownCodeSpanRanges call counts instead:
zero for a toggle-free document, one per call whose remaining source
holds the toggle. The wall-clock check survives as an opt-in benchmark
gated by ORCA_DETAILS_SCAN_BENCH, matching this repo's existing
bench-test convention.

# Conflicts:
#	src/renderer/src/components/editor/markdown-scan-ranges.test.ts
2026-09-18 00:35:27 -07:00
Frederic Barthelemy 7bb1838cab fix(editor): treat tag-shaped text in code as prose when validating toggles
The nested-toggle strip handed a <details> candidate inside a code span
to the block matcher, which consumed the span's closing tag and left the
containing block unmatched. The editability sweep then rejected any
remaining tag-shaped text, so a body quoting details markup fell back to
passthrough HTML.
2026-09-18 00:33:12 -07:00
Frederic Barthelemy 65ceead55b fix(editor): skip fenced blocks when scanning for code spans
A backtick inside a fenced block paired with a later prose backtick,
producing a span that covered everything between and hid any <details>
block in that stretch from the tokenizer.
2026-09-18 00:33:10 -07:00
Neil 4dbc6ffcae fix(editor): ignore <details> inside code spans when tokenizing
The details markdown extension registered a bare `<details` string as
its marked start hook, which @tiptap/markdown turns into a raw
indexOf scan over unlexed block source. A `<details>` mention inside
backtick code spans or fenced code therefore split the surrounding
paragraph and let marked's own HTML-block rule swallow the remaining
prose into a details node, corrupting the saved file.

findDetailsBlockStart replaces the literal start hook with a scan that
skips fenced and code-span ranges and requires the tag to open a line
per CommonMark's HTML-block rule. matchDetailsHtmlBlock's tag-depth
pairing scan gets the same code-span exclusion, fixing a related gap
where a </details>-shaped code span inside a real block's body could
close the tag pairing early.

The scanning helpers move to markdown-scan-ranges.ts to keep
details-markdown-html.ts under the project's max-lines limit.

# Conflicts:
#	src/renderer/src/components/editor/details-markdown-html.ts
2026-09-18 00:32:47 -07:00
Baekspace 78121c2dd5 fix: support CJK-adjacent Markdown emphasis 2026-09-18 00:20:39 -07:00
SahilZ0810 b51c65670d fix(editor): preserve case-sensitive details class values 2026-09-18 00:15:06 -07:00
SahilZ0810 41f551990b fix(editor): allow plain details blocks in rich markdown mode 2026-09-18 00:15:04 -07:00
Neil 9473a7b0e5 fix(editor): respect top-level Markdown fence indentation 2026-09-18 00:05:39 -07:00
Slava Katiukha 00d888be07 fix(editor): preserve HTML comments, fenced code, and table pipes in rich Markdown
Signed-off-by: Slava Katiukha <3524973+SlavaKatiukha@users.noreply.github.com>
2026-09-17 23:57:31 -07:00
Neil 2cc34de756 fix(editor): keep an unresolvable mirrored file tab open with a truthful terminal state (#21375)
* fix(editor): keep an unresolvable mirrored file tab open with a truthful terminal state

A host-mirrored file whose read keeps answering `selector_not_found` used
to sit on the raw code forever (and, in the reverted #21363, was closed
outright, discarding drafts). `selector_not_found` is the host's "could
not resolve right now", not proof the workspace is gone, and the file-read
path has no definitive absence code.

Bound the retries as before, then swap in a truthful terminal message
with Retry and Close tab. The tab is never closed automatically; Close
routes through the unsaved-changes queue so a dirty draft is confirmed.

Fixes #21041

* fix(editor): classify selector_not_found by RPC code, not message text

Preserve `RuntimeRpcCallError.code` on `FileContent.loadErrorCode` and gate
the host-unresolved terminal transition with `hasRuntimeRpcErrorCode`, so a
host that sends `{ code: 'selector_not_found', message: 'Selector not found' }`
reaches the same truthful state as one that puts the bare token on the
message. Also drop the Close action on inline conflict-review rows, which
are not open tabs and would have been a dead control.

* fix(editor): localize the host-unresolved copy by sentinel, and pin the token matcher

Separate the terminal state's comparison key from its display text: the
retry hook stores `WORKTREE_HOST_UNRESOLVED_CODE` on `loadErrorCode`, and
the error view localizes by that code (`editor.fileLoad.hostUnresolved`),
so translating the message can never break the terminal check. Export the
selector_not_found matcher and cover near misses (case, suffix, prose,
wrong code) so only the defined token classifies.

* test(editor): name the it.each parameter for the host answer it labels

* fix(editor): drop the load-error Close action; closing stays with the tab strip

The Close button routed through `requestEditorFileClose`, which skips the
pinned-tab and shared-reference checks the tab strip applies, has no
listener outside the Terminal workbench (floating editor panels), and on
the conflict-review overview could target an unrelated open tab whose id
is the same absolute path as a synthesized inline row. Rather than
reimplement the tab strip's close semantics in a second place, the error
view keeps Retry and its copy points the user at closing the tab.

* fix(editor): reword the host-unresolved copy and namespace its sentinel

The copy no longer points at a Close control that is gone ("close this
tab from the tab strip") and no longer claims a scan is in progress, since
`selector_not_found` is also thrown synchronously for unregistered folder
workspaces and removed repos. The sentinel becomes
`editor_host_workspace_unresolved` so it cannot be confused with the CLI's
`worktree_host_unresolved` client error. The doc comment narrows the
"no definitive absence code" claim to git worktrees and names the two host
codes that are definitive but not yet classified.

Refs #21041
2026-09-17 23:23:17 -07:00
Neil 1fa6fac17c fix(daemon): answer the per-pty snapshot predicate for the pty it was asked about (#21381)
canProvideAuthoritativeBufferSnapshot is contracted as "whether this exact PTY can
return a sequence-safe provider snapshot" (pty-provider-contract.ts), and two of the
three layers already route it per id: DaemonPtyRouter forwards to adapterFor(id), and
DegradedDaemonPtyProvider forwards to the provider that owns the session. The daemon
adapter was the leaf that discarded the id and returned supportsAuthoritativeBufferSnapshots
— a negotiated protocol version, which is a fact about the connection, not about a pty.

That is reachable, not theoretical. getProviderForPty falls back to the local provider
for any id it cannot place, so a remote-runtime id (whose pty lives on another machine)
resolves to the local daemon adapter, and pty:getAuthoritativeBufferSnapshotCapabilities
answered `true` for a session this daemon has never owned. The renderer caches that as a
definitive per-pty verdict, and because the leaf discarded the id it could not tell it had
been asked about something it does not own.

Today the wrong answer is masked: allowOrdinaryParkRestore short-circuits remote and SSH
ptys before the cached verdict is read, so nothing consults it. This closes the gap before
something relies on it — a caller reaching for a per-pty answer should not be handed a
confident one that is wrong.

Not touching that short-circuit. It is deliberate: SSH bytes transit the client's own main
process into its headless mirror, so those panes have a local copy the predicate says
nothing about, and the direct-SSH lane was confirmed to repaint from a daemon-backed
restore with the park capture disabled entirely. Routing SSH around a daemon-snapshot
predicate is correct, and removing the short-circuit would disable SSH parking for no
correctness gain.

The existing protocol-compatibility test asserted `true` for a made-up session id, which
encoded the bug. It now spawns a real session, so it still proves the protocol-version
gate without depending on an unowned id reading as supported.
2026-09-17 23:21:39 -07:00
Brennan Benson 85576b6361 chore(mobile): bump to 0.0.51 and Android versionCode 18 (#21382)
0.0.50 is closed on the App Store and shipped as mobile-android-v0.0.50
with versionCode 17, so both values are consumed. Fastlane fails the iOS
release when the resolved version is not higher than the closed train.
2026-09-18 02:11:25 -04:00
Neil 4e3170a76e fix(accounts): free the account queue when a sign-in is abandoned, and show the Codex sign-in link (#21372)
* fix(accounts): free the account queue when a sign-in is abandoned

Closing Settings mid sign-in left the `codex login` / `claude auth login`
child running, and every account mutation shares one FIFO queue, so the
next Add Account sat behind it for the login's whole deadline and then
inherited the abandoned call's timeout toast.

Cancel the pending login before enqueueing the next add or reauth (never
inside the queue the abandoned login owns), give Codex the cancel handle
and Cancel button Claude already had, and stop reporting a cancellation
as a failure.

Also surface the sign-in link Codex prints, with copy and open, so the
flow can be finished in a private window or another browser profile.

* test(accounts): drop the bare casts CI's changed-code gate rejects

The service doubles still need a cast; one documented helper per file
carries the SAFETY rationale instead of nine bare `as never`s.

* fix(codex): a cancel must not discard a sign-in that already succeeded

The Windows post-auth watcher gives a lingering codex login five seconds
to exit after it writes auth.json. A cancel arriving in that window
rejected the login, and the caller's rollback then deleted the managed
home that had just authenticated.

Refuse the cancel once new credential bytes exist: there is nothing left
to cancel, and the close handler already treats that state as success.

Found by review of #21372.

* fix(codex): keep a refused cancel cancellable, and require the sign-in notice

Review of the auth-aware cancel guard found two holes it opened:

- The outer handle latched `cancelled` before asking the session, so a
  refusal killed cancellation for the rest of the deadline. On a host
  with no post-auth watcher that reinstated the very stall this PR
  removes. Latch only when the cancel is accepted.
- WSL never reads a pre-spawn baseline, so the guard read the auth.json
  that was already there and refused from the first click, making a WSL
  reauthentication uncancellable. Require a baseline before refusing.

Also from review: publish the sign-in link from a stdout-only buffer, so
an interleaved stderr chunk cannot truncate it; require codex's own
"navigate to this URL" notice rather than offering the first link in the
output; hide the notice in a remote account scope, where it would name a
login running on this desktop; and share the cancellation message
instead of matching a duplicated literal.

The Claude case joins the login-process suite that already owns the two
neighbouring cancel cases, and the auth-snapshot helpers move out of the
session file, which the additions pushed over the line cap.

* refactor(codex): cut the sign-in-link plumbing to its smallest form

Review found the change correct but larger than it needs to be:

- The pending-link store was a class with one permanent subscriber, a
  never-called unsubscribe and a try/catch that could not fire. It is a
  field and a listener set on the service, beside the cancel handle it
  already owned — and the service now clears both in one place.
- The optional login-session dependencies were always supplied.
- The parser's https check could not fail; the pattern already fixed the
  scheme. The renderer's unmount guard inside a synchronous IPC listener
  could not fire either.
- The broadcast channel and the cancellation message are single sources
  of truth in src/shared now, rather than exported next to a hardcoded
  copy of themselves.
- The duplicated seven-line rationale in both services says the same
  thing in three, including why only add and reauthenticate supersede.
- The codex suite reuses its own factory, and unmocks once.

Also reverts four reformat hunks the formatter pulled in around edits.

* fix(accounts): free the queue for a switch, not only for another add

Switching or removing an account shares the mutation queue an abandoned
sign-in was holding, so the commonest thing a user does after giving up
— pick a different account — still spun for the whole deadline while Add
recovered instantly. Both now supersede, as does the Claude side.

Every caller is a person: the two IPC handlers and the mobile RPC
methods. No poll, sync or CLI path reaches them, and a sign-in that
already wrote credentials refuses the cancel, so a switch cannot discard
one that succeeded.

Also from review: the Cancel button regains the gap its Claude twin has
(layout is allowed by the design-system rule; only the colour override
was not), and the URL subscription says what it is — registration for
the process's lifetime, with no teardown to hand back.
2026-09-17 23:08:59 -07:00
Brennan Benson 71f3bdb700 chore(mobile): bump Android versionCode to 17 for the 0.0.50 release (#21335)
versionCode 16 already shipped as mobile-android-v0.0.48, and Android
refuses an install whose versionCode is not higher than the installed
one. Keep expo.version at 0.0.50 so the release tag can match it.
2026-09-17 22:57:02 -07:00
Jinwoo Hong b90837ee46 feat(mobile-web-bundle): advertise the bundle capability where a bundle ships (OTA phase A, 4/5) (#21376)
* feat(mobile-web-bundle): advertise the bundle capability where one ships

status.get pushes mobileWeb.bundle.v1 only when the install's bundle resolves and
its manifest parses, beside the other conditional capabilities. Dev trees and
`orca serve` installs may carry no out/mobile-web, and a static entry there would
promise a download that only ever answers mobile_web_bundle_unavailable.

No protocol version bump: protocol-version.ts asks for one when a method or a
required field is removed or changes meaning, not when a capability is added.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): pin that mobileWeb.bundle.v1 is inert on a released client

Derives the old desktop's reply by removing the one capability from what the new
one sends, rather than writing down what the old client had, and asserts every
released read of status.get lands identically apart from that string: the gate
hook, the three transport readers, the quick-command predicate and the
worktree-create support probe.

Proved red against three mutants: a closed enum on the capability schema (the
salvaged field drops whole, so nothing publishes), a client-side filter over the
new name, and a gate that changes floatingWorkspaceEnabled when it sees it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* chore(mobile): name the invariant behind the fake client's cast

The changed-code casting gate wants the rationale on the line, and the reason is
narrow enough to state: every reader under test reaches the client through an rpc
operation's `request`, which uses sendRequest alone.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
2026-09-18 01:56:20 -04:00
Neil 7c7310fc43 Keep workspace reveals minimal for folders (#21373)
* Keep folder reveals minimal and require filter adjustment

* Clarify minimal reveal test names

* Resolve remote folder hosts during reveal
2026-09-17 22:46:14 -07:00
b7d694ff7e feat(composer): choose a base ref in the New Workspace composer (#17250)
* refactor(repo): share the create-from picker outside automations

Move CreateFromPicker and its test from components/automations to
components/repo, next to the repo-scoped shared UI that already lives
there (RepoCombobox, RepoBadgeLabel, repo-icon). The New Workspace
composer will consume this picker instead of growing a second base-ref
combobox.

Pure move: no behavior change. The translate() keys are call-site
literals, so no locale catalog is affected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(composer): separate the branch that names a workspace from its base

baseBranch carried two meanings at once. It is the ref a worktree is created
from, and it is also what buildWorkspaceSourceSelection turns into the name
field's branch pill whenever no work item is linked. Any second control that
set a base therefore took the name field over: the pill replaced the text
input, hiding whatever the user had typed. The name survived in state, and
Advanced still exposed it, but the main field silently stopped showing it.

Add baseBranchNamesWorkspace, true only when a branch was picked to name the
workspace. The pill reads that flag; creation keeps reading baseBranch. Two
call sites set it, because those are the only paths that make baseBranch
defined with nothing linked — and an undefined base yields no pill anyway.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(composer): let the New Workspace composer pick its base ref

The name field's tabs pick how a workspace is named; the base ref is a
separate decision the composer never exposed. Naming a workspace from a
Jira, Linear, GitHub or GitLab issue therefore pinned the project's default
base with no way to start from a release or a long-lived feature branch.

Nothing below the UI was missing. baseBranch already crosses IPC next to
linkedWorkItem and wins over every default in main, and the composer already
computed handleBaseBranchChange and startFromResetHint — the card simply
never declared those props, so its {...props} spread dropped them. Declare
them and render the shared create-from picker under the name field.

ComposerBaseRefPicker owns its own store reads, the way the sibling
ComposerParentWorktreePicker already does, so the name section stays
presentational and nothing subscribes to the worktree list while the picker
is hidden.

The picker is offered for a plain typed name and for issue-shaped sources.
It is hidden where a base already exists: PR/MR sources pin the pull
request's own head, a branch pick IS the base — and offering one there would
silently turn a checkout of that branch into a new branch off something
else, since picking a base clears reuse — and folder workspaces have no
branches. It always opens on the project default: no sticky base.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(repo): drop a stale react-doctor suppression on the create-from picker

no-adjust-state-on-prop-change no longer fires on this file: removing the
directive and running the react-doctor pass over the directory — where the JS
plugin actually loads — reports nothing, at the new path and at the old one on
main alike. The suppression was already dead; the rename only put the file in
the changed set, where the quality gate reports unused directives.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(repo): list branches as soon as the create-from picker opens

The picker only searched once two characters were typed, so opening it showed
just the project default and whatever branches already had a worktree. The
composer's Branch tab lists on an empty query through the same runtime helper;
match it, and the picker offers the repo's branches straight away.

Search stays debounced at 200ms and capped at 30 results, and it still runs on
the repo's own execution host, so a remote repo lists its own branches. The
Automations picker shares this component and gains the same listing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(composer): carry the base-ref naming intent through a saved draft

`baseBranchNamesWorkspace` lived only in component state, so restoring a
persisted draft always reset it to true. A base ref chosen in the picker
came back as a name-field source pill, hiding the name the user had typed
— the exact regression the flag exists to prevent, reappearing across a
draft round trip.

Persist it next to `baseBranch` and restore it through
`resolveDraftBaseBranchNamesWorkspace`. A draft written before the flag
existed records no intent and restores as a branch pick, which is the
behavior it had when it was saved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(composer): preserve independent base and branch name choices

* fix(composer): pass naming-intent through the create-more reset test

IssueSourceActions now requires baseBranchNamesWorkspace. The create-more reset fixture is a source-owned base, so the flag stays true and the next create still clears it.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Neil <neil@stably.ai>
2026-09-17 22:31:31 -07:00
Neil 8d2f16856f fix(session): scope agent resume to the host that captured the session (#21288)
* fix(session): scope agent resume to the host that captured the session

A provider session id names a transcript in one machine's agent state
directory. Nothing in the resume path compared that machine against the
one the resume executes on, so a record captured on host A reached a
`--resume` run on host B, which answers `No conversation found with
session ID`.

Three things make the drift reachable: `worktreeId` is `repoId::path`
with no host component, sleeping records are `'sleepingAgentKeyed'` so
boot-time host-contention parking never arbitrates them and every
partition merges into one map without retaining provenance, and both
issuers resolve their launch target from the current catalog.

Both issuers are gated. The activation sweep hands `quit`/`live` records
whose pane still exists to the pane's own cold restore, so gating the
sweep alone changed nothing in the SSH lane.

Declines rather than guesses: the record is preserved and remains
resumable by hand. A refused resume is recoverable, a forked transcript
is not. The predicate fails open on anything it cannot positively rule
out -- an unstamped record, an empty stamp, or a `runtime:` host, which a
paired client uses to relabel its host's own SSH workspaces.

The cold-restore gate consults both the pane's transport and the
catalog. The transport alone was racy: it is unresolved on an early
reattach frame, and that frame is exactly when a wrong resume escaped.

* docs(session): name the inverted fail-open direction at the resume gate

* fix(session): keep an unresolved catalog out of the resume host verdict

The worktree form of the resume gate resolved the current host through
getExecutionHostIdForWorktree, which answers 'local' for a worktree the
catalog has no row for. Read as a host, that made every SSH-stamped record
look foreign until its repo row landed, contradicting the module's own
contract that it reports only a positively-known disagreement. Add
getKnownExecutionHostIdForWorktree, which returns null in that silence
(no repo row for a git worktree, no folder-workspace row for a folder
workspace), and route the gate through it; the pair form already fails
open on a null host. The routing resolver keeps its default unchanged.

The CI red on the control case was a separate spec race: the ledger wait
returned as soon as the ledger was non-empty, and it already held the
first launch's `--version` probe, so the control read two probes and gave
up before the cold-restore had typed `--resume` (the failure screenshot
shows the command running in the pane). The spec now reads only the lines
the relaunch appended, anchors on the relaunch's PTY binding and its own
probe, and then waits for `--resume` for the control case or a bounded
grace for the refusal case.
2026-09-17 22:12:55 -07:00
Neil 945ea33541 Revert "fix(editor): evict stale mirrored file tabs (#21363)" (#21368)
This reverts commit 07e8c851b8.

The eviction keys on `selector_not_found`, which this repo documents twice as
UNKNOWN rather than absence:

- `remote-browser-stream-errors.ts`: "it means 'I could not resolve this right
  now', which is UNKNOWN, not proof the target is gone. Its producer is a live
  worktree scan behind a 1s-TTL cache ... a slow scan can surface it
  transiently. Treating that as permanent would strand the pane forever, which
  is the exact bug this file exists to prevent."
- `web-runtime-session-tab-lifecycle.ts`, added by #21277: "'selector_not_found'
  is a transient worktree resolver state (e.g. during scans or cache warm-up)
  and must not become a durable close tombstone."

Two unambiguous absence codes exist for this purpose -- `tab_not_found` and
`terminal_tab_not_found` -- and #21277 had just finished excluding
`selector_not_found` from them. This keyed on the excluded one.

Consequences, after roughly 3.75s of retries:

1. `closeFile` deletes `editorDrafts[fileId]` with no dirty check and no
   confirmation, so a transient resolver blip discards unsaved edits.
2. `closeFile` calls `notifyHostOfMirroredEditorClose`, so the host closes its
   copy too -- the eviction is not local and not recoverable.

The `!ownerNotReady` guard does not cover this: `ownerNotReady` means the host is
still connecting, while `selector_not_found` is emitted for a cold resolver cache
or an unhydrated catalog, which is a different state.

#21041 is still open. A correct fix keys on the two definitive absence codes,
refuses to evict a tab that has a draft, and has a test proving a dirty mirrored
tab survives `selector_not_found`.
2026-09-17 22:12:46 -07:00
Neil ffc812cdce Reveal active workspaces with minimal filter changes (#21364)
* Reveal workspaces by adjusting only blocking filters

* Update runtime localization catalog

* Preserve minimal reveal behavior across catalogs and folders
2026-09-17 22:12:16 -07:00
Jinwoo Hong 9641a1b544 feat(mobile-web-bundle): serve the packaged mobile web bundle over RPC (OTA phase A, 3/5) (#21348)
* feat(mobile-web-bundle): serve the bundle manifest and chunks over RPC

Two paired-runtime methods on the already-authenticated connection:
`mobileWeb.bundle.manifest` returns this install's manifest plus the chunk
size it advertises, and `mobileWeb.bundle.chunk` returns one aligned range of
one asset with the whole asset's length and hash, so a single chunk describes
what it belongs to.

`path` is accepted only by exact match against a manifest member, so traversal
is unreachable rather than mitigated. Each asset's on-disk sha256 is verified
once and the verdict remembered, concurrent first readers sharing one hash.
Reads are capped at four in flight per connection, and a disconnected client
stops costing reads at the next checkpoint.

No SSH or relay proxying: a runtime answers only out of its own install.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile-web-bundle): pin the three buildId serializers against each other

The canonical serialization exists in the builder, the packaging guard, and the
shared contract, because the two packaging scripts run on bare node before any
build output exists and cannot import TypeScript. A divergence in any one would
reject every honest bundle at packaging, or ship a bundle whose id the phone
recomputes differently and re-downloads forever. Proved red by swapping the
guard's code-unit sort for localeCompare: five of six cases fail.

Exports the guard's serializer for the test; no packaging behaviour changes.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile-web-bundle): cover every error code and a multi-chunk paging round trip

Against a synthetic bundle in a temp dir, because the real builder's largest
asset is under one chunk and CI unit jobs never build out/mobile-web. The
fixture's script spans three chunks, its stylesheet is exactly one, and one
asset is empty, so paging, the eof boundary, and the zero-byte case are
exercised rather than assumed.

Reads in flight are held by latching `open`, so the four-per-connection cap and
an abort arriving mid-read are deterministic rather than a race with a
stopwatch. Both were proved red: dropping the abort check after verification
fails the abort case, and keying the cap on connectionId alone fails the
device-token case.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* fix(mobile-web-bundle): resolve the bundle root through the AppEnvironment port

check:runtime-electron-ratchet caught this: the resolver sat beside
getBundledWebClientRoot in src/main/startup and imported electron, and importing
it from an RPC method pulled the first electron edge into a runtime graph whose
baseline is zero. The runtime has to stay bootable on plain Node.

So it reads app.getAppPath() through the port every other runtime module already
uses, and moves next to its two callers under src/main/runtime. A host with no
environment installed has no install root, which is the same answer as having no
bundle. orcad answers getAppPath from its own install root, so a headless
runtime that carries the artifact serves it with no special case.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile-web-bundle): cover the resolver's two probe layouts directly

Also stops exporting the manifest filename, which nothing outside the resolver
needs.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile-web-bundle): pin both methods on the mobile allowlist

The scanner only checks mobile-used ⊆ allowlist, and no mobile source calls these
until A5, so deleting both entries left every test green.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* fix(mobile-web-bundle): keep filesystem failures inside the six error codes

An asset unlinked or truncated after its verdict was cached reached the client as
runtime_error carrying the desktop's absolute install path. Both now answer
mobile_web_bundle_asset_changed, with the cause warned host-side only. A short
positional read is the truncation case, so it throws instead of paging the client
past the end.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile-web-bundle): drop the unreachable release-idempotence guard

The one caller releases exactly once in a finally; removing the flag left every
test green, so it was defensiveness against a caller that does not exist.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile-web-bundle): prove a failed verify is not cached as a verdict

The verdict cache never invalidates, so a transient read failure remembered as a
verdict would poison the asset for the life of the process. Removing the delete
left every test green until now.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile-web-bundle): delete the unsatisfiable manifest params schema

The dispatcher substitutes `{}` for absent params, so `z.null()` could never
parse; the method declares `params: null` instead. A comment on the method name
records why there is no schema.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* fix(mobile-web-bundle): fill the read window instead of failing a partial read

fs.read may answer short of what it was asked for before EOF, so the previous
check turned a legitimate partial read into a spurious asset_changed. The loop
mirrors the relay's readFullStreamChunk, which is not imported because it sits
behind the relay dispatcher's module graph; only a read returning nothing is
treated as truncation.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile-web-bundle): read the disconnect idiom with the shared predicate

isClientDisconnectedError already exports exactly the check the catch needed, so
the local error class goes away and the throw returns to the repo-wide idiom. The
module doc now says asContractError is a total catch.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile-web-bundle): pin the four branches no test was holding

Each one survived a mutation: the abort check before verification, the
per-process manifest cache, the buildId component of the verdict key, and
delete-at-zero in the admission map. The last two matter beyond hygiene — a
verdict keyed by path alone carries a failed verdict onto the next build of
index.html, and a map that never drops a key retains one pairing token per
socket.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
2026-09-18 01:04:27 -04:00
Neil 4b4ee040df perf(relay): index client request aborts instead of scanning every controller (#20052)
* test(relay): measure per-connection teardown and hot-path costs by counting

Both suites replace a would-be duration with the structural fact the duration
was a proxy for, so neither depends on machine load.

The census pins that attach/publish/detach churn returns every per-connection
container to baseline, and asserts the containers actually filled first so a
green cannot come from a probe that never loaded them. It also pins the one
container with no per-client teardown: a publication-ledger entry is reclaimed
only by its own lease, never by closeClient.

The operation counts pin that notifyLegacyCapacity costs one ledger lookup per
active client, that a broadcast costs a fixed number per subscriber, and that
abortClient enumerates every controller rather than the target client's --
which is what makes a full client churn quadratic.

* perf(relay): index client request aborts instead of scanning every controller

abortClient runs on every closeClient and every setWrite. Under the flat map
keyed `${clientId}:${requestId}` it had to walk every controller in the relay to
find one client's, so a full churn of N clients each holding K in-flight requests
cost K*N*(N+1)/2 key visits: measured 50 -> 5,100, 100 -> 20,200, 200 -> 80,400,
400 -> 320,800, exactly 4x per doubling.

Do not "optimise" this back to a scan with an early break. It cannot work: the
matching keys are scattered through the map, so any correct loop still visits
every entry before it can know it is done. Only an index makes teardown
proportional to what the client owns.

`create` now returns an opaque handle carrying the owner, so a release finds its
bucket without parsing a composite string key, and no call site changes.

Also stop building the low-water key array eagerly. `belowLowWater` decides on
the aggregate ceiling first and returns without reading the keys, but the caller
had already allocated an N-element array and N template strings to pass them --
paying most in the loaded case, which is when that short-circuit fires. It takes
a thunk now.

The hot-path test becomes a guard rather than a characterisation: it asserts a
teardown visits only the target client's K controllers and never enumerates the
client index at all, since enumerating it is the old scan. Verified by mutation:
restoring the scan shape fails it with "expected 40 to be +0". It asserts the
maps really hold 160 controllers first, so it cannot pass by never filling them.

* test(relay): make the capacity-thunk guard fail when the thunk is removed

The operation-count test measured an idle dispatcher, where the aggregate ceiling
never short-circuits, so every key is read whichever call shape is used. Reverting
the thunk left all five assertions green -- it guarded nothing it claimed to.

Adds the loaded arm, where the ceiling answers first and the saving exists, and
asserts the client index is not enumerated at all. Reverting the thunk now fails
it with `expected 50 to be +0`.

Drops the ledger-retention case: it asserted a stranded entry SURVIVES close, so
it pinned a capacity leak as a contract and would have broken whoever fixed it. It
also used a key no client-keyed reclamation could match, and touched nothing this
branch changes. The churn census already proves normal closes settle every entry;
the gap is recorded there as a gap.

* test(relay): carry the SAFETY: rationale main's casting gate now requires

Not introduced here: main gained a `typescript/consistent-type-assertions` scan while
this branch sat 432 commits behind, and every `as` in the two probe files this branch
adds is new relative to main, so all 11 land as new findings. Verified by running the
gate on this branch with and without my earlier test commit — 11 either way.

Both files reach past `protected` to count containers, which is the measurement; each
cast now carries the line-specific rationale AGENTS.md mandates.

* test(relay): put the countingIterator SAFETY: directive on the line oxlint flags

The diagnostic points at the `return {` that opens the object literal, not at the
`} as IterableIterator<T>` that closes it, so disable-next-line has to sit above the
statement.

* test(relay): type countingIterator as MapIterator and drop two suppressions

The wrapper only ever receives a Map iterator, so declaring that removes the cast at
both call sites; one irreducible cast stays on the object literal, which cannot satisfy
MapIterator's full surface. Three suppressions become one.

* fix(relay): key the abort index by the id's string form so a string id can still be cancelled

The flat map's template key folded a request id of 7 and "7" onto one entry;
keying the raw value split them, so rpc.cancel (which coerces through Number)
missed a string-id request. Restore the coercion at the index.
2026-09-17 21:50:15 -07:00