Lightpanda: the headless browser designed for AI and automation
agent: trim narrative comments from the terminal split
Adrià Arrufat1d8a0b9fc42c
diff --git a/src/agent/Terminal.zig b/src/agent/Terminal.zigindex c78f3c788..654e644c7 100644--- a/src/agent/Terminal.zig+++ b/src/agent/Terminal.zig@@ -48,9 +48,8 @@ repl_arena: ?std.heap.ArenaAllocator,stderr_is_tty: bool,stdout_is_tty: bool,spinner: Spinner,-/// State for the prompt-assist C callbacks (completion/hints/highlighting);-/// registered by `attachCompleter`, which requires this Terminal to sit at-/// its final address.+/// Prompt-assist C-callback state; `attachCompleter` registers its address,+/// so the Terminal must sit at its final location by then.assist: prompt_assist.State,/// Line-buffered markdown state for streamed assistant deltas; its `close`/// resets everything so fence state can't leak into the next message. Only@@ -60,8 +59,7 @@ md_stream: md_term.Stream = .{ .show_table_placeholder = true },pub const CompletionSource = prompt_assist.CompletionSource;pub const HistoryPaths = prompt_assist.HistoryPaths;-/// Wires the isocline completer, hinter, and highlighter to `self.assist`,-/// with `source` supplying the dynamic `/provider` and `/model` candidates.+/// Wires the isocline completer, hinter, and highlighter to `self.assist`./// Must run after the Terminal is in its final memory location and before/// the first `readLine`.pub fn attachCompleter(self: *Terminal, source: ?CompletionSource) void {@@ -74,9 +72,6 @@ pub fn jsMode(self: *const Terminal) bool {}pub fn init(allocator: std.mem.Allocator, history_paths: ?HistoryPaths, verbosity: Verbosity, is_repl: bool) Terminal {- // Isocline probes the terminal on setup (writes ESC[6n cursor-report on- // stdout), so skip it in script-only mode — `ic_readline` is never- // reached there anyway.if (is_repl) prompt_assist.setupRepl();const stderr_is_tty = std.posix.isatty(std.posix.STDERR_FILENO);return .{diff --git a/src/agent/ansi.zig b/src/agent/ansi.zigindex 322216525..ce4790e60 100644--- a/src/agent/ansi.zig+++ b/src/agent/ansi.zig@@ -33,8 +33,7 @@ pub const blue = "\x1b[34m";pub const magenta = "\x1b[35m";pub const clear_eol = "\x1b[K";pub const clear_line = "\x1b[2K";-// Kitty keyboard protocol: push the "disambiguate" flag, push legacy-// encoding (flag 0), pop the pushed entry. Pushes must pair with a pop.+// Kitty keyboard protocol; each push must pair with a pop.pub const kitty_disambiguate = "\x1b[>1u";pub const kitty_legacy = "\x1b[>0u";pub const kitty_pop = "\x1b[<u";diff --git a/src/agent/picker.zig b/src/agent/picker.zigindex c1c7a4d8c..4e38df867 100644--- a/src/agent/picker.zig+++ b/src/agent/picker.zig@@ -101,8 +101,7 @@ const RawTerminal = struct {fn enable() error{NotInteractive}!RawTerminal {if (!interactiveTty()) return error.NotInteractive;- // A tty that refuses raw mode is non-interactive for the picker's- // purposes: callers degrade to the line prompt.+ // A tty that refuses raw mode is non-interactive for our purposes.const original = std.posix.tcgetattr(std.posix.STDIN_FILENO) catch return error.NotInteractive;var raw = original;raw.iflag.BRKINT = false;diff --git a/src/agent/prompt_assist.zig b/src/agent/prompt_assist.zigindex ab9639ec1..2689cc3e3 100644--- a/src/agent/prompt_assist.zig+++ b/src/agent/prompt_assist.zig@@ -31,8 +31,6 @@ const c = @cImport({@cInclude("isocline.h");});-// Styles referenced by name in the highlighter below; the kind-mapped styles-// live only as `styles` table rows.const style_slash = "ps-slash";const style_string = "ps-string";const style_var = "ps-var";@@ -42,16 +40,14 @@ const style_num = "ps-num";const style_err = "ps-err";const style_jsmode = "ps-jsmode";-/// The prompt's style palette (`ps-*` namespace avoids colliding with-/// isocline's built-in `ic-*` styles). `setupRepl` registers every entry and-/// `IcSink` paints token kinds from it, so a style can't be painted without-/// being registered: a `js_highlight.Kind` missing from `kinds` fails-/// compilation in `kind_styles` instead of silently rendering unstyled.+/// The prompt's style palette (`ps-*` avoids isocline's built-in `ic-*`+/// namespace). Registration and token-kind painting both derive from it, so+/// a painted style is registered by construction.const Style = struct {name: [:0]const u8,spec: [:0]const u8,/// `js_highlight` token kinds painted with this style; empty for styles- /// applied directly by name (slash names, kv keys, urls, errors, …).+ /// applied directly by name.kinds: []const js_highlight.Kind = &.{},};@@ -107,7 +103,7 @@ pub const HistoryPaths = struct {};/// The mutable state the C callbacks read: registered once via `attach`, so-/// it must live at a stable address (Terminal embeds it).+/// it must live at a stable address.pub const State = struct {/// True while the REPL is in JS mode; set by isocline's mode callback.js_mode: bool = false,@@ -117,10 +113,9 @@ pub const State = struct {history_paths: ?HistoryPaths = null,};-/// One-time isocline configuration for REPL mode: editing behavior, the-/// `ps-*` style palette, and JS prompt mode. Isocline probes the terminal on-/// first use (writes ESC[6n cursor-report on stdout), so callers must skip-/// this in script-only mode.+/// One-time isocline configuration for REPL mode. Probes the terminal+/// (isocline writes an ESC[6n cursor-report on stdout), so callers must skip+/// it in script-only mode.pub fn setupRepl() void {_ = c.ic_enable_multiline(true);_ = c.ic_enable_hint(true);@@ -138,11 +133,9 @@ pub fn setupRepl() void {_ = c.ic_enable_highlight(true);}-/// Wires the isocline completer, hinter, and highlighter to `state` so the C-/// callbacks can reach the global schemas, and loads the initial history from-/// `state.history_paths` — the same source `modeCallback` swaps from, so the-/// two can't diverge. Must run after `state` is in its final memory location-/// and before the first readline.+/// Wires the isocline completer, hinter, and highlighter to `state` and+/// loads the initial history. Must run after `state` is in its final memory+/// location and before the first readline.pub fn attach(state: *State) void {c.ic_set_default_completer(&completionCallback, state);c.ic_set_default_hinter(&hintsCallback, state);@@ -367,10 +360,8 @@ fn addMetaValueCompletions(}/// Directory entries whose basename completes the partial path `body`-/// (`dir/ba` → entries of `dir/` prefix-matching `ba`). Shared by Tab-/// completion and the ghost hint so the two can't drift on matching or the-/// directory `/` suffix. Returned names borrow the iterator; use before the-/// next `next()`.+/// (`dir/ba` → entries of `dir/` prefix-matching `ba`). Returned names+/// borrow the iterator; use before the next `next()`.const PathMatchIterator = struct {dir: std.fs.Dir,it: std.fs.Dir.Iterator,@@ -406,7 +397,6 @@ const PathMatchIterator = struct {}};-/// Completes a path argument against the filesystem.fn addPathCompletions(cenv: ?*c.ic_completion_env_t,input: []const u8,@@ -589,7 +579,6 @@ fn renderMetaHint(state: *State, meta: *const SlashCommand.MetaCommand, body: []return ghostFirstMatch(meta.values, body, "");}-/// Ghosts the first filesystem entry that completes the partial path `body`.fn ghostPathFirstMatch(body: []const u8) [*c]const u8 {var matches: PathMatchIterator = .init(body) orelse return null;defer matches.deinit();