mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 08:39:02 +03:00
test(cli-rs): remove migration notes from app fixtures
Describe the setup that affects what a test observes: local time, frame delivery, dynamic registration, file writes, and reference inputs. Drop issue inventories and assertion walkthroughs from the fixtures.
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
//! The session actions (E.10a) over a fixture server that logs every request: rename, timeline, fork, compact,
|
||||
//! undo, redo, the copies, export, the parent session, and the revert commit before a prompt. Writes answer 204
|
||||
//! where the server does. The dialogs' cells are compared with the TypeScript ones in
|
||||
//! `parity/component/E.10a-actions.tsx` (`dialogs_match_typescript`).
|
||||
//! Session commands through a request-recording server.
|
||||
|
||||
use crate::support::{self, Fake, Harness, Log, WAIT, deref_harness};
|
||||
|
||||
@@ -201,7 +198,7 @@ fn rename_opens_the_dialog_by_key_and_renames_or_generates_by_slash() {
|
||||
|
||||
kit.clear();
|
||||
kit.app.type_text("/rename");
|
||||
// The first Enter takes the slash completion, as in TS; the second submits.
|
||||
// The first Enter accepts completion; the second submits.
|
||||
kit.app.press("return");
|
||||
let completed = kit.app.wait_until(WAIT, || kit.prompt_text() != "/rename");
|
||||
assert!(completed, "{:?}", kit.prompt_text());
|
||||
@@ -263,13 +260,10 @@ fn fork_forks_the_whole_session_or_before_a_prompt_and_opens_it() {
|
||||
kit.app.press("return");
|
||||
assert_eq!(kit.wait_writes(1), [r#"POST /api/session/ses_a/fork {"before":"msg_03"}"#]);
|
||||
kit.wait_for("Forked session");
|
||||
// The fork's composer holds the prompt it was forked before.
|
||||
let found = kit.app.wait_until(WAIT, || kit.prompt_text() == "Fix the bug\nin parse");
|
||||
assert!(found, "{:?}\n{}", kit.prompt_text(), kit.app.text());
|
||||
}
|
||||
|
||||
// `dialog-fork.tsx:24-48`: the fork's composer gets the prompt it was forked before with its attachments
|
||||
// (`restorePrompt`), and the fork opens known, with the session the server returned.
|
||||
#[test]
|
||||
fn fork_before_a_prompt_keeps_its_attachments_and_opens_the_returned_session() {
|
||||
let mut messages = turns();
|
||||
@@ -349,8 +343,6 @@ fn undo_reverts_to_the_last_prompt_and_puts_it_back_in_the_prompt() {
|
||||
assert!(kit.writes().is_empty(), "{:?}", kit.writes());
|
||||
}
|
||||
|
||||
// `projectedPromptInput` and `appendToSessionPrompt` (`codec.ts:14-37`, `draft-stash.ts:37-47`): the undone prompt
|
||||
// comes back with its files and their mentions, after the composer's own parts, in normal mode.
|
||||
#[test]
|
||||
fn undo_puts_the_attachments_back_after_the_composer_parts() {
|
||||
let mut messages = turns();
|
||||
@@ -446,8 +438,6 @@ fn a_prompt_commits_a_staged_revert_before_it_is_sent() {
|
||||
assert!(commit < prompt, "{writes:?}");
|
||||
}
|
||||
|
||||
// The accepted submit keeps its target after the composer unmounts (`prompt/index.tsx:1281,1341-1380`): leaving the
|
||||
// session while the revert commits still sends the replacement.
|
||||
#[test]
|
||||
fn leaving_the_session_while_the_revert_commits_still_sends_the_prompt() {
|
||||
let kit = Kit::new(session("ses_a", json!({ "revert": { "messageID": "msg_03" } })), turns(), vec![]);
|
||||
@@ -464,7 +454,6 @@ fn leaving_the_session_while_the_revert_commits_still_sends_the_prompt() {
|
||||
|
||||
#[test]
|
||||
fn copies_and_the_parent_report_their_outcome() {
|
||||
// Without a terminal, every copy fails, as TS reports a rejected clipboard write.
|
||||
let kit = Kit::new(session("ses_a", json!({ "parentID": "ses_p" })), turns(), vec![]);
|
||||
kit.ready();
|
||||
kit.tui.keymap.dispatch("messages.copy", None);
|
||||
@@ -610,7 +599,7 @@ fn export_saves_markdown_or_sanitized_json_and_shows_the_path() {
|
||||
#[test]
|
||||
fn dialogs_match_typescript() {
|
||||
let mut failed = Vec::new();
|
||||
// The TS fixtures render in UTC; the Rust footers use local time, so shift the prompts by the local offset.
|
||||
// Shift prompt times by the local offset to compare against UTC recordings.
|
||||
let offset = i64::from(opencode_util::time::Zone::Local.offset(1_772_539_200_000)) * 1000;
|
||||
let shifted: Vec<Value> = turns()
|
||||
.into_iter()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The `animations` switch (`rs-animations-off`): with it off a running session draws the TS still glyphs and asks
|
||||
//! for no frames; turning it on or off at run time takes effect at once.
|
||||
//! Animation and idle-frame behavior on the app clock.
|
||||
|
||||
use crate::support;
|
||||
|
||||
@@ -90,8 +89,7 @@ fn mount_with(tabs: Value, animations: bool, active: &Value) -> (support::Harnes
|
||||
(h, memory)
|
||||
}
|
||||
|
||||
/// Whether a spinner frame past the first shows. A running tab's still indicator is the first frame, `⠋`, as in
|
||||
/// TS (`TabIndicator`).
|
||||
/// Detect an advancing spinner; a busy tab also shows its first glyph when animation is off.
|
||||
fn moving(screen: &str) -> bool {
|
||||
screen.chars().any(|c| ('⠀'..='⣿').contains(&c) && c != '⠋')
|
||||
}
|
||||
@@ -110,8 +108,7 @@ fn frames(h: &support::Harness, span: Duration) -> usize {
|
||||
.count()
|
||||
}
|
||||
|
||||
/// Lets the startup polls (the data migration's status) start and end: two seconds for their timers, then no read in
|
||||
/// flight and a stretch that asks for no frame, since a reply can land after any fixed stretch on a loaded machine.
|
||||
/// Drain startup timers and reads before measuring idle frames.
|
||||
fn settle(h: &support::Harness, memory: &Memory) {
|
||||
frames(h, Duration::from_secs(2));
|
||||
h.wait("the startup polls to end", || memory.in_flight() == 0 && frames(h, Duration::from_millis(400)) == 0);
|
||||
@@ -203,7 +200,6 @@ fn a_spinner_out_of_sight_costs_no_frames_and_no_wakeups() {
|
||||
let hiding = h.app.idle(Duration::from_secs(1));
|
||||
let hidden = h.app.idle(Duration::from_secs(4));
|
||||
if case == "a dialog beside it" {
|
||||
// The palette leaves the rows in view, so they still move, as in TS.
|
||||
assert!(h.app.text().contains(" npm test"), "{case}:\n{}", h.app.text());
|
||||
assert!((100..=104).contains(&hidden.frames), "{case}: {hidden:?}");
|
||||
continue;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//! P-APP, Rust side (`docs/testing.md`): replays every recording under `parity/fixtures/*/*.app.json`
|
||||
//! through the whole Rust TUI in a `TestApp`, over the in-memory transport, and compares each checkpoint's
|
||||
//! cells and the requests with what the TS TUI did. `PARITY_SCENARIO=<step>/<name>` selects one scenario.
|
||||
//! Replay recorded app scenarios against the full TUI and compare checkpoints and requests. `PARITY_SCENARIO` selects
|
||||
//! one recording.
|
||||
|
||||
use crate::support::{self, ide};
|
||||
|
||||
@@ -39,8 +38,7 @@ fn scenarios() {
|
||||
let only = std::env::var("PARITY_SCENARIO").ok();
|
||||
let recordings = Recording::all(only.as_deref()).unwrap_or_else(|error| panic!("{error}"));
|
||||
assert!(!recordings.is_empty(), "no P-APP recording matches {only:?}");
|
||||
// The built-ins' own screens (E.14) run on both carriers (P6a): with Rust values, and through the C ABI's byte
|
||||
// shims. `PARITY_CARRIER=both` runs every selected scenario on both.
|
||||
// Run built-in screens on both carriers. `PARITY_CARRIER=both` repeats every selected scenario on both.
|
||||
let both = std::env::var("PARITY_CARRIER").is_ok_and(|carrier| carrier == "both");
|
||||
let mut failed = Vec::new();
|
||||
for recording in &recordings {
|
||||
@@ -94,7 +92,6 @@ fn run(recording: &Recording, abi: bool) -> (bool, String) {
|
||||
#[cfg(not(feature = "ts"))]
|
||||
let cache: Option<opencode_util::temp::TempDir> = None;
|
||||
let args = &recording.args;
|
||||
// TS opens `sessionID` unless it forks it (`app.tsx:680-686`).
|
||||
let session = args.session_id.clone().map(SessionID);
|
||||
let tui = opencode_tui::mount_with(
|
||||
&app,
|
||||
@@ -146,14 +143,12 @@ fn run(recording: &Recording, abi: bool) -> (bool, String) {
|
||||
let config = opencode_plugin::pipe::Config {
|
||||
version: "test".to_owned(),
|
||||
channel: "test".to_owned(),
|
||||
// TS's recorder runs in UTC (`parity/app/scenarios.test.tsx`), so a time a plugin writes in local time
|
||||
// (`opencode-session-time`'s) reads the same on both sides on any machine.
|
||||
// Match the recorder's UTC time zone for plugin-local timestamps.
|
||||
env: vec![("TZ".to_owned(), "UTC".to_owned())],
|
||||
..opencode_plugin::pipe::Config::new(bun)
|
||||
};
|
||||
let root = opencode_util::temp::tempdir().expect("plugin root");
|
||||
// The user's global opencode config names the scenario's cached packages, as a TS server plugin's TUI part
|
||||
// loads without approval only then in Rust (O-162); TS asks for none.
|
||||
// Global config vouches for cached server plugins so the replay does not require interactive approval.
|
||||
let user: Vec<&String> = recording.cache.keys().collect();
|
||||
std::fs::create_dir_all(root.path().join("config")).expect("config directory");
|
||||
let global = serde_json::json!({ "plugins": user }).to_string();
|
||||
@@ -187,10 +182,7 @@ fn run(recording: &Recording, abi: bool) -> (bool, String) {
|
||||
let sockets = Arc::new(Sockets::new(recording));
|
||||
tui.terminals.set_connector(sockets.clone());
|
||||
|
||||
// TS draws no route until its plugins' setups have run (`app.tsx`, `<Show when={plugins.ready()}>`), so its first
|
||||
// checkpoint already has every plugin's commands and slots. The Rust route mounts first and the plugins load after
|
||||
// it, a V2 plugin's commands in a reload after its first mount: under load a step could come before them, an Enter
|
||||
// on a completion that has not listed `/files` yet (file-browser-flake). The replay starts once they have loaded.
|
||||
// Wait for plugin registration before replaying keys. The recorder's first frame already has the plugin's commands.
|
||||
let starting = || {
|
||||
tui.plugins.entries().iter().any(|entry| match &entry.status {
|
||||
opencode_plugin::Status::Skipped(reason) => {
|
||||
@@ -275,9 +267,7 @@ fn run(recording: &Recording, abi: bool) -> (bool, String) {
|
||||
}
|
||||
}
|
||||
|
||||
// A write a last key starts can come after the last checkpoint, as the recorder's stays open past it: a JS plugin's
|
||||
// declined Enter goes on once the JS host answered, and the prompt goes then (CT-19). Wait, at most `UNTIL`, until as
|
||||
// many writes went as TS sent.
|
||||
// A key can start a write after its last checkpoint. Wait for the recorded number of writes before comparing.
|
||||
let writes = || memory.requests().iter().filter(|logged| !app::is_read(&logged.method, &logged.path)).count();
|
||||
let deadline = Instant::now() + SETTLE;
|
||||
while !(memory.in_flight() == 0 && writes() >= recording.requests.writes.len()) && Instant::now() < deadline {
|
||||
@@ -334,8 +324,7 @@ fn run(recording: &Recording, abi: bool) -> (bool, String) {
|
||||
(passed, report)
|
||||
}
|
||||
|
||||
/// What a client sent the IDE server, each message once and without its request ID: TS connects again when
|
||||
/// the session's directory differs from its working directory, which the Rust runner's does not.
|
||||
/// Deduplicate IDE messages and omit request IDs: reconnects can repeat the handshake.
|
||||
fn handshake(messages: &[serde_json::Value]) -> Vec<serde_json::Value> {
|
||||
let mut unique: Vec<serde_json::Value> = Vec::new();
|
||||
for message in messages {
|
||||
@@ -350,8 +339,7 @@ fn handshake(messages: &[serde_json::Value]) -> Vec<serde_json::Value> {
|
||||
unique
|
||||
}
|
||||
|
||||
/// Replays the recorded fake PTY sockets (E.13a): each socket sends the TS fake's messages once the scenario reached
|
||||
/// the same step and the TUI sent as many frames, and keeps the frames the TUI sent.
|
||||
/// Replay PTY socket messages at their recorded steps once the client connects.
|
||||
struct Sockets {
|
||||
recorded: Vec<app::SocketRecording>,
|
||||
step: Arc<AtomicUsize>,
|
||||
@@ -423,7 +411,6 @@ impl pty::Connector for Sockets {
|
||||
fn slot_plugin() -> abi::Plugin {
|
||||
fn setup(setup: &mut abi::Setup) -> Result<(), String> {
|
||||
for path in [slot::HOME_FOOTER, slot::SESSION_COMPOSER_TOP] {
|
||||
// TS pads the left edge only; the line is short, so the right edge's padding shows nothing.
|
||||
let node = Node::column(vec![Node::text([Span::new(format!("slot plugin: {path}"))]).fg("text.muted")]);
|
||||
setup.slot(Placement::append(path), move |_, _, _| Render::Show(node.clone().padding(2, 0)));
|
||||
}
|
||||
@@ -441,7 +428,7 @@ fn app_plugin() -> abi::Plugin {
|
||||
abi::Plugin { id: "parity.app", setup }
|
||||
}
|
||||
|
||||
/// `parity/plugins/fence/tui.tsx`, as a renderer claim of `parity` fences (Pr): each line of the fence after a label.
|
||||
/// Render a label and the lines of each claimed fence.
|
||||
fn fence_plugin() -> abi::Plugin {
|
||||
fn setup(setup: &mut abi::Setup) -> Result<(), String> {
|
||||
setup.claim(abi::claim::Claim::fence("parity", |_, part| {
|
||||
@@ -495,7 +482,7 @@ fn p0a_plugin() -> abi::Plugin {
|
||||
abi::Plugin { id: "parity.p0a", setup }
|
||||
}
|
||||
|
||||
/// `parity/plugins/p0b/tui.tsx`: one line appended to `app` that shows what the reads of ABI 1.6 answer.
|
||||
/// Append a line showing the plugin's host reads.
|
||||
fn p0b_plugin() -> abi::Plugin {
|
||||
fn setup(setup: &mut abi::Setup) -> Result<(), String> {
|
||||
setup.slot(Placement::append(slot::APP), |read, input, _| {
|
||||
@@ -568,8 +555,7 @@ fn npm_config(config: &serde_json::Value) -> String {
|
||||
config.to_string()
|
||||
}
|
||||
|
||||
/// js-npm: an npm cache in a temporary directory holding each package of `packages` (spec to tarball name) as TS's
|
||||
/// `Npm.add` leaves it, as the TS recorder lays it out (`npmCache` in parity/app/scenarios.test.tsx).
|
||||
/// Build the npm cache layout for the pinned packages in an isolated directory.
|
||||
#[cfg(feature = "ts")]
|
||||
fn cache(packages: &BTreeMap<String, String>) -> opencode_util::temp::TempDir {
|
||||
let cache = opencode_util::temp::tempdir().expect("npm cache");
|
||||
@@ -634,12 +620,7 @@ fn routes(recording: &Recording) -> Vec<MemoryRoute> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Waits for `until` (bounded by [`UNTIL`]), then until nothing is in flight (`in_flight`), two renders 25 ms apart are
|
||||
/// equal, and the frame is `expected` (bounded by [`SETTLE`]). A frame can stay still before a read that changes it
|
||||
/// has even been sent, so stillness alone is not enough. Each 25 ms passes on the app's manual clock too: the TS
|
||||
/// recorder's settle lets real time pass, 30 ms a poll, three polls at least, and its timers run in it, such as the
|
||||
/// 50 ms poll by which the open list follows its prompt (flakes-10). A frozen clock left a list opened before its prompt
|
||||
/// laid out one row tall.
|
||||
/// Wait for readiness, idle requests, and matching cells across two renders. Retry with a bounded deadline.
|
||||
pub(crate) fn settle(
|
||||
app: &TestApp,
|
||||
in_flight: &dyn Fn() -> usize,
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
//! Pastes, attachments, and the stash (E.4) over a fixture server that records requests. Clipboard reads go
|
||||
//! to the test sink (`features::links::testing`), never to the real clipboard.
|
||||
//!
|
||||
//! - Long pastes collapse into parts that submit their text, and expand on a click or a second paste.
|
||||
//! - Clipboard images and pasted file paths attach as `[Image N]`, preview above the prompt, and open in the
|
||||
//! image preview dialog.
|
||||
//! - The stash pushes, pops, and lists, and `prompt-stash.jsonl` is shared with the TypeScript TUI (P-FILE).
|
||||
//! Clipboard reads use a test sink; the fake server records attachment and stash requests.
|
||||
|
||||
use crate::support::{self, DIRECTORY, Fake, Harness, Log, WAIT, deref_harness};
|
||||
|
||||
@@ -48,7 +42,7 @@ impl Setup {
|
||||
Self::with(opencode_util::temp::tempdir().unwrap(), Info::default(), false)
|
||||
}
|
||||
|
||||
/// Releasing a drag copies it, which is the default outside Windows only (`app.tsx:586`).
|
||||
/// Enable copy-on-select explicitly across platforms.
|
||||
fn copying_on_select() -> Self {
|
||||
let info = opencode_local::cli_config::merge(&[Some(json!({ "terminal": { "copy": "select" } }))]);
|
||||
Self::with(opencode_util::temp::tempdir().unwrap(), info, false)
|
||||
@@ -148,8 +142,6 @@ fn a_second_paste_or_a_click_expands_a_paste_and_backspace_removes_it() {
|
||||
setup.wait_text("");
|
||||
}
|
||||
|
||||
// #63265 (`prompt-paste.test.tsx`): undo brings a cleared paste label back as the paste, so a submit sends its text.
|
||||
// A fragment of the label comes back as plain text.
|
||||
#[test]
|
||||
fn undo_submits_the_restored_paste_and_a_fragment_as_text() {
|
||||
let pasted = "one\ntwo\nthree\nfour";
|
||||
@@ -461,7 +453,7 @@ fn stash_file_is_shared_with_typescript() {
|
||||
again.wait_stash_file(str::is_empty);
|
||||
}
|
||||
|
||||
/// The TypeScript TUI's `push`: one appended line, without a lock.
|
||||
/// Append one unlocked line as an independent stash writer.
|
||||
fn ts_stash(state: &Path, text: &str) {
|
||||
use std::io::Write;
|
||||
let line = json!({
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! Attention sounds (E.19b) through the whole TUI: an event the notifications plugin reacts to hands its sound to the
|
||||
//! audio engine. Tests never open a playback device, so the engine mixes without one and the test reads the mix.
|
||||
//! Deliver notification sounds through the TUI to the test audio engine.
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
//! Which clicks move the keyboard focus (`rs-click-focus`). TS runs the renderer with `autoFocus: false`
|
||||
//! (`app.tsx:258`), so a click moves no focus by itself: the transcript, the sidebar, the tabs, the footer, and a
|
||||
//! toast leave the prompt focused. Only the prompt (`prompt/index.tsx:1838-1844`), an embedded terminal
|
||||
//! (`EmbeddedTerminal.forwardMouse`), and a panel's host (`panel-host.tsx:34`) take it, and a click on the session
|
||||
//! pane while the right pane has it gives it back to the prompt (`session-frame.tsx:300-322`).
|
||||
//! Focus follows handled clicks, not every mouse press.
|
||||
|
||||
use crate::support;
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! Prompt autocomplete (E.3) over a fixture server that records requests: slash commands (the
|
||||
//! keymap's and the server's), `@` mentions of agents, skills, references, and files, `/cd` with
|
||||
//! directory completion and recents, and the mentions as atomic prompt parts.
|
||||
//! Exercise completion through key bindings, submitted parts, and persisted recents.
|
||||
|
||||
use crate::support::{self, DIRECTORY, Fake, Harness, Log, WAIT, deref_harness, list};
|
||||
|
||||
@@ -132,7 +130,6 @@ impl Setup {
|
||||
fn slash_lists_commands_and_enter_runs_one_without_arguments() {
|
||||
let setup = Setup::new();
|
||||
setup.app.type_text("/");
|
||||
// The first ten of the sorted list, keymap commands with their titles; E.14's `/btw` is among them.
|
||||
let screen = setup.wait_for("/agents");
|
||||
for row in ["/btw", "/cd", "/compact", "Change working directory"] {
|
||||
assert!(screen.contains(row), "{row:?} missing:\n{screen}");
|
||||
@@ -150,13 +147,10 @@ fn slash_lists_commands_and_enter_runs_one_without_arguments() {
|
||||
assert!(setup.requests("POST", "/prompt").is_empty());
|
||||
}
|
||||
|
||||
/// Slash commands TS declares that this fixture's session route does not list: `/restart` (deviation K04), and
|
||||
/// the ones TS also offers only in a state the fixture lacks (an available update, release highlights, a revert to
|
||||
/// redo, terminal support).
|
||||
/// Commands absent from this fixture's session route.
|
||||
const SLASH_ELSEWHERE: &[&str] = &["restart", "update", "highlights", "redo", "terminal"];
|
||||
|
||||
// Every `slash: { name, aliases }` in the TS TUI sources, with the id of the command it sits in, against the
|
||||
// commands the Rust keymap registers. E.3's fixture shows only a filtered list.
|
||||
// Compare registered slash names and aliases with their declarations in the reference client.
|
||||
#[test]
|
||||
fn slash_names_and_aliases_match_the_typescript_sources() {
|
||||
let tui = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../tui/src");
|
||||
@@ -186,8 +180,7 @@ fn slash_names_and_aliases_match_the_typescript_sources() {
|
||||
assert!(missing.is_empty() && extra.is_empty(), "TypeScript only: {missing:#?}\nRust only: {extra:#?}");
|
||||
}
|
||||
|
||||
/// `<command id> /<name> [aliases]` for each `slash: {` block under `dir`. The id is the nearest `id: "…"` or
|
||||
/// `name: "…"` before the block, as the TS command objects declare it.
|
||||
/// Find command IDs and aliases in slash declarations, ignoring lines outside each declaration.
|
||||
fn typescript_slashes(dir: &Path) -> Vec<String> {
|
||||
let mut entries: Vec<_> = std::fs::read_dir(dir).unwrap().map(|entry| entry.unwrap().path()).collect();
|
||||
entries.sort();
|
||||
@@ -342,8 +335,7 @@ fn a_mention_keeps_its_part_through_a_theme_switch() {
|
||||
);
|
||||
}
|
||||
|
||||
// Undo brings a deleted mention's mark back with its id, but not its part: TS maps parts by mark id and forgets the
|
||||
// id with the part (`syncExtmarksWithPromptParts`), so the mention is sent as text.
|
||||
// Undo restores the mention's text but not the removed attachment.
|
||||
#[test]
|
||||
fn undo_brings_a_mention_back_as_text() {
|
||||
let setup = Setup::new();
|
||||
@@ -528,9 +520,6 @@ fn escape_hides_and_ctrl_c_dismisses_the_command() {
|
||||
setup.wait_for("/agents");
|
||||
}
|
||||
|
||||
/// Expected (js-followups, TS `autocomplete.tsx` keeps `store.selected` until the filter changes): the route mounting
|
||||
/// again under an open list, as it does when a plugin loads or reloads, keeps the list open with its search and the
|
||||
/// selection by its place, and the screen equals the one before. Keys go on to the list, and Enter runs its command.
|
||||
#[test]
|
||||
fn an_open_list_stays_open_when_the_route_mounts_again() {
|
||||
let setup = Setup::new();
|
||||
@@ -547,9 +536,6 @@ fn an_open_list_stays_open_when_the_route_mounts_again() {
|
||||
assert_eq!(setup.text(), "");
|
||||
}
|
||||
|
||||
/// Expected (select-search-flake, the lane's `P.8/select-search`): a list typed into a composer that a plugin's load
|
||||
/// mounted again, before the screen laid it out, lays out as the list of a composer that was never remounted: all its
|
||||
/// rows, the first selected, once the frame comes.
|
||||
#[test]
|
||||
fn a_list_typed_before_a_remounted_composer_lays_out_shows_every_row() {
|
||||
let screen = |remount: bool| {
|
||||
@@ -569,9 +555,6 @@ fn a_list_typed_before_a_remounted_composer_lays_out_shows_every_row() {
|
||||
assert_eq!(screen(true), twin);
|
||||
}
|
||||
|
||||
/// Expected (flakes-10, the lane's `P.8/select-search` again): the P-APP replay's settle, which compares a checkpoint,
|
||||
/// shows a list typed into a remounted composer before it laid out with all its rows, as the TS recorder's settle does
|
||||
/// once its 50 ms poll ran. On a frozen app clock the follow never ran, and the list stayed one row tall.
|
||||
#[test]
|
||||
fn the_replay_settles_a_list_typed_before_its_composer_laid_out() {
|
||||
let screen = |remount: bool| {
|
||||
@@ -583,7 +566,6 @@ fn the_replay_settles_a_list_typed_before_its_composer_laid_out() {
|
||||
setup.app.type_text("/se");
|
||||
setup.wait_for("Open settings");
|
||||
let settled = crate::app::settle(&setup.app, &|| 0, None, |_| true);
|
||||
// The settled frame is the last one painted: its text is the app's now.
|
||||
(settled, setup.app.render().text())
|
||||
};
|
||||
let (twin, text) = screen(false);
|
||||
@@ -607,8 +589,6 @@ fn an_open_list_keeps_its_height_across_two_remounts_in_one_turn() {
|
||||
assert_eq!(setup.app.render().text(), before);
|
||||
}
|
||||
|
||||
/// Expected (review jsnpm-1): a dialog opened over an open list keeps its keys across a remount, as without one. Escape
|
||||
/// closes it and the list is open again under it, and Ctrl+C closes the dialog and does not end the client.
|
||||
#[test]
|
||||
fn a_dialog_over_an_open_list_keeps_its_keys_across_a_remount() {
|
||||
let setup = Setup::new();
|
||||
@@ -628,8 +608,6 @@ fn a_dialog_over_an_open_list_keeps_its_keys_across_a_remount() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Expected (review jsnpm-1): an `@` list keeps its file search's results and its selection across a remount: Enter
|
||||
/// picks the same row as a list that never remounted, and the search is not asked again.
|
||||
#[test]
|
||||
fn a_file_list_keeps_its_results_and_selection_across_a_remount() {
|
||||
let picked = |remount: bool| {
|
||||
@@ -673,7 +651,7 @@ fn frecency_file_is_shared_with_typescript() {
|
||||
assert_eq!(rust.lines().count(), 2, "{rust}");
|
||||
let state = setup.home.path().join("state");
|
||||
|
||||
// TypeScript keeps the latest line per path and counts on from it.
|
||||
// The last frequency line for a path wins.
|
||||
let frequencies = typescript_frecency(&root, &state, json!(["src/main.rs", "README.md"]));
|
||||
assert_eq!(frequencies, json!({ "/project/src/main.rs": 3, "/project/README.md": 1 }));
|
||||
let typescript = std::fs::read_to_string(state.join("frecency.jsonl")).unwrap();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! The composer, the shell output dialog, and the client MCP tools (E.13b) through the whole TUI, over the in-memory
|
||||
//! transport, for the paths the P-APP scenario `E.13b/composer` does not reach: the client MCP experiment and its
|
||||
//! tools, interrupting a subagent, picking a terminal, the queued dock, and the output text.
|
||||
//! Exercise the composer, shell output, and client MCP tools against an in-memory transport.
|
||||
|
||||
use crate::support::{self, WAIT};
|
||||
|
||||
@@ -518,7 +516,7 @@ fn the_subagent_selection_follows_the_keys_while_subagents_stream_under_a_restin
|
||||
assert!(harness.wait(|harness| harness.rows().len() == 3));
|
||||
let rows = harness.rows();
|
||||
assert_eq!(harness.focused(), [rows[0]]);
|
||||
// The pointer rests on the first row, where the prompt was. Rows redrawn under it must not take the selection.
|
||||
// A stationary pointer must not change selection when rows redraw beneath it.
|
||||
let (x, y) = harness.at(&format!("Explore: {} ()", rows[0])).unwrap();
|
||||
harness.app.hover(x, y);
|
||||
for (key, expected) in [("down", 1), ("down", 2), ("up", 1)] {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! The live config (`rs-ms34-config`): settings writes and outside `cli.json` edits reach every reader at once,
|
||||
//! as TS's reactive `ConfigProvider` does (`packages/tui/src/config/index.tsx:354-371`), and writes queue
|
||||
//! instead of dropping.
|
||||
//! Apply live config changes from both settings writes and external file replacements.
|
||||
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
@@ -66,7 +64,7 @@ fn the_leader_sequence_expires_on_the_app_clock() {
|
||||
let app = TestApp::new(100, 30);
|
||||
let tui = support::mount_empty(&app, opencode_local::cli_config::decode_text(config).unwrap(), None);
|
||||
app.press("ctrl+x");
|
||||
// The first read prunes the sequence's captures, which restarts the timer as in TS; a frame reads it at once.
|
||||
// Reading the pending sequence prunes captures and restarts its timer.
|
||||
assert!(tui.keymap.leader_active());
|
||||
app.advance(Duration::from_millis(wait));
|
||||
assert_eq!(tui.keymap.leader_active(), completes, "{config} after {wait} ms");
|
||||
@@ -115,7 +113,7 @@ fn an_outside_cli_json_edit_reloads() {
|
||||
let app = TestApp::new(100, 30);
|
||||
let (tui, file) = mount_with_file(&app, home.path(), "{}\n");
|
||||
assert!(Tabs::enabled(&tui));
|
||||
// As the TS TUI or an editor would: a new file renamed over the old one.
|
||||
// Simulate an editor's atomic replacement.
|
||||
let temp = file.with_extension("json.edit");
|
||||
std::fs::write(&temp, "{\n // edited elsewhere\n \"tabs\": { \"mode\": \"off\" }\n}\n").unwrap();
|
||||
std::fs::rename(&temp, &file).unwrap();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The diff viewer's lifetime (`reviews/ms3-ms4.review-carbon.md` carbon-1): a viewer goes with its panel, so its
|
||||
//! file menu and its last-turn watch end when the panel closes.
|
||||
//! Exercise the diff viewer's lifecycle and controls over real input and recorded server responses.
|
||||
|
||||
use crate::support;
|
||||
|
||||
@@ -148,8 +147,7 @@ impl Diffs {
|
||||
.count()
|
||||
}
|
||||
|
||||
/// A turn of `session` starts and ends within one turn of the UI: the store applies both before the UI hears of
|
||||
/// the first, as on a loaded machine (`steps/flakes-8.md`).
|
||||
/// Deliver start and end in the same UI turn so both events arrive before the next sync.
|
||||
fn short_turn(&self, session: &str) {
|
||||
for (kind, status) in [
|
||||
("session.execution.started", SessionStatus::Running),
|
||||
@@ -171,9 +169,8 @@ impl Diffs {
|
||||
}
|
||||
}
|
||||
|
||||
/// Waits until the diff loaded after the `before`-th read has landed in the viewer: the read was sent, its reply
|
||||
/// taken, and the content it gives held. A reload releases the content of the load before as it starts, so until its
|
||||
/// reply is drawn the viewer holds none.
|
||||
/// Wait for the requested diff to become visible; observing a request alone does not guarantee the reply has
|
||||
/// rendered.
|
||||
fn reloaded(&self, before: usize) {
|
||||
let held = || opencode_plugin::surface::ledger_of("opencode.diffs").content_bytes;
|
||||
let landed = self
|
||||
@@ -311,7 +308,7 @@ fn a_large_added_file_shows_its_start_and_end() {
|
||||
h.tui.keymap.dispatch("diff.first", None);
|
||||
h.wait_for("row-0000");
|
||||
h.app.resize(if width == 80 { 160 } else { 80 }, 20);
|
||||
// The viewer draws again at the new width first (TS awaits a flush).
|
||||
// Render at the new width before checking the layout.
|
||||
h.app.render();
|
||||
h.tui.keymap.dispatch("diff.last", None);
|
||||
h.wait_for("row-7499");
|
||||
@@ -358,9 +355,6 @@ fn the_viewer_runs_on_both_carriers() {
|
||||
}
|
||||
}
|
||||
|
||||
// The scenarios of synthesis 4.9 by name, and the hunk rules the host's verbs and reads now hold (P6c). Each opens the
|
||||
// full-screen route from Home, with the file tree beside the cards, over files of one modified hunk each.
|
||||
|
||||
fn hunk_file(index: usize, lines: usize) -> Value {
|
||||
let body: String = (0..lines)
|
||||
.map(|line| match line {
|
||||
@@ -692,7 +686,6 @@ fn ctrl_c_closes_one_level_of_the_viewer() {
|
||||
});
|
||||
}
|
||||
|
||||
/// The viewer's settings as the TUI config holds them now.
|
||||
fn diffs_setting(h: &Diffs) -> serde_json::Value {
|
||||
h.tui.settings.info().to_value()["diffs"].clone()
|
||||
}
|
||||
@@ -882,8 +875,6 @@ fn the_docked_footer_follows_the_panels_focus() {
|
||||
assert_eq!(footer(&h), focused, "the footer did not light again");
|
||||
}
|
||||
|
||||
// Expected (TS's turn watch, `steps/flakes-8.md`): a turn that starts and ends before the UI hears of its start still
|
||||
// loads the last turn's diff again, on both carriers; another session's turn loads nothing.
|
||||
#[test]
|
||||
fn a_turn_too_short_to_see_running_loads_the_diff_again() {
|
||||
for abi in [false, true] {
|
||||
@@ -1136,8 +1127,6 @@ fn the_viewers_dialogs_end_with_it() {
|
||||
});
|
||||
}
|
||||
|
||||
// Expected (carbon's review of P6c, 4): a plugin's image preview takes only images the host decodes, as an image node
|
||||
// would, and has the key `images`, which `Dialog::Close` closes.
|
||||
#[test]
|
||||
fn a_plugin_image_preview_is_bounded_and_keyed() {
|
||||
let h = route(1, 4, 120, 30);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! H.4: the real TUI on a headless app, driven over the `OPENCODE_DRIVE` endpoint by a client on another thread.
|
||||
//! Drive the headless TUI over its simulation endpoint from another thread.
|
||||
|
||||
use crate::support;
|
||||
|
||||
|
||||
@@ -134,8 +134,7 @@ fn ide_mentions_insert_file_parts_with_their_lines() {
|
||||
let marks = setup.textarea().extmarks();
|
||||
assert_eq!(marks.len(), 1);
|
||||
assert_eq!((marks[0].start, marks[0].end), (8, 25));
|
||||
// One line, outside the project: an absolute path and no end. `normalizeMentionPath` gives `path.resolve` with
|
||||
// `/` separators, so on Windows the path takes the working directory's drive, `D:/elsewhere/a b.ts`.
|
||||
// A drive-less absolute path gains the current drive on Windows.
|
||||
ide.notify("at_mentioned", json!({ "filePath": "/elsewhere/a b.ts", "lineStart": 4, "lineEnd": 4 }));
|
||||
let elsewhere = format!("{}#4", Flavor::NATIVE.resolve(&["/elsewhere/a b.ts"]).replace('\\', "/"));
|
||||
setup.wait("the second mention", || setup.textarea().text().ends_with(&format!("@{elsewhere} ")));
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
//! The form prompt (E.9b) over a fixture server: a pending form shows above the session prompt or over home, and
|
||||
//! each answer sends one request (P-REQ: method, path, body, and the directory header of a global form). The
|
||||
//! server answers 204, as it does, and lists no forms once one settled. The flows follow
|
||||
//! `packages/tui/test/cli/tui/form.test.tsx`.
|
||||
//!
|
||||
//! P-COMP: `parity/component/E.9b-form.tsx` renders the TS prompt alone at 96x30, one fixture per field kind and
|
||||
//! the review; here the prompt sits in the session route of a 100x30 app, two columns in. The comparison covers
|
||||
//! the prompt's rows (those with its left border).
|
||||
//! Drive session and global forms through their visible fields and inspect the submitted answers.
|
||||
|
||||
use crate::support::{self, Fake, Harness, WAIT, deref_harness};
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The home footer on the one plugin API (O-67): its nested `home.footer.status` slot, which keeps rendering while
|
||||
//! the footer keeps its node, and the footer through the C ABI's byte shims.
|
||||
//! Home footer status claims across carriers and screen sizes.
|
||||
|
||||
use crate::support::{self, DIRECTORY, Fake, Harness, list};
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
//! The mouse pointer shape (OSC 22) over the TUI. TS never asks for one (Core 0.8.1's renderables set none and
|
||||
//! `packages/tui/src` never calls `setMousePointer`). The Rust TUI shows the hand over every element that acts on
|
||||
//! a click and the resize shape over the pane resize handle, a deliberate deviation
|
||||
//! (`parity/deviations/W01-hand-pointer.md`). Text, the transcript, and the prompt keep the default pointer.
|
||||
//! Inspect the pointer shape for clickable and non-clickable cells.
|
||||
|
||||
use crate::support::{self, WAIT};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! TypeScript: `parity/component/E.17a-integrations.tsx`.
|
||||
//! Integration dialogs and their credential requests.
|
||||
|
||||
use crate::support::{self, Fake, Harness, Log, WAIT, deref_harness, list};
|
||||
|
||||
@@ -547,7 +547,6 @@ fn form_steps_open_a_link_take_an_own_answer_and_a_multiselect() {
|
||||
}));
|
||||
let kit = Kit::with(list, "auto");
|
||||
opencode_tui::dialogs::integration::show_auto_connect(&kit.tui, &IntegrationID("mcp_aws".into()), None);
|
||||
// "I finished" stays hidden until the link was opened.
|
||||
kit.wait_for("Open link");
|
||||
assert!(!kit.app.text().contains("I finished"));
|
||||
kit.app.press("return");
|
||||
@@ -555,8 +554,7 @@ fn form_steps_open_a_link_take_an_own_answer_and_a_multiselect() {
|
||||
assert_eq!(*kit.opened.borrow(), ["https://aws.example/login"]);
|
||||
kit.down(1);
|
||||
kit.app.press("return");
|
||||
// The own answer: row 2, typed, submitted with Enter. The list is as tall as its rows without their gaps
|
||||
// (`count` in TS), so row 2 scrolls into view when selected.
|
||||
// The second choice can be below the viewport because the height counts options but excludes the gaps.
|
||||
kit.wait_for("1. default");
|
||||
kit.down(1);
|
||||
kit.wait_for("2. Type your own answer");
|
||||
|
||||
@@ -35,14 +35,13 @@ mod plugin_builtins;
|
||||
mod plugin_canvas;
|
||||
mod plugin_carriers;
|
||||
mod plugin_claim;
|
||||
// The JS host's rows (TypeScript plugins): in a build with the `ts` feature only (ts-feature).
|
||||
#[cfg(feature = "ts")]
|
||||
mod plugin_compat;
|
||||
// The JS host's rows (TypeScript plugins): in a build with the `ts` feature only (ts-feature).
|
||||
mod plugin_contain;
|
||||
#[cfg(feature = "ts")]
|
||||
mod plugin_fences;
|
||||
mod plugin_fetch;
|
||||
mod plugin_field_echo;
|
||||
mod plugin_flood;
|
||||
pub mod plugin_input;
|
||||
mod plugin_limits;
|
||||
@@ -52,16 +51,12 @@ mod plugin_machines;
|
||||
mod plugin_mail;
|
||||
mod plugin_manager;
|
||||
mod plugin_model;
|
||||
// The JS host's rows (TypeScript plugins): in a build with the `ts` feature only (ts-feature).
|
||||
#[cfg(feature = "ts")]
|
||||
mod plugin_npm;
|
||||
// The JS host's rows (TypeScript plugins): in a build with the `ts` feature only (ts-feature).
|
||||
mod plugin_field_echo;
|
||||
#[cfg(feature = "ts")]
|
||||
mod plugin_ownership;
|
||||
mod plugin_p0a;
|
||||
mod plugin_pending_focus;
|
||||
// The JS host's rows (TypeScript plugins): in a build with the `ts` feature only (ts-feature).
|
||||
#[cfg(feature = "ts")]
|
||||
mod plugin_pipe;
|
||||
#[cfg(feature = "ts")]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! TypeScript: `parity/component/E.17b-mcp.tsx`.
|
||||
//! MCP and skill dialogs.
|
||||
|
||||
use crate::support::{self, Fake, Harness, Log, WAIT, deref_harness, list};
|
||||
|
||||
@@ -223,8 +223,6 @@ fn mcp_dialog_reads_the_list_once_and_space_toggles_each_server() {
|
||||
]
|
||||
);
|
||||
assert!(kit.requests("POST", "/api/experimental/mcp/").iter().all(|(_, _, body)| body.is_null()));
|
||||
// notion signs in through its integration: the integration dialog opens (E.17a) instead of a toggle. This
|
||||
// fixture serves no integrations, so it shows none.
|
||||
space_at(4);
|
||||
kit.wait_for("No integrations available");
|
||||
assert_eq!(kit.toggles().len(), 4);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! The transcript's other rows (E.6b) over a fixture server: compactions (running, done, failed,
|
||||
//! queued), shell, skill, notice and switch messages, errors and retries, the revert banner, the
|
||||
//! background hint, images, and the free-limit stop that offers OpenCode Go.
|
||||
//! Transcript messages, notices, errors, retries, and interaction with their rows.
|
||||
|
||||
use crate::support::{self, Fake, Harness, Log, WAIT, deref_harness};
|
||||
|
||||
@@ -256,7 +254,7 @@ fn the_revert_banner_counts_reverted_prompts_and_a_click_clears_it() {
|
||||
],
|
||||
}});
|
||||
let h = open(30, session(revert), messages, Vec::new(), Info::default());
|
||||
// The session can load before its messages, and TS then also counts 0 for a moment.
|
||||
// Wait for messages as well as the session before checking the revert count.
|
||||
let screen = h.wait_for("┃ 2 messages reverted");
|
||||
assert!(screen.contains("┃ M src/parser.rs +4 -2"), "{screen}");
|
||||
assert!(screen.contains("┃ A src/new.rs +10"), "{screen}");
|
||||
@@ -347,8 +345,7 @@ fn a_theme_switch_restyles_these_rows_in_place() {
|
||||
);
|
||||
}
|
||||
|
||||
/// The store takes events off the UI thread and the transcript syncs on its next frame, so a theme switch in between
|
||||
/// restyles against messages the rows were not rendered from: here a revert that hides the newest message.
|
||||
/// Switch themes between a store update and its next UI flush.
|
||||
#[test]
|
||||
fn a_theme_switch_before_the_sync_restyles_against_the_messages_the_store_holds() {
|
||||
let messages = vec![
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
//! Models and usage (E.16) over the fixture server of `parity/fixtures/E.16/server.json`:
|
||||
//!
|
||||
//! - P-COMP: each dialog against the cells `parity/component/E.16-models.tsx` wrote from the TS dialog;
|
||||
//! - P-REQ: the dialogs and commands send reads only, never `/api/experimental/session/stats`;
|
||||
//! - P-FILE: `model.json` as the TS model preference repository reads and writes it, in a temp dir;
|
||||
//! - the commands and keys through the whole TUI.
|
||||
//! Model selection and usage dialogs against recorded cells and server responses.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
@@ -89,7 +84,7 @@ impl Transport for Server {
|
||||
}
|
||||
}
|
||||
|
||||
/// The TS fixtures render in UTC; the Rust dialogs use local time, so each `resetsAt` moves by the local offset.
|
||||
/// Shift reset times by the local offset; the fixture records them in UTC.
|
||||
fn shift_resets(value: &mut Value) {
|
||||
match value {
|
||||
Value::Object(fields) => fields.iter_mut().for_each(|(key, field)| match field.as_i64() {
|
||||
@@ -241,7 +236,7 @@ fn go_upsell_art_matches_typescript_when_still() {
|
||||
);
|
||||
kit.wait_for("subscribe");
|
||||
support::wait_fixture(&kit.app, "E.16/go-upsell-art");
|
||||
// Without 24-bit color TS draws the logo's seven full blocks as "█"; Rust cannot tell and keeps its half blocks.
|
||||
// Without truecolor the reference uses full blocks for the logo; this renderer keeps its half blocks.
|
||||
let fixtures = opencode_parity::fixtures_dir();
|
||||
let expected = opencode_parity::Fixture::load(fixtures.join("E.16/go-upsell-art-256.json")).unwrap();
|
||||
let comparison = opencode_parity::compare(&expected, &opencode_parity::Fixture::from_capture(&kit.app.render()));
|
||||
@@ -421,7 +416,6 @@ fn ctrl_f_favorites_the_selected_model() {
|
||||
fn cycle_commands_move_through_recents_favorites_agents_and_variants() {
|
||||
let h = mount();
|
||||
let local = h.tui.local.clone();
|
||||
// F2: the first recent model, since the current one is not recent.
|
||||
h.app.press("f2");
|
||||
assert_eq!(local.current(), Some(Model::new("anthropic", "claude-haiku")));
|
||||
h.tui.keymap.dispatch("model.cycle_favorite", None);
|
||||
@@ -451,9 +445,6 @@ fn ctrl_t_cycles_the_variant_and_saves_it() {
|
||||
h.wait_file(|file| file["variant"]["anthropic/claude-sonnet"] == "low");
|
||||
}
|
||||
|
||||
// Expected: a `model.json` reload that read the file before a pending write landed does not undo the change the write
|
||||
// carries. Actual: the stale reload replaced the preferences, so a `ctrl+t` made while an earlier write's reload was
|
||||
// in flight fell back to the default variant (`high`), the `ctrl_t_cycles_the_variant_and_saves_it` flake.
|
||||
#[test]
|
||||
fn a_reload_that_read_the_file_before_a_pending_write_keeps_the_change() {
|
||||
let h = mount();
|
||||
@@ -531,7 +522,7 @@ fn model_json_is_shared_with_the_typescript_client() {
|
||||
"variant": { "anthropic/claude-sonnet": "default" },
|
||||
})
|
||||
);
|
||||
// TS writes under the same lock, and the running Rust TUI picks it up through its watcher.
|
||||
// An independent writer uses the same lock; the TUI should pick up its update through the watcher.
|
||||
run(&oracle, &["recent", h.state.to_str().unwrap(), "openai", "gpt-5-mini"]);
|
||||
let local = h.tui.local.clone();
|
||||
let reloaded = h.app.wait_until(WAIT, || local.recent().first() == Some(&Model::new("openai", "gpt-5-mini")));
|
||||
|
||||
@@ -103,8 +103,7 @@ fn open(messages: Vec<Value>, info: Info) -> Nav {
|
||||
let fake = fake(messages, older.clone(), failing.clone());
|
||||
let deps =
|
||||
Deps { config: support::config(info), route: support::session_route("ses_n"), ..support::deps(Arc::new(fake)) };
|
||||
// The transcript keeps the 15-row view these cases were written for (E.12 took the session header and
|
||||
// the column gaps out, so it grew by five rows at 80x30).
|
||||
// Keep a 15-row transcript viewport for the paging assertions.
|
||||
let h = Nav { harness: support::mount(80, 25, deps), older, failing };
|
||||
h.wait_for(&format!("Answer {last} three."));
|
||||
h
|
||||
@@ -303,9 +302,6 @@ fn message_navigation_aligns_messages_with_the_top() {
|
||||
assert_eq!(Nav::row(&screen, "Question 1"), Some(TOP + 1), "{screen}");
|
||||
}
|
||||
|
||||
/// A failed transcript read shows the error's message alone as a toast, without its tag: a session's first page, and
|
||||
/// an older page whichever move asked for it (deviation `O89-transcript-read-toast` for all but `session.first`, which
|
||||
/// toasts in TS too).
|
||||
#[test]
|
||||
fn a_failed_transcript_read_toasts_its_message() {
|
||||
for command in ["session open", "session.page.up", "session.message.user.previous", "session.first"] {
|
||||
@@ -400,8 +396,6 @@ fn a_tab_reopens_where_the_reader_left_it() {
|
||||
let left = transcript(&screen);
|
||||
assert!(left.iter().any(|line| line.contains("Jump to latest ↓")), "{screen}");
|
||||
|
||||
// Another tab opens at its newest rows; back on the first, the reader's rows show where they were
|
||||
// (`sessionTabs.setScrollAnchor`, `restoreScrollPosition`).
|
||||
switch("ses_m");
|
||||
let other = h.app.wait_until(WAIT, || {
|
||||
let screen = h.app.text();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The permission prompt (E.9a) over a fixture server: a pending request from the store shows above the
|
||||
//! prompt, and each answer sends one reply request (P-REQ: method, path, body).
|
||||
//! Drive permission decisions and inspect their server requests.
|
||||
|
||||
use crate::support::{self, Fake, Harness, WAIT, deref_harness};
|
||||
|
||||
@@ -238,8 +237,6 @@ fn autoaccept_replies_once_to_each_request_without_prompting() {
|
||||
assert!(!screen.contains("Permission required"), "{screen}");
|
||||
}
|
||||
|
||||
// `index.tsx:208-215`: in autoaccept the prompted list is empty, so a request already shown goes when the mode
|
||||
// turns on, and the session prompt comes back.
|
||||
#[test]
|
||||
fn turning_on_autoaccept_answers_and_hides_the_shown_request() {
|
||||
let harness = mount(
|
||||
@@ -342,13 +339,8 @@ fn a_pending_permission_does_not_take_the_plugin_manager_search() {
|
||||
harness.wait_for("Permission required");
|
||||
}
|
||||
|
||||
/// The permission prompt's model test (M5, `round2/models.md`): random asks, replies from this client and from
|
||||
/// others, reply failures, `autoaccept` toggles, session switches and keys, some dispatched before the keys of the
|
||||
/// prompt they replace are gone. After each event the test compares what the TUI shows, which keys it holds, which
|
||||
/// widget has focus and which replies the server got with a small model of the TS prompt.
|
||||
///
|
||||
/// `PERMISSION_SEED` runs one seed, `PERMISSION_SEEDS` sets how many seeds run otherwise, and `PERMISSION_STEPS`
|
||||
/// sets the events per seed.
|
||||
/// Generate asks, replies, cancellations, and failures across a session family. Compare the visible prompt and sent
|
||||
/// replies with the model after each action.
|
||||
mod model {
|
||||
use crate::support::{self, WAIT};
|
||||
|
||||
@@ -405,7 +397,7 @@ mod model {
|
||||
message: Option<String>,
|
||||
}
|
||||
|
||||
/// The server: pending requests in ask order, the replies it got, and whether it fails them now.
|
||||
/// Pending requests in arrival order, received replies, and injected failures.
|
||||
struct Server {
|
||||
memory: Memory,
|
||||
state: Mutex<ServerState>,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The prompt (E.2) over a fixture server that records requests: editing through the `input.*`
|
||||
//! layer, submit, queue, history, drafts, shell mode, clear, interrupt, and a new session from home.
|
||||
//! Prompt editing and submission over a request-recording transport.
|
||||
|
||||
use crate::support::{self, Harness, WAIT, deref_harness, list};
|
||||
|
||||
@@ -490,7 +489,7 @@ fn a_failed_create_goes_home_with_the_newer_text_and_closes_its_tab() {
|
||||
let opened = setup.app.wait_until(WAIT, || setup.tui.route() == Route::Session { id: id.clone() });
|
||||
assert!(opened, "{:?}", setup.tui.route());
|
||||
setup.app.type_text("follow up");
|
||||
// The create fails only now, so the route cannot go home before the wait above sees the session.
|
||||
// Release the failure only after the session becomes visible.
|
||||
setup.reject.store(false, Ordering::SeqCst);
|
||||
setup.wait_for("Creating a session failed");
|
||||
let home = setup.app.wait_until(WAIT, || setup.tui.route() == Route::Home);
|
||||
@@ -501,7 +500,6 @@ fn a_failed_create_goes_home_with_the_newer_text_and_closes_its_tab() {
|
||||
assert!(tabs.iter().all(|tab| tab.session_id != id.0), "{tabs:?}");
|
||||
}
|
||||
|
||||
// `routes/session/index.tsx:350-370`: a session the server does not have closes its tab instead of staying blank.
|
||||
#[test]
|
||||
fn a_missing_session_closes_its_tab() {
|
||||
let setup = Setup::new(support::session_route("ses_gone"));
|
||||
@@ -599,8 +597,7 @@ fn typescript_history(root: &Path, state: &Path, ops: Value) -> Value {
|
||||
serde_json::from_str(stdout.lines().last().unwrap_or_default()).unwrap()
|
||||
}
|
||||
|
||||
/// P-FILE: the TypeScript TUI reads the history the Rust prompt writes, rewrites it byte for byte,
|
||||
/// and the Rust prompt reads what TypeScript appends.
|
||||
/// Check history-file interoperability in both directions.
|
||||
#[test]
|
||||
fn history_file_is_shared_with_typescript() {
|
||||
let Some(root) = support::ts_root() else { return };
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! The prompt footer and its goal on the one plugin API (O-67): the goal read a mount starts, a `changed` event that
|
||||
//! comes before that read returns, a remount while it is in flight, the narrow busy footer, and the goal panel through
|
||||
//! the C ABI's byte shims (`Loopback`).
|
||||
//! Goal footer updates across pending reads and mount changes.
|
||||
|
||||
use crate::support::{self, DIRECTORY, Harness};
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The store-to-UI pump survives a full UI queue (reviews bigboi-1 and carbon-2 of the plugin fixes): a burst while
|
||||
//! the UI thread is busy delays events, it never stops later ones.
|
||||
//! Exercise store-to-UI delivery while the UI queue is full.
|
||||
|
||||
use crate::support::{self, DIRECTORY};
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! Queued prompts and pending prompt actions (E.10b) over a fixture server that logs every request: the dock, the
|
||||
//! queued prompts dialog (steer, delete, undo), the pending steer dialog, and the message actions dialog. Writes
|
||||
//! answer 204 where the server does; `fail` answers the inbox writes with a 409.
|
||||
//! Interact with queued prompts through the dock and message dialogs.
|
||||
|
||||
use crate::support::{self, Fake, Harness, Log, WAIT, deref_harness};
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! A reconnect reads the location again, config included (review carbon-2 of MS6), also when the connection
|
||||
//! status never showed the stream down: a `resync` or a fast reconnect leaves only the new `server.connected`.
|
||||
//! A reconnect must refresh state even if the UI never observes the disconnected status.
|
||||
|
||||
use crate::support::{self, WAIT};
|
||||
|
||||
@@ -66,8 +65,7 @@ impl Transport for Transcript {
|
||||
}
|
||||
}
|
||||
|
||||
// R4-1: the events of a turn lost with the old stream (a stall after Ctrl+Z) reach the open session through its reads
|
||||
// on the next `server.connected`, as TS reads the session and its rows again when the connection turns connected.
|
||||
// The next connection's reads recover events missed during suspension.
|
||||
#[test]
|
||||
fn a_reconnect_reads_the_open_transcript_again() {
|
||||
let user = |id: &str, text: &str, created: u64| json!({ "id": id, "type": "user", "text": text, "time": { "created": created } });
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! Regressions for the `carbon` review of MS1 (`reviews/ms1.review-carbon.md`): session views that leave their
|
||||
//! keys behind (carbon-2), keymap conditions that lock the store (carbon-5), and permission reads and focus
|
||||
//! after a reconnect or under a dialog (carbon-6).
|
||||
//! Session key ownership and permission refresh across route and connection changes.
|
||||
|
||||
use crate::support::{self, WAIT};
|
||||
|
||||
@@ -153,7 +151,7 @@ fn a_reconnect_reads_permissions_again() {
|
||||
let h = mount(support::session_route("ses_a"));
|
||||
h.wait_for("the session", |screen| screen.contains("Review"));
|
||||
h.app.advance(Duration::from_millis(50));
|
||||
// Asked while the stream was down: only the read after the reconnect can see it.
|
||||
// Only the reconnect read can discover a request added while the stream is down.
|
||||
h.server.permissions.lock().unwrap().push(permission());
|
||||
h.server.memory.emit(&json!({ "id": "evt_again", "type": "server.connected", "data": {} }));
|
||||
h.wait_for("the permission prompt", |screen| screen.contains("Permission required"));
|
||||
|
||||
@@ -372,15 +372,13 @@ fn startup_agent_and_model_reach_the_selection() {
|
||||
h.agent().as_deref() == Some("plan") && h.tui.local.current() == Some(Model::new("demo", "other"))
|
||||
});
|
||||
assert_eq!(h.tui.local.recent(), [Model::new("demo", "other")]);
|
||||
// `--agent` shows over a session's own agent until the user picks one there (`local.tsx:90-96`).
|
||||
h.tui.navigate(session_route("ses_b"));
|
||||
h.wait_for("Write the docs");
|
||||
assert_eq!(h.agent().as_deref(), Some("plan"));
|
||||
assert_eq!(h.writes(), Vec::<String>::new());
|
||||
}
|
||||
|
||||
// `--model` leaves the model saved on the session `-s` opens, and stays `fallbackModel`'s first choice
|
||||
// (`local.tsx:184-196,266-283`, `app.tsx:666-686`).
|
||||
// An existing session keeps its saved model; the flag still leads fallback selection.
|
||||
#[test]
|
||||
fn startup_model_keeps_a_saved_session_model_and_leads_the_fallback() {
|
||||
let h =
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The root command's TUI arguments (C.13) that P-APP cannot record, because the TS app fixture passes no
|
||||
//! `environment`: the terminal's variables go to the session on a local server, and to nobody otherwise.
|
||||
//! Drive terminal-environment uploads through the root command's TUI arguments.
|
||||
|
||||
use crate::support;
|
||||
|
||||
@@ -126,8 +125,7 @@ fn an_opened_session_gets_the_environment_only_on_a_local_server() {
|
||||
}
|
||||
}
|
||||
|
||||
/// TS uploads when the status turns connected (`app.tsx:529-539`), which follows `server.connected`
|
||||
/// (`connection.ts:114-115`). The connection is driven by hand to get that order.
|
||||
/// Trigger the upload on connected status; an earlier event alone does not suffice.
|
||||
#[test]
|
||||
fn the_environment_is_uploaded_when_the_status_follows_server_connected() {
|
||||
let app = TestApp::new(100, 30);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! TypeScript: `packages/tui/test/ui/session-link.test.tsx`.
|
||||
//! Session links through rendered Markdown and mouse input.
|
||||
|
||||
use crate::support::{self, DIRECTORY, Harness, Seen};
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The session view's follow-ups to `rs-ms34-session`, over the in-memory transport with its request log
|
||||
//! (P-REQ): `session.submit_scroll` after a send, and usage limits kept per location as TS keys them.
|
||||
//! Session viewport behavior and its store subscriptions.
|
||||
|
||||
use crate::support::{self, WAIT};
|
||||
|
||||
@@ -235,7 +234,6 @@ impl Harness {
|
||||
|
||||
#[test]
|
||||
fn a_send_returns_to_the_newest_rows_unless_submit_scroll_is_keep() {
|
||||
// `onSubmit` calls `toBottom` unless `session.submit_scroll` is `keep` (`index.tsx:1650-1652`).
|
||||
let h = mount("ses_a", json!({ "animations": false }));
|
||||
h.send_while_away();
|
||||
h.wait("the newest rows", || {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! TypeScript: `parity/component/E.11a-sessions.tsx`.
|
||||
//! Session list and open-dialog navigation.
|
||||
|
||||
use crate::support::{self, Fake, Harness, Log, WAIT, deref_harness};
|
||||
|
||||
@@ -175,8 +175,7 @@ impl Kit {
|
||||
};
|
||||
let harness = support::mount_on(support::dark_app(100, 34), deps, Args::default());
|
||||
let kit = Self { harness, log, state, _home: home };
|
||||
// The scoped sessions go into the store, as the TS script remembers them. The read names the
|
||||
// `directory`, so `dialog_reads` leaves it out.
|
||||
// Exclude the background list read, identifiable by its directory, from dialog reads.
|
||||
let ids: Vec<&str> = match mode {
|
||||
Mode::List => vec!["ses_a", "ses_b", "ses_c"],
|
||||
Mode::Open => vec!["ses_r1", "ses_r2", "ses_r3"],
|
||||
@@ -219,10 +218,7 @@ impl Kit {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The dialog's reads, in order: location, projects, and sessions. The home's own list read
|
||||
/// (by `directory`; a theme change that alters the colors remounts the home, which reads again) and the
|
||||
/// prompt's catalog reads after connect are left out; TS does not order those against the
|
||||
/// dialog.
|
||||
/// Dialog reads in order, excluding the background session list.
|
||||
fn dialog_reads(&self) -> Vec<String> {
|
||||
self.requests()
|
||||
.into_iter()
|
||||
@@ -365,8 +361,6 @@ fn open_reads_the_worktrees_again_on_worktree_updated() {
|
||||
harness.wait("worktree.updated read nothing", || reads() == 2);
|
||||
}
|
||||
|
||||
// Both dialogs read the store's projects (`dialog-open.tsx:210,239`, `dialog-session-list.tsx:138-157`), so a
|
||||
// project renamed while one is open shows its new name.
|
||||
#[test]
|
||||
fn open_and_session_list_follow_project_updated() {
|
||||
let (harness, memory) = evented();
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
//! Settings, experiments, debug, and the DevTools bar (E.18a).
|
||||
//!
|
||||
//! - P-COMP: `parity/component/E.18a-settings.tsx` renders the TS dialogs alone; here they open over the whole
|
||||
//! TUI, so the comparison covers the dialog panel (the cells with the panel background in the fixture).
|
||||
//! - P-ORACLE: every field of `SETTINGS` against the TS table, through `parity/oracle/E.18a-settings.ts`.
|
||||
//! - `TestApp`: changes, the palette's settings rows, the debug dialog, and the bar.
|
||||
//! - P-FILE: settings writes go to a `cli.json` in a temporary home, and the TS `Config` service reads them
|
||||
//! back through `parity/oracle/F.5-config.ts` (skipped without bun and `node_modules`).
|
||||
//! Settings, experiment, debug, and developer-tool interactions.
|
||||
|
||||
use crate::support::{self, WAIT, wait_for};
|
||||
|
||||
@@ -55,8 +48,7 @@ fn assert_dialog(app: &TestApp, name: &str, title: &str) {
|
||||
assert!(comparison.is_equal(), "P-COMP {name} (panel {left}..={right} x {top}..={bottom}): {comparison}");
|
||||
}
|
||||
|
||||
// The P-COMP fixtures show only the first screen and two filters; this compares every field of every row with
|
||||
// the TS table itself, read live through `parity/oracle/E.18a-settings.ts`.
|
||||
// Visible fixtures cover only a subset of settings; compare the entire settings table with the reference.
|
||||
#[test]
|
||||
fn settings_table_matches_the_typescript_table() {
|
||||
if support::ts_root().is_none() {
|
||||
@@ -392,7 +384,6 @@ fn settings_writes_match_typescript_and_typescript_reads_them() {
|
||||
wait_for(&app, "TUI tools");
|
||||
app.press("right");
|
||||
assert!(app.wait_until(WAIT, || { tui.settings.experiment("client-mcp") }));
|
||||
// The bytes TS writes for the same two updates (`Config.update` through the F.5 oracle).
|
||||
let text = std::fs::read_to_string(&file).unwrap();
|
||||
assert_eq!(
|
||||
text,
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
//! The MS1 review fixes carbon-3 and carbon-7 through the whole TUI:
|
||||
//!
|
||||
//! - model and agent state follow the open session's location, and acknowledged commits clear their
|
||||
//! drafts (`context/local.tsx`);
|
||||
//! - `session.json` and `prompt-history.jsonl` keep what another client wrote, prompts submitted before
|
||||
//! the history loads are kept, and `session.deleted` prunes its pin.
|
||||
//! Session-scoped selection and shared-file merges across independent writers.
|
||||
|
||||
use crate::support::{self, Fake, Harness, Log, WAIT, deref_harness, list};
|
||||
|
||||
@@ -174,8 +169,6 @@ fn cd_on_home_moves_the_agents_to_the_new_directory() {
|
||||
setup.wait("the new directory's agents", || setup.tui.local.agents().iter().any(|agent| agent.id.0 == "reviewer"));
|
||||
}
|
||||
|
||||
/// MS6 carbon-3: home follows the default location once the server names its canonical directory, so the
|
||||
/// agents load when the start directory is spelled differently.
|
||||
#[test]
|
||||
fn home_follows_the_canonical_default_location() {
|
||||
let fake = Fake::new(|seen| {
|
||||
@@ -210,8 +203,6 @@ impl Transport for Canonical {
|
||||
}
|
||||
}
|
||||
|
||||
/// carbon-3: once the session reports the agent and model a submit committed, the drafts give way, so a
|
||||
/// later switch from another client shows.
|
||||
#[test]
|
||||
fn acknowledged_commits_clear_the_drafts() {
|
||||
let setup = Setup::new(&[]);
|
||||
@@ -249,8 +240,6 @@ fn acknowledged_commits_clear_the_drafts() {
|
||||
setup.wait("the other client's agent", || setup.agent().as_deref() == Some("reviewer"));
|
||||
}
|
||||
|
||||
/// carbon-3: the acknowledgments and another client's switch in one batch: TS handles each event in turn, so
|
||||
/// the drafts give way and the switch shows.
|
||||
#[test]
|
||||
fn a_switch_batched_with_the_acknowledgments_shows() {
|
||||
let setup = Setup::new(&[]);
|
||||
@@ -273,8 +262,6 @@ fn a_switch_batched_with_the_acknowledgments_shows() {
|
||||
setup.wait("the other client's agent", || setup.agent().as_deref() == Some("reviewer"));
|
||||
}
|
||||
|
||||
/// carbon-7: a pin keeps the pins another client wrote after this one read the file, and
|
||||
/// `session.deleted` prunes it.
|
||||
#[test]
|
||||
fn pins_keep_other_clients_pins_and_prune_deleted_sessions() {
|
||||
let setup = Setup::new(&[("session.json", r#"{"pinned":["ses_old"]}"#)]);
|
||||
@@ -293,7 +280,6 @@ fn pins_keep_other_clients_pins_and_prune_deleted_sessions() {
|
||||
assert!(!pins::list(&setup.tui).contains(&SessionID("ses_b".into())));
|
||||
}
|
||||
|
||||
/// carbon-7: a prompt submitted while the history still loads is kept, in memory and in the file.
|
||||
#[test]
|
||||
fn a_prompt_appended_before_the_history_loads_is_kept() {
|
||||
let state = opencode_util::temp::tempdir().unwrap();
|
||||
@@ -316,8 +302,6 @@ fn a_prompt_appended_before_the_history_loads_is_kept() {
|
||||
assert_eq!(step(-1, "early").unwrap()["text"], "old");
|
||||
}
|
||||
|
||||
/// carbon-7: a save past the limit keeps a line the TS TUI appended after this one loaded; the next
|
||||
/// load trims the file to the newest 50.
|
||||
#[test]
|
||||
fn a_save_past_the_limit_keeps_lines_another_client_appended() {
|
||||
let full: String = (0..50).map(|n| format!("{{\"text\":\"{n}\",\"pasted\":[]}}\n")).collect();
|
||||
|
||||
@@ -10,7 +10,6 @@ use opentui::testing::TestApp;
|
||||
fn a_theme_change_keeps_a_pending_leader_and_the_focus() {
|
||||
let app = TestApp::new(80, 30);
|
||||
let tui = opencode_tui::mount(&app, support::deps(Arc::new(support::empty())));
|
||||
// The home's logo (E.1).
|
||||
support::wait_for(&app, "█▀▀█");
|
||||
|
||||
// The terminal reports a light background between the leader and its second key.
|
||||
@@ -31,8 +30,6 @@ fn a_theme_change_keeps_a_pending_leader_and_the_focus() {
|
||||
support::wait_for(&app, "draft kept");
|
||||
}
|
||||
|
||||
// Expected: in the `system` theme, the terminal's color scheme notice (`?997`) reads the palette again and the theme
|
||||
// follows it, as TS `theme.tsx` does. Actual: the palette was read once at startup and `system` stayed stale.
|
||||
#[test]
|
||||
fn the_system_theme_follows_the_terminal_palette_after_a_color_scheme_change() {
|
||||
use opentui::input::OscColor;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! The sidebar's MCP and footer sections on the one plugin API (O-67): clicks that run commands, a fold and a
|
||||
//! dismissal kept in plugin storage, their settings listeners, and the MCP section through the C ABI's byte shims.
|
||||
//! MCP sidebar actions and persisted section state.
|
||||
|
||||
use crate::support::{self, DIRECTORY, Fake, deref_harness, list};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ thread_local! {
|
||||
static THREAD: Cell<usize> = const { Cell::new(0) };
|
||||
}
|
||||
|
||||
/// Counts what this thread allocates from now on, until the measure drops.
|
||||
/// Count allocations on this thread until the guard drops.
|
||||
pub fn measure() -> Measure {
|
||||
let lock = ONE_AT_A_TIME.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
|
||||
LIVE.store(0, Ordering::SeqCst);
|
||||
@@ -36,7 +36,7 @@ pub struct Measure {
|
||||
}
|
||||
|
||||
impl Measure {
|
||||
/// The bytes this thread allocated since the measure started and that are not freed yet.
|
||||
/// Bytes allocated on this thread during the measurement that remain live.
|
||||
pub fn kept(&self) -> isize {
|
||||
LIVE.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! A fake IDE MCP server for the editor context tests (E.5), shared by `editor.rs` and the P-APP runner.
|
||||
//! Fake IDE MCP server shared by the editor tests and app replay.
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
|
||||
@@ -142,9 +142,7 @@ pub fn base(seen: &Seen, directory: &str) -> Reply {
|
||||
) => (200, list(directory, json!([]))),
|
||||
("GET", _) if path.ends_with("/form") || path.ends_with("/permission") => (200, json!({ "data": [] })),
|
||||
("GET", "/api/config") => (200, json!([])),
|
||||
// The TUI reads the data migration's status a second after it connects (`features/overlays.rs`). A server
|
||||
// with nothing to migrate says so; a 404 would toast "Data migration failed" over whatever a test is at by
|
||||
// then, which a slow column under load reaches and a fast one does not.
|
||||
// Report migration complete; a fixture 404 would produce an unrelated delayed toast.
|
||||
("GET", "/api/experimental/migration/v1") => (200, json!({ "status": "completed" })),
|
||||
("POST", _) if path.ends_with("/prompt") => (200, prompted(seen, "steer")),
|
||||
("POST", _) if path.ends_with("/model") || path.ends_with("/agent") => (204, Value::Null),
|
||||
@@ -245,11 +243,7 @@ pub fn still() -> Info {
|
||||
Info { animations: Some(false), ..Info::default() }
|
||||
}
|
||||
|
||||
/// Whether the calling test goes on here: it does when this process runs in UTC (`TZ=UTC`). Elsewhere it runs again, in
|
||||
/// a child of this binary with `TZ=UTC`, which this asserts passed, and the caller returns. TS's recorder runs in UTC
|
||||
/// (`parity/app/scenarios.test.tsx`), so a time the client or a plugin shows in local time (`Read::utc_offset`,
|
||||
/// `Zone::Local`) reads the same on any machine. The zone is read once a process, so it is pinned by the child's
|
||||
/// environment, not set in this one.
|
||||
/// Run the test body in UTC, spawning the same test in a child when needed.
|
||||
pub fn in_utc() -> bool {
|
||||
if std::env::var("TZ").as_deref() == Ok("UTC") {
|
||||
return true;
|
||||
@@ -295,8 +289,7 @@ pub fn roots(paths: Paths, channel: &str) -> Option<Roots> {
|
||||
Some(Roots { paths, storage_channel: channel.into() })
|
||||
}
|
||||
|
||||
/// An app that clears with the dark `opencode` theme's page background, as the TS screens do, so a dialog's
|
||||
/// backdrop blends over the same color.
|
||||
/// Clear with the dark page background so dialog backdrop blending matches the fixture.
|
||||
pub fn dark_app(width: u16, height: u16) -> TestApp {
|
||||
let theme =
|
||||
opencode_ui::theme::Catalog::default().load("opencode", opencode_ui::theme::ThemeMode::Dark).unwrap().theme;
|
||||
@@ -351,7 +344,7 @@ pub fn xdg_paths(home: &Path) -> Paths {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// One op of the F.5 oracle's `config` command in `home`, or `None` without bun and `node_modules`.
|
||||
/// Run one reference configuration operation in `home`, or return `None` without the TypeScript test dependencies.
|
||||
pub fn ts_config(home: &Path, op: Value) -> Option<Value> {
|
||||
use std::io::Write;
|
||||
use std::process::{Command, Stdio};
|
||||
@@ -625,8 +618,7 @@ pub fn at(screen: &str, needle: &str) -> Option<(u16, u16)> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Limits of host work no tree reaches, until the guard drops: for rows that check something else than the limits
|
||||
/// with trees past them (Pl).
|
||||
/// Temporarily lift host limits for fixtures that measure work above the default limits.
|
||||
pub fn unlimited() -> opencode_plugin::limits::Restore {
|
||||
let most = u64::MAX;
|
||||
opencode_plugin::limits::set(opencode_plugin::limits::Limits {
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
//! The harness of the seeded model tests (O-124), in the shape of OpenTUI's
|
||||
//! `packages/rust/crates/opentui/tests/support/model.rs`: generate a command list from a seed, run it against the
|
||||
//! real host and its oracles, and on a failure shrink the list (drop chunks of n/2 down to 1, then simplify each
|
||||
//! command) and print the trace.
|
||||
//!
|
||||
//! Environment: `MODEL_SEED=<n>` runs one seed, `MODEL_SEEDS=<n>` sets how many seeds run, `MODEL_SKIP=<property,...>`
|
||||
//! ignores failures of the named properties.
|
||||
//!
|
||||
//! Every run is also a run of the plugin C ABI (Pc, synthesis 4.14: "every model again through the transcripts"):
|
||||
//! what crosses it is fed to the protocol machine of `opencode_plugin::conformance`, and a broken rule fails the run
|
||||
//! as the property `abi-protocol`, after the model's own checks.
|
||||
//! Generate deterministic command traces, check the host and ABI after each run, and shrink failures while preserving
|
||||
//! their property and check site. `MODEL_SEED`, `MODEL_SEEDS`, and `MODEL_SKIP` select the cases.
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
@@ -199,8 +190,6 @@ impl Model for Toy {
|
||||
}
|
||||
}
|
||||
|
||||
// Expected (review bigboi-10): the shrinker deletes again after a simplification, to a fixed point, and it keeps the
|
||||
// check site, so it does not take a failure at another site of the same property for this one.
|
||||
#[test]
|
||||
fn the_shrinker_keeps_the_site_and_reaches_a_fixed_point() {
|
||||
let x = Failure { property: "p", site: "x", step: 2, detail: String::new() };
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
//! System dialogs (E.18b): themes, status, pair, highlights, update and the home notice, the plugin manager,
|
||||
//! and error details.
|
||||
//!
|
||||
//! - P-COMP: `parity/component/E.18b-system.tsx` renders the TS dialogs alone; here they open over the whole TUI,
|
||||
//! so the comparison covers the dialog panel (the cells with the panel background in the fixture).
|
||||
//! - `TestApp` and P-REQ: behavior, and the requests each dialog sends to a test transport. Pairing and updating
|
||||
//! are only ever proven here: they change real state.
|
||||
//! System dialogs, plugin management, and update notices.
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
@@ -285,7 +279,7 @@ fn plugin_manager(app: &TestApp, extra: Value) -> (Mounted, fn() -> u32) {
|
||||
plugin_manager_on(app, extra, false)
|
||||
}
|
||||
|
||||
/// [`plugin_manager`] on the linked carrier, or with `abi` across the C ABI's byte shims (P6b: the manager is a plugin).
|
||||
/// Open the plugin manager linked or through the C ABI.
|
||||
fn plugin_manager_on(app: &TestApp, extra: Value, abi: bool) -> (Mounted, fn() -> u32) {
|
||||
let mounted = mount_on(app, support::component_info(extra), plugin_server(), abi);
|
||||
ACTIVATIONS.set(0);
|
||||
@@ -497,7 +491,6 @@ fn a_configured_typescript_plugin_is_listed_as_skipped_with_its_reason() {
|
||||
mounted.tui.keymap.dispatch("plugins.list", None);
|
||||
let screen = wait_for(&app, "skipped, local");
|
||||
assert!(screen.contains("./broken.ts"), "{screen}");
|
||||
// TUI rows sort by label: `./broken.ts` comes before `team.tui`.
|
||||
assert!(screen.contains("view error enter"), "{screen}");
|
||||
app.press("enter");
|
||||
let screen = wait_for(&app, "TUI plugin error");
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
//! System commands, selection and copy, links, console copy, and the working directory dialog (E.20).
|
||||
//!
|
||||
//! - `TestApp` over a test sink (`features::links::testing`): copies and opens are recorded, so no test writes
|
||||
//! the host clipboard or starts a browser.
|
||||
//! - P-FILE: the toggles write a `cli.json` in a temporary home, compared byte for byte with what the TS
|
||||
//! `Config` service writes for the same updates, and read back by it (`parity/oracle/F.5-config.ts`; skipped
|
||||
//! without bun and `node_modules`).
|
||||
//! - P-APP (`parity/scenarios/E.20/*`) and P-PTY (`E.20/copy.pty.ts`) are in `tests/app.rs` and the PTY runner.
|
||||
//! System commands, clipboard actions, and working-directory interactions.
|
||||
|
||||
use crate::support::{self, Fake, WAIT, wait_for};
|
||||
|
||||
@@ -43,7 +36,7 @@ fn mount(app: &TestApp, info: Info, roots: Option<Roots>) -> Rc<Tui> {
|
||||
)
|
||||
}
|
||||
|
||||
/// Copy on select, which is the default outside Windows only (`app.tsx:586`).
|
||||
/// Explicitly enable copy-on-select on every platform.
|
||||
fn select() -> Info {
|
||||
support::component_info(json!({ "terminal": { "copy": "select" } }))
|
||||
}
|
||||
@@ -186,7 +179,6 @@ fn system_commands_run_from_their_keys_and_the_palette() {
|
||||
assert_eq!(*capture.0.opened.borrow(), ["https://opencode.ai/docs"]);
|
||||
assert!(!tui.dialogs.is_open());
|
||||
|
||||
// Only these three of E.20's commands are in the palette, as in TS.
|
||||
let palette: Vec<String> = tui
|
||||
.keymap
|
||||
.commands()
|
||||
@@ -251,7 +243,7 @@ fn toggles_write_cli_json_as_typescript_does_and_typescript_reads_them() {
|
||||
Some(Roots { paths: paths.clone(), storage_channel: "test".into() }),
|
||||
);
|
||||
wait_for(&app, "/project");
|
||||
// One write at a time: the settings writer ignores a change while one is in flight, as TS does.
|
||||
// Wait between writes because the settings dialog ignores changes during a save.
|
||||
let toggles: [(&str, &[&str], Value); 5] = [
|
||||
("f5", &["animations"], json!(false)),
|
||||
("f6", &["diffs", "wrap"], json!("none")),
|
||||
@@ -269,7 +261,6 @@ fn toggles_write_cli_json_as_typescript_does_and_typescript_reads_them() {
|
||||
}
|
||||
let text = std::fs::read_to_string(&file).unwrap();
|
||||
|
||||
// TS writes the same bytes for the same updates, and reads what Rust wrote.
|
||||
let twin = opencode_util::temp::tempdir().unwrap();
|
||||
let twin_file = support::xdg_paths(twin.path()).config.join("cli.json");
|
||||
std::fs::create_dir_all(twin_file.parent().unwrap()).unwrap();
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
//! Tabs and panes (E.12) through the whole TUI, with real roots in a temp dir:
|
||||
//!
|
||||
//! - P-FILE: `tabs.json` and `layout.json` as the TS storage and tab model read and write them
|
||||
//! (`parity/oracle/E.12-tabs.ts`), under the same lock;
|
||||
//! - `session.deleted` of the open tab, `/clear`, and a plugin panel with its resize handle.
|
||||
//!
|
||||
//! The cell-level proofs are the P-APP scenarios `E.12/tab-strip` and `E.12/rail-resize`.
|
||||
//! Session tabs and panes over temporary shared storage.
|
||||
|
||||
use crate::support::{self, Harness, WAIT, deref_harness};
|
||||
|
||||
@@ -142,8 +136,7 @@ fn clear_closes_the_tab_and_goes_home() {
|
||||
assert!(screen.lines().next().unwrap().contains("Fix the parser"), "{screen}");
|
||||
}
|
||||
|
||||
// `createSessionRetention` (`packages/client/src/solid/retention.ts`, limit 3 in `session-tabs.tsx:140-146`): of the
|
||||
// sessions viewed and left, only the last three keep their transcripts.
|
||||
// Open tabs retain transcripts; background retention keeps the three most recently viewed roots.
|
||||
#[test]
|
||||
fn only_the_last_three_viewed_sessions_keep_their_transcripts() {
|
||||
let ids: Vec<String> = (1..=6).map(|n| format!("ses_{n}")).collect();
|
||||
@@ -182,8 +175,6 @@ fn only_the_last_three_viewed_sessions_keep_their_transcripts() {
|
||||
assert_eq!(held, ids[3..].iter().collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
// The prefetch effect (`session-tabs.tsx:285-325`): a persisted background tab reads its permissions after a delay,
|
||||
// so its tab shows that it waits on the user.
|
||||
#[test]
|
||||
fn a_background_tab_reads_its_pending_permission() {
|
||||
let home = opencode_util::temp::tempdir().unwrap();
|
||||
@@ -251,8 +242,7 @@ fn closing_a_session_whose_tab_another_tui_closed_selects_its_former_neighbour()
|
||||
assert_eq!(ids(), ["ses_a", "ses_c"]);
|
||||
}
|
||||
|
||||
// Another client holding `tabs.json`'s lock delays the writes, not the UI thread that queues them
|
||||
// (`context/storage.tsx` returns a pending promise).
|
||||
// A held file lock should delay the write but leave the UI responsive.
|
||||
#[test]
|
||||
fn a_held_tabs_lock_does_not_block_the_ui() {
|
||||
let h = mount(100, json!({ "animations": false }));
|
||||
@@ -266,7 +256,6 @@ fn a_held_tabs_lock_does_not_block_the_ui() {
|
||||
});
|
||||
let started = std::time::Instant::now();
|
||||
h.tui.navigate(support::session_route("ses_b"));
|
||||
// The first write now waits on the lock; give it time to start.
|
||||
std::thread::sleep(std::time::Duration::from_millis(200));
|
||||
opencode_tui::tabs::reorder(&h.tui, "ses_b", 0);
|
||||
let elapsed = started.elapsed();
|
||||
@@ -372,10 +361,6 @@ fn a_closed_busy_tab_stops_the_pulse_ticks() {
|
||||
assert!(closed.frames <= 1 && closed.wakeups <= rest.wakeups + closed.frames, "{closed:?}, at rest {rest:?}");
|
||||
}
|
||||
|
||||
// A busy tab in the background animates with nothing else going on, and stops once it is idle. The strip and the
|
||||
// full rail pulse at 20 fps. The compact rail has no pulse: its spinner paints each step of TS's 80 ms interval,
|
||||
// 12.5 frames a second. Without a frame source of its own it stalled until input came (the user saw it step 2-3
|
||||
// times a second). A rail that hides while its tab works (the terminal narrows to the strip) leaves nothing ticking.
|
||||
#[test]
|
||||
fn a_busy_tab_paints_on_its_own_and_stops_when_idle() {
|
||||
let execution = |kind: &str, seq: u64| {
|
||||
@@ -512,8 +497,6 @@ fn a_split_panel_shows_beside_the_session_and_resizes() {
|
||||
assert!(h.app.wait_until(WAIT, || h.tui.panels.current().is_none()));
|
||||
}
|
||||
|
||||
// P-FILE: the TS client reads what Rust wrote and Rust reads what TS wrote, under the same lock.
|
||||
|
||||
#[test]
|
||||
fn tabs_and_layout_are_shared_with_the_typescript_client() {
|
||||
let Some(script) = oracle() else { return };
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! The terminal pane (E.13a) through the whole TUI, over the in-memory transport and a fake socket, for the paths the
|
||||
//! P-APP scenario `E.13a/terminal` does not reach: `/terminal` creating a terminal, input written before the pane
|
||||
//! mounts, a stored selection whose terminal is gone, and a server without terminals.
|
||||
//! Terminal panes against a fake socket and recorded requests.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -125,8 +123,7 @@ impl Terminal {
|
||||
|
||||
fn attach(&self) {
|
||||
assert!(self.wait(|harness| !harness.remotes.lock().unwrap().is_empty()), "no socket opened");
|
||||
// A replay that ends before the pane is laid out has no size to send pending input at (as in TS, where the
|
||||
// server is never that fast). The pane mounted before its socket opened, so one frame lays it out.
|
||||
// Lay out the pane before completing replay: input needs the terminal dimensions.
|
||||
self.app.render();
|
||||
let deliver = self.remotes.lock().unwrap()[0].deliver.clone();
|
||||
for text in [
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
//! Tool rows (E.7a) over a fixture server: the inline tools (read, glob, grep, write before it
|
||||
//! lands, the generic tool), the block tools (shell, write, edit), each running and finished, the
|
||||
//! error and denied states, clicks that expand, and the warning color of a call that waits on a
|
||||
//! permission request.
|
||||
//! Tool transcript rows, states, and click actions.
|
||||
|
||||
use crate::support::{self, Fake, Harness, Log, WAIT, deref_harness};
|
||||
|
||||
@@ -355,8 +352,6 @@ fn the_edit_diff_splits_in_a_session_pane_above_120_columns() {
|
||||
),
|
||||
)]);
|
||||
let h = open(140, 30, messages, Vec::new());
|
||||
// The docked sidebar leaves the session pane 98 columns, so the diff is unified (`contentWidth`,
|
||||
// `session-frame.tsx:283-298`).
|
||||
let screen = h.wait_for("new();");
|
||||
let (_, removed) = h.find("old();");
|
||||
let (_, added) = h.find("new();");
|
||||
|
||||
@@ -162,7 +162,6 @@ fn user_markdown_reasoning_and_footer_render_as_the_typescript_rows() {
|
||||
assert!(!screen.contains("The loop stops early."), "{screen}");
|
||||
assert!(screen.contains("Build · provider/model · 3.0s · 33.3 tok/s"), "{screen}");
|
||||
assert!(screen.contains("+ Tokens: 1 step · latest: 1,250 new · 3,000 cached · 4,250 total"), "{screen}");
|
||||
// Rows keep the TS order.
|
||||
let order = ["Why does the parser fail?", "Thought", "The parser drops", "Build ·", "Tokens"];
|
||||
let positions: Vec<_> = order.iter().map(|text| screen.find(text).unwrap()).collect();
|
||||
assert!(positions.is_sorted(), "{screen}");
|
||||
@@ -170,7 +169,6 @@ fn user_markdown_reasoning_and_footer_render_as_the_typescript_rows() {
|
||||
let row = screen.lines().position(|line| line.contains("+ Thought")).unwrap();
|
||||
h.app.click(8, row as u16);
|
||||
let expanded = h.wait_for("The loop stops early.");
|
||||
// Open, the group header drops the title (`group-view.tsx:186`).
|
||||
assert!(expanded.contains("- Thought · 1.5s"), "{expanded}");
|
||||
|
||||
let shown = Info { session: Some(Session { thinking: Some(Visibility::Show), ..medium() }), ..Info::default() };
|
||||
@@ -186,8 +184,6 @@ fn user_markdown_reasoning_and_footer_render_as_the_typescript_rows() {
|
||||
assert!(screen.contains("┃ Plan the fix."), "{screen}");
|
||||
}
|
||||
|
||||
/// A settings change reaches the rows at once, as TS's reactive config does: thinking opens and the
|
||||
/// tokens-per-second footer goes, then `session.toggle.thinking` writes the config back.
|
||||
#[test]
|
||||
fn config_changes_reach_the_transcript_without_a_restart() {
|
||||
let messages = vec![assistant(
|
||||
@@ -287,7 +283,7 @@ fn long_session() -> View {
|
||||
]
|
||||
})
|
||||
.collect();
|
||||
// One row per wheel step, so each step's top line can be followed (TS scrolls 3 by default).
|
||||
// Use single-row wheel steps so every viewport movement is observable.
|
||||
let info = Info { scroll: Some(Scroll { speed: Some(Bounded(1.0)), ..Scroll::default() }), ..Info::default() };
|
||||
open(80, 20, "ses_w", messages, info)
|
||||
}
|
||||
@@ -478,10 +474,7 @@ fn the_tail_mounts_first_and_older_pages_load_near_the_top() {
|
||||
assert_eq!(h.older.load(Ordering::SeqCst), 4);
|
||||
}
|
||||
|
||||
/// The timestamps of a recorded reply ("Debugging concurrent speaker mute issue"): one prompt, then 21 steps
|
||||
/// (created, streamed, completed) over 24 minutes. The first page of 20 messages starts inside the turn's
|
||||
/// exploration group, so TS loads the next page (`completeGroupBoundary`) and its footer measures from the
|
||||
/// prompt, not from the last step.
|
||||
/// A recorded sequence of multi-step timings spans a turn across the page boundary.
|
||||
#[test]
|
||||
fn the_footer_spans_a_turn_whose_prompt_is_on_an_older_page() {
|
||||
const PROMPT: u64 = 1_787_836_326_838;
|
||||
@@ -538,8 +531,6 @@ fn the_footer_spans_a_turn_whose_prompt_is_on_an_older_page() {
|
||||
assert_eq!(h.older.load(Ordering::SeqCst), 1);
|
||||
}
|
||||
|
||||
/// `app-lifecycle.test.tsx` (#63321, #63759): tokens per second count from the first streamed token, and the
|
||||
/// footer does not show the time to it.
|
||||
#[test]
|
||||
fn the_footer_measures_throughput_from_the_first_token() {
|
||||
let mut reply = assistant("msg_2", 2000, json!([{ "type": "text", "text": "Original answer" }]), Some(5000));
|
||||
@@ -616,9 +607,6 @@ fn a_theme_switch_restyles_the_transcript_in_place() {
|
||||
assert_eq!(diff.map(|(x, y)| (x, y, switched.cell(x, y), expected.cell(x, y))), None, "{}", switched.text());
|
||||
}
|
||||
|
||||
/// P11 as a work counter: a theme switch builds no fence or diff again, so it parses none. The widgets one switch
|
||||
/// creates are as many with 0, 3 or 36 fences, and with 1 or 12 edit diffs. A kept code view restyles its highlight
|
||||
/// without a parse (OpenTUI's `option_changes_keep_builtin_fences_streaming` counts them).
|
||||
#[test]
|
||||
fn a_theme_switch_builds_no_fence_or_diff_again() {
|
||||
let fence = |language: &str, line: &str| format!("```{language}\n{}```\n", format!("{line}\n").repeat(15));
|
||||
|
||||
@@ -90,7 +90,7 @@ fn the_leader_opens_its_commands_in_every_terminal_encoding() {
|
||||
|
||||
#[test]
|
||||
fn tab_and_shift_tab_cycle_tabs_only_while_tabs_are_on() {
|
||||
// `tabs.mode` wins over the legacy `enabled` (TS `config/index.tsx:295`), so "off" turns tabs off.
|
||||
// Explicit `tabs.mode` takes precedence over legacy `enabled`.
|
||||
let h = mount("off");
|
||||
for key in [&b"\t"[..], b"\x1b[Z"] {
|
||||
h.app.feed(key);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! Worktrees (E.11b) over a fixture server that records requests: `session.move` in a session and on home,
|
||||
//! a new worktree staged on home and created by the first submit, and the quick switch slots with their
|
||||
//! pins. No test touches a real service or repository.
|
||||
//! Worktree selection, creation, and session moves through the TUI.
|
||||
|
||||
use crate::support::{self, DIRECTORY, Fake, Harness, Log, WAIT, deref_harness};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user