Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ runvil-plugin-sdk = { version = "0.10.0", git = "https://github.com/cppalliance/
# own export of `runvil_plugin`, which `workshop-plugin-std` makes instead.
# The key is `std-plugin` because that crate's own library is named
# `plugin_std`, the name of the file Workshop ships.
std-plugin = { package = "plugin-std", version = "0.1.0", git = "https://github.com/cppalliance/runvil-plugin-std", rev = "badf32c91d9c16694758cc3cc847b2e2878d0a82", default-features = false }
std-plugin = { package = "plugin-std", version = "0.1.0", git = "https://github.com/cppalliance/runvil-plugin-std", rev = "a0a1e3f7388ad60131d7ed35afff0cc970a25a36", default-features = false }
# The bashkit Plugin, from its own repository, pinned by commit and built
# against the same contract commit. default-features off drops its own
# export of `runvil_plugin`, which `workshop-plugin-bashkit` makes
Expand Down
57 changes: 27 additions & 30 deletions crates/workshop/server/tests/it/std_real_directory.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! The `std` file tools over a real directory, mounted with
//! `RealBackend::rooted`: the acceptance flow a coding agent follows. List
//! the directory, find a word with Grep, read a window of the file, and read
//! the next window from the offset the first window's trailer names. Then
//! the tools that change files: Write makes a file under a directory that
//! is absent, StrReplace edits it, and Delete removes it, and the real
//! directory holds each change.
//! the directory, find a word with Grep, see an oversized full read refused,
//! and read a window around the line Grep found. Then the tools that change
//! files: Write makes a file under a directory that is absent, StrReplace
//! edits it, and Delete removes it, and the real directory holds each change.
//!
//! The tools come from the std Plugin's dynamic library, loaded from a
//! Plugin directory as the server loads it, so each call crosses the C
Expand Down Expand Up @@ -39,11 +38,6 @@ const NEEDLE_LINE: usize = 3000;
/// The word only that line holds.
const NEEDLE: &str = "needleword";

/// The first line the second window starts at, which is the line after the
/// last one a 100,000-byte window of 40-byte lines with every-10th-line
/// numbers holds.
const SECOND_OFFSET: usize = 2399;

/// Counts the directories this process has made, so two tests never share
/// one.
static DIRECTORIES: AtomicUsize = AtomicUsize::new(0);
Expand Down Expand Up @@ -162,36 +156,39 @@ fn list_find_read_a_window_and_read_the_next_one_by_the_trailer_offset() {
assert_eq!(found.text(), format!("/{FILE}\n{expected_line}"));

let path = format!("/{FILE}");
let first = call(&*pack, &access, "read", json!({ "path": path }));
assert_eq!(first.trust(), OutputTrust::Trusted);
assert!(
first.text().starts_with(&format!("{}\n", "x".repeat(40))),
"the first window starts at line 1"
);
let trailer = first
.text()
.lines()
.last()
.expect("a first window has a last line");
let full = call(&*pack, &access, "read", json!({ "path": path }));
assert_eq!(full.trust(), OutputTrust::Trusted);
assert!(
trailer.contains(&format!("Use offset={SECOND_OFFSET} to continue.")),
"{trailer}"
full.text().starts_with(
"Requested content exceeds maximum allowed characters (100000 characters)."
),
"an oversized full read is refused: {}",
full.text()
);

let second = call(
let offset = NEEDLE_LINE - 5;
let slice = call(
&*pack,
&access,
"read",
json!({ "path": path, "offset": SECOND_OFFSET }),
json!({ "path": path, "offset": offset, "limit": 10 }),
);
assert_eq!(slice.trust(), OutputTrust::Trusted);
assert!(
slice
.text()
.starts_with(&format!("... {} lines not shown ...\n", offset - 1)),
"the slice opens with the omitted-lines marker: {}",
slice.text()
);
assert!(
second.text().starts_with(&format!(" {SECOND_OFFSET}|")),
"the second window starts at the offset the trailer named: {}",
&second.text()[..20]
slice.text().contains(&format!(" {NEEDLE_LINE}|{NEEDLE}")),
"the slice holds the line Grep found"
);
assert!(
second.text().contains(&format!(" {NEEDLE_LINE}|{NEEDLE}")),
"the second window holds the line Grep found"
slice.text().ends_with(" lines not shown ..."),
"the slice ends with the omitted-lines marker: {}",
slice.text()
);
}

Expand Down
4 changes: 4 additions & 0 deletions crates/workshop/ui/src/parts/agent/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Agent Window UI

- **Everything is inspectable**: the agent window must give the user a way to see every thinking block, every tool call, and every tool input, output, and error. Each item either expands inline to show its full contents or jumps directly to the underlying artifact (for example, clicking a successful `Read` row opens the file in the editor at the starting line of that read, while a failed `Read attempted` row expands inline to show its arguments and error text).
- **Collapsed by default and accumulated**: thinking blocks and tool calls start collapsed by default and accumulate into `Explored ...` groups with a hover-only caret, expanding only when the user clicks.
4 changes: 4 additions & 0 deletions crates/workshop/ui/src/parts/agent/agent-session-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { TOAST_STACK } from "../../services/toast-service";
import { TEXT_CONTROL_SERVICE } from "@workshop/platform/text-control-service";
import { AgentToolbar } from "./agent-toolbar";
import { buildTranscript } from "./transcript/transcript-model";
import { openPathAtLine } from "../workspace/file-actions";
import { TranscriptView } from "./transcript/transcript-view";
import { ChatBox } from "../chatbox/chat-box";
import type { ChatBoxError, ChatBoxEvent, ChatBoxProps } from "../chatbox/types";
Expand Down Expand Up @@ -121,6 +122,9 @@ export class AgentSessionView extends Disposable {
copied: () => {
getServiceOrNull(TOAST_STACK)?.show(COPIED_TOAST, "info");
},
openFile: (path, line) => {
openPathAtLine(path, line);
},
}),
);

