Commit graph

22235 commits

Author SHA1 Message Date
Simon Klee
ff7fa63d0d
feat(cli-rs): add the run command
Port of handlers/run.ts, run/run.ts and run/noninteractive.ts: text and
--format json output, permissions and forms auto-rejected (or approved
with --auto), -f attachments typed by the mime-types table, stdin and
words after --, -w worktrees, titles and archived sessions. Events and
messages stay JSON so JSON lines pass server fields through unchanged.
P-CLI scenarios in parity/scenarios/C.10 compare it with the TS run.
2026-11-04 23:46:40 +01:00
Simon Klee
2314d94f2b
fix(cli-rs): flush telemetry before handing over to TS
The CLI now logs and exports before dispatch, and exec drops whatever
is still queued. The delegate test keeps its log file in a temp dir.
2026-11-04 23:44:42 +01:00
Simon Klee
90b1fd8954
test(cli-rs): compare delegated commands with TS in P-CLI
opencode-rs delegates to the TS CLI from source, so serve errors,
uninstall --dry-run, plugin list and plugin remove print the same as TS.
2026-11-04 23:44:42 +01:00
Simon Klee
fb147bf299
feat(cli-rs): delegate serve, upgrade, uninstall and plugin to TS
These commands need the server, the installer, npm and Host.resolve,
which exist only in TypeScript (Q4). opencode-rs now execs
OPENCODE_TS_BIN, else opencode on PATH, with its own arguments, so the
TS binary keeps the pid, stdio, signals and exit status. Remote access
gets enable_remote (TS service set remote true) and tunnel_hostname,
which reads the OpenTunnel XDG storage, for C.8 and C.9.
2026-11-04 23:44:42 +01:00
Simon Klee
502ca8ab73
docs(cli-rs): record that integration links open with Enter only 2026-11-04 23:42:16 +01:00
Simon Klee
619842646e
fix(cli-rs): read the integration location from the model state
Local now resolves the routed location; the connect requests use it. The MCP test expects the integration dialog for a server that signs in through an integration.
2026-11-04 23:42:16 +01:00
Simon Klee
9fd92338c8
test(cli-rs): prove the integration dialog against the TypeScript cells
P-COMP fixtures for the list, accounts, methods, key, form and OAuth views, and P-REQ tests for every connect flow, the account actions and the form steps over a fixture server, with a URL sink instead of a browser. The form list scrolls from row heights, since rows rebuilt in a render have no layout yet.
2026-11-04 23:42:16 +01:00
Simon Klee
9e2421d9a0
feat(cli-rs): add the Connect an integration dialog and its flows
Ports dialog-integration.tsx: the integration list, accounts (activate, rename, remove), the method picker, API keys, OAuth in the browser or with a pasted code, external and command connects, and the method forms. /connect, the model dialog, the prompt without a model and the MCP sign-in now open it.
2026-11-04 23:42:16 +01:00
Simon Klee
ad026b5c24
docs(cli-rs): record the telemetry and shutdown deviations 2026-11-04 23:37:39 +01:00
Simon Klee
7d11495ef3
feat(cli-rs): add log files, OTLP logs, signals, and the askpass helper
Port C.14: merge NO_PROXY with the loopback hosts, run as the SSH askpass
helper when OPENCODE_SSH_ASKPASS_PORT is set, install a log facade logger
that writes the TS key=value format to <data>/log (with trim, --log-level,
--print-logs, and OTLP log export), and bound signal-initiated shutdown to
10 s with SIGHUP as SIGTERM under a terminal.