Expand Down
30 changes: 19 additions & 11 deletions crates/workshop/ui/src/parts/agent/transcript/rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ export class ToolRowView implements IDisposable {
readonly kind = "tool";
readonly element: HTMLElement;

private readonly line = new ToolLine();
private readonly line: ToolLine;

constructor() {
constructor(onOpenFile?: (path: string, line: number) => void) {
this.line = new ToolLine(onOpenFile);
this.element = this.line.element;
}

Expand All @@ -217,12 +218,12 @@ export class ToolRowView implements IDisposable {

// --- Group ----------------------------------------------------------------------------

/** A group's thinking step: an inner thinking line that opens while it streams. */
/** A group's thinking step: collapsed by default until clicked. */
class ThinkingStepView implements KeyedComponent {
readonly kind = "thought";
readonly element: HTMLElement;

private readonly line = new ThinkingLine(true, "ws-thinking-line");
private readonly line = new ThinkingLine(false, "ws-thinking-line");

constructor() {
this.element = this.line.element;
Expand All @@ -246,9 +247,10 @@ class ToolStepView implements KeyedComponent {
readonly kind = "tool";
readonly element: HTMLElement;

private readonly line = new ToolLine();
private readonly line: ToolLine;

constructor() {
constructor(onOpenFile?: (path: string, line: number) => void) {
this.line = new ToolLine(onOpenFile);
this.element = this.line.element;
}

Expand Down Expand Up @@ -283,9 +285,11 @@ export class GroupRowView implements IDisposable {
private readonly collapsible = new Collapsible();
private readonly steps = new Map<string, StepComponent>();
private readonly list: HTMLDivElement;
private readonly onOpenFile: ((path: string, line: number) => void) | undefined;
private text = "";

constructor() {
constructor(onOpenFile?: (path: string, line: number) => void) {
this.onOpenFile = onOpenFile;
this.element = document.createElement("div");
this.element.className = "ws-group-row";
this.element.appendChild(this.collapsible.element);
Expand All @@ -305,7 +309,7 @@ export class GroupRowView implements IDisposable {
this.list,
this.steps,
entries,
(entry) => (entry.kind === "tool" ? new ToolStepView() : new ThinkingStepView()),
(entry) => (entry.kind === "tool" ? new ToolStepView(this.onOpenFile) : new ThinkingStepView()),
(component, entry) => {
if (component.kind === "tool" && entry.step.step === "tool") {
component.update(entry.step);
Expand Down Expand Up @@ -363,7 +367,11 @@ export type RowComponent =
| ToolRowView;

/** Builds the component for a row's kind. */
export function createRowComponent(row: TranscriptRow, animateIn: boolean): RowComponent {
export function createRowComponent(
row: TranscriptRow,
animateIn: boolean,
onOpenFile?: (path: string, line: number) => void,
): RowComponent {
let component: RowComponent;
switch (row.kind) {
case "human":
Expand All @@ -376,10 +384,10 @@ export function createRowComponent(row: TranscriptRow, animateIn: boolean): RowC
component = new ThoughtRowView();
break;
case "group":
component = new GroupRowView();
component = new GroupRowView(onOpenFile);
break;
case "tool":
component = new ToolRowView();
component = new ToolRowView(onOpenFile);
break;
}
component.element.classList.add("ws-transcript-row");
Expand Down
Loading
Loading