Panics and the service connection notes now go through the same logger.
2026-11-04 23:37:39 +01:00
Simon Klee
ea73c53ec4
test(cli-rs): prove the diff dialogs over repository fixtures
Three P-APP scenarios: the last turn selected from the source dialog and loaded again after a turn, the base branch picker over a repository's branches, and the shortcuts dialog with the file menu. The harness gains a right-click step, and repo.ts also returns the repository's branches.
2026-11-04 23:34:28 +01:00
Simon Klee
8072f4e662
feat(cli-rs): add the diff viewer's dialogs and file menu
The diff source dialog, the base branch picker, the shortcuts dialog and the right-click file menu fill E.15a's stubs (DLG46 to DLG49). In turn mode the viewer loads the last turn again when its session goes from running to idle, and a docked panel keeps its focus styling while a dialog is open, as TS does.
2026-11-04 23:34:28 +01:00
Simon Klee
538bab2d39
test(cli-rs): compare the session pager and export picker with TS
P-PTY cases for session list under less and for the export picker: choose, cancel, and no sessions, with their request logs.
2026-11-04 23:33:26 +01:00
Simon Klee
8bed1f8d47
feat(cli-rs): add session list, delete, export, and import
Ports packages/cli/src/commands/handlers/session/*.ts: the list with its less pager on a terminal, the export picker on stderr through the prompt kit, and the import that replaces the file's location in place. P-CLI compares 14 cases with TS on the fake server.
2026-11-04 23:33:26 +01:00
Simon Klee
4302b3645f
style(cli-rs): format the dialog footer key rule
rustfmt wraps the let-else of the TS keyless-action rule.
2026-11-04 23:31:18 +01:00
Simon Klee
028ae8f85a
feat(cli-rs): add the update dialog and the home update notice
The updater stays with the CLI: features::update_notification::Source is what D.2 provides through set_source, and until then there is no /update and no notice, as in TS without an updater. With a source, client notices and the installation.* events show the home notice; skip remembers it in update-notifications. The dialog checks, installs, and restarts as DialogUpdate does, proven against a fake updater. The dialog footer now shows an action without a key or command, as TS does, and the P-COMP helper compares the footer band too.
2026-11-04 23:31:18 +01:00
Simon Klee
4f35dfa9e5
feat(cli-rs): add release highlights and their auto-open
DialogHighlights shows the embedded OPENCODE_RELEASE_HIGHLIGHTS, as TS stable builds do; /highlights is registered only when there are some. Once connected, an idle home claims the version in the highlights storage under its lock, ported from util/highlights.ts with its tests.
2026-11-04 23:31:18 +01:00
Simon Klee
b82b9e2f93
feat(cli-rs): add the pair dialog
/pair and /web read GET /api/info and POST /api/pair, then show the connect links, the localhost link, and a QR code of the first link as renderUnicodeCompact draws it (byte mode, level L, smallest version). Proven against a test transport only, since a pairing creates a code on the server.
2026-11-04 23:31:18 +01:00
Simon Klee
85ef533ca9
feat(cli-rs): add the plugin manager and the error source line
/plugins lists the TUI plugins from the registry and the server plugins from GET /api/plugin. Enter toggles a TUI plugin through set_active and remounts the route, space or Enter opens an error, ctrl+u updates and ctrl+r checks packages, ctrl+a shows the built-ins. A configured TS plugin is listed as skipped with the reason as its error. The error details view gains the source path line, and select actions gain hidden_when for row-dependent actions.
2026-11-04 23:31:18 +01:00
Simon Klee
46054a08ab
feat(cli-rs): add the status dialog
/status and <leader>s list the default location MCP servers with their status, as DialogStatus does, and follow the store while open.
2026-11-04 23:31:18 +01:00
Simon Klee
82fb532f4f
feat(cli-rs): add the theme list with preview and restore
Settings → Theme and /themes open DialogThemeList. Moving or filtering previews the theme, Escape restores the opening one, and Enter writes theme.name. The dialog is built again in each previewed theme, as TS restyles it, through a select restore of the selection and scroll.
2026-11-04 23:31:18 +01:00
Simon Klee
da822df66a
fix(cli-rs): keep the queued prompts condition off the store lock
session.queued_prompts read the store in its enabled condition, which
the reentry assert caught under a keymap query. It reads the count the
dock last updated instead (carbon-5).
2026-11-04 23:25:31 +01:00
Simon Klee
49a287616b
test(cli-rs): cover the MS1 review fixes in the TUI
Leaving a missing location session, keymap queries under the store
lock, permission reads after a reconnect, and focus under a dialog
(carbon-2, carbon-5, carbon-6).
2026-11-04 23:25:31 +01:00
Simon Klee
5b2a163227
fix(cli-rs): read permissions and forms again after a reconnect
Permission, SessionForms and HomeForms read each owner once per mount,
so a request created while the event stream was down never showed. They
now read again on a full sync, which a reconnect brings. Reading on
every sync instead loops when a read fails with SessionNotFoundError.

A permission or form that closed under an open dialog focused the prompt
behind the dialog. The prompt now takes the keys when the dialog closes,
through the new Dialogs::refocus (carbon-6).
2026-11-04 23:25:31 +01:00
Simon Klee
a7832c818a
fix(cli-rs): keep keymap conditions off the store lock
Keymap queries evaluate every command's conditions, and has_sessions, the
prompt's running, the session actions' reverted and child, and
Local::route_fn locked the store. A query under Data::read then hung the
UI thread. Tui::sync now caches the routed session and whether sessions
exist, and the prompt caches running at each refresh (carbon-5).
2026-11-04 23:25:31 +01:00
Simon Klee
1eece51bb1
fix(cli-rs): dispose session view keymap layers
LocationMissing, the scroll controls and the transcript dropped their
Disposer handles, which keeps the layers registered. After a missing
location session, Enter on home opened "Choose directory", and session
commands stayed in the palette. Each view now disposes its layers when it
replaces or drops them (carbon-2).
2026-11-04 23:25:11 +01:00
Simon Klee
ccd8f2e17c
fix(cli-rs): panic on a reentrant store lock in debug builds
The store mutex is not reentrant, so a read under a read hung the UI thread
until the test timeout. Debug builds now track the stores each thread
holds and panic with a stack trace instead (carbon-5).
2026-11-04 23:25:11 +01:00
Simon Klee
58c5e53aec
fix(cli-rs): shift copied theme colors by value
Theme::decrease and increase matched tokens by address, so a Color copied
to a local never shifted and hover and badge surfaces kept the raised
background. A copy now shifts by the tones of the tokens with its value,
and stays unchanged when they disagree (carbon-8).
2026-11-04 23:25:11 +01:00
Simon Klee
4f70268817
test(cli-rs): wait on conditions in the shared state tests
Use support/wait.rs's ceiling and wait for the asserted state instead
of a fixed 50 ms settle after each event.
2026-11-04 22:57:35 +01:00
Simon Klee
c013fb54d6
refactor(cli-rs): follow E.11b's /cd location in the model state
E.11b's home /cd sets the location, as TS does, so Local follows
location::current alone and location::set already syncs it.
2026-11-04 22:57:35 +01:00
Simon Klee
845e38b499
fix(cli-rs): follow home's /cd directory in the model state
TS /cd sets the location that useLocal reads; here it sets the prompt's
home directory, so Local follows that on home too.
2026-11-04 22:57:35 +01:00
Simon Klee
25605936e8
test(cli-rs): prove session.json and history writes against the TS TUI
P-FILE under contention: parity/oracle/MS1-files.ts writes with the
TypeScript TUI's own persistence functions while Rust writes, and a
reader checks every state of both files.
2026-11-04 22:57:35 +01:00
Simon Klee
302a34dded
fix(cli-rs): only append to the prompt history on save
Under real contention a trim by rename dropped a line the TypeScript TUI
was appending without the lock: Node can open the old file before the
rename and write after it. Saves now only append, as TypeScript does
below the limit, and the load trims the file to the newest 50.
2026-11-04 22:57:35 +01:00
Simon Klee
7b6d784b42
test(cli-rs): prove cross-location model state and shared state files
Covers carbon-3 (a project-local agent survives a submit, acknowledged
commits clear the drafts) and carbon-7 (pins and history lines another
client wrote survive, early prompts are kept, deletes prune pins).
2026-11-04 22:57:35 +01:00
Simon Klee
fa4826fe14
fix(cli-rs): read model state for the session's location
Local takes its models, providers, agents, integrations, and configured
model from the store for the current location, and follows it when the
TUI moves. Acknowledged agent and model commits clear their drafts, and
session.deleted drops drafts and pins, as context/local.tsx does
(carbon-3).
2026-11-04 22:57:35 +01:00
Simon Klee
fb92812629
fix(cli-rs): lock and re-read session.json and prompt history writes
Pins and history entries are written in order on one worker, under the
file's Flock lock, from what the file holds then, with uniquely named
atomic rewrites. Pins and lines the TypeScript TUI wrote since survive,
and prompts submitted before the history loads are kept (carbon-7).
2026-11-04 22:57:34 +01:00
Simon Klee
ec8f9bac9f
test(cli-rs): cover pastes, attachments, and the stash file with TS
TestApp tests over a recording fixture and the clipboard sink: compact pastes and their expansion, clipboard images and text, read errors, pasted paths and SVGs, previews and the image dialog, copy, and the stash dialog. P-FILE runs the real PromptStashProvider on the Rust stash file and back.
2026-11-04 22:55:49 +01:00
Simon Klee
38f311bacf
feat(cli-rs): copy pasted text, not its label, from the prompt
A mouse selection copied while the prompt is focused expands each [Pasted ~N lines] label to its text, as the TS prompt's getClipboardText does. Drops parts::files, which the attachment path replaced.
2026-11-04 22:55:49 +01:00
Simon Klee
5830f6b707
test(cli-rs): prove compact pastes against TS with a paste step
The P-APP harness gains a bracketed paste step on both sides. E.4/paste collapses a three-line paste, expands it by pasting it again, and strips ANSI from a short paste; every checkpoint equals TS.
2026-11-04 22:55:49 +01:00
Simon Klee
c50a4c3e36
feat(cli-rs): add pastes, attachments, image previews, and the stash
Long pastes collapse into [Pasted ~N lines] parts on the E.3 extmark map, pasted file paths and clipboard images attach as [Image N] or [PDF N], and the prompt stash keeps prompt-stash.jsonl in step with the TS TUI. Adds the image preview and stash dialogs, and opens the preview from transcript images.
2026-11-04 22:55:48 +01:00
Simon Klee
cb4d98c584
test(cli-rs): make the TS oracles' waits exact and say which timed out
File times come from a coarse clock that can trail Date.now(), so the load's
rewrite is now told by a changed mtime rather than one past the mount time.
The frecency appends land in any order, so they are compared as a set. A wait
that runs out now names itself on stderr, where a failing test shows it.
2026-11-04 22:53:35 +01:00
Simon Klee
a082899e80
fix(cli-rs): append prompt history in submit order
Each append ran on its own blocking task, so two quick submits could reach
prompt-history.jsonl in reverse order, and one made before the load finished
was dropped. Entries now queue in submit order, each task appends the whole
queue while it holds the history, and whichever task runs first loads the
file. prompt.rs caught the reversed file on a loaded machine.
2026-11-04 22:53:35 +01:00
Simon Klee
b4f9221bd3
test(cli-rs): let the TS oracles' load rewrite land before appending
The TypeScript history and frecency providers rewrite the file on load without
awaiting it. Under load, an append made after the load could land first and be
truncated by the rewrite. The oracles now wait for the rewrite, by mtime,
before running the ops. This is a race in the TS client itself.
2026-11-04 22:53:35 +01:00
Simon Klee
199077f8ff
test(cli-rs): wait for the TS oracles' appends to land
The E.2 and E.3 oracles gave the TypeScript appends a fixed 50 ms and the load
1 s. They now wait, up to 30 s, until the file ends with the appended lines,
read through a fresh BunFile each time, since a reused one can keep a stale
size.
2026-11-04 22:53:35 +01:00
Simon Klee
b9c8e299c8
test(cli-rs): serve ses_a's collections in the prompt fixture
ses_a's inbox, permission and form reads answered SessionNotFoundError, as for
a session not created yet. When one landed after the test set ses_a running,
the store marked ses_a deleted and dropped its status, so 'esc interrupt' never
showed.
2026-11-04 22:53:35 +01:00
Simon Klee
daadabcb58
test(cli-rs): wait for every autocomplete row the skills test checks
Skills, references and agents load separately; the test waited for a skill and
then asserted a reference that had not landed yet.
2026-11-04 22:53:35 +01:00
Simon Klee
cab5645cd2
fix(cli-rs): write tab changes to tabs.json in order
Each tabs update wrote the file on its own blocking task, and the tasks could
run out of order: a tab's title, set once its session read landed, could reach
the file before the tab itself, and was then lost. Each task now writes every
pending update, in order, while it holds the queue. tabs.rs caught it on a
loaded machine: ses_b stayed untitled in tabs.json for 30 s.
2026-11-04 22:53:35 +01:00
Simon Klee
9b9622f6d2
test(cli-rs): wait for the line-range row before picking it
The typed '@src/main.rs#3-5' already matched the wait, so on a loaded machine
Enter picked the stale '#3' row before the search for '#3-5' landed.
2026-11-04 22:53:35 +01:00
Simon Klee
c4b40b8a68
chore(cli-rs): format the ui crate's dialog, select and theme oracle
cargo fmt --check failed on these three files at d759713d61.
2026-11-04 22:53:35 +01:00
Simon Klee
b48fafd029
test(cli-rs): wait for conditions, not fixed times, in TUI tests
tabs, navigate, prompt and complete failed on a loaded machine. Waits now share
a 30 s ceiling (tests/support/wait.rs) and return once their condition holds;
fixed sleeps before assertions became waits for the asserted state.

- navigate: a page-up near the top moves two frames later, and when the older
  page arrived before the first render the move landed on the next key's
  frame. press and dispatch now render until no frame is pending.
- tabs: wait for both stored titles, not just two tabs.
- complete: wait for the search for 'ma', not only its results.
2026-11-04 22:53:35 +01:00