Skip to content
Merged
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,57 @@ and released versions are intended to follow Semantic Versioning.

- An OpenCode session's age now follows its latest real message. A model or
agent switch used to bump it, so several sessions could all read "6 hours".
- `agentview opencode attach SESSION_ID [--cwd DIR]` attaches one TUI to the
session on this agentview's own OpenCode server, replacing the process.
- Jumping into a remote OpenCode session attaches through the host's agentview
supervisor, so turns typed in that TUI show as Working on both dashboards;
a direct TUI would run on its own server instance whose state managed
discovery cannot see. Hosts without the subcommand fall back to the direct
TUI.

- `space` on a remote OpenCode row fetches the session's full transcript for
Peek from the host over SSH. The export lands in a temp file first because
`opencode export` truncates a piped export at 64 KiB, and a bounded tail of
larger exports is salvaged message by message.

- `agentview opencode launch "task" --cwd DIR [--model M]` starts one managed
OpenCode session in the background through the supervisor's own server and
prints it as JSON — the same launch path the dashboard composer uses.
- A remote OpenCode launch with a task goes through that host's agentview
supervisor, so the session is managed there: Completed when idle, and
visible as managed on both dashboards. Hosts running an agentview without
the subcommand fall back to the interactive TUI launch.

- New sessions can start on a watched SSH host: `ctrl+o` and the directory
view offer each host's known folders as `[host] /path`, and submitting a
task hands the terminal to that harness on the host over SSH — Claude and
Codex receive the task as their argument, and OpenCode's task is typed into
its editor as soon as the remote screen shows it accepting input. Model
picks and `--yolo` stay local-only.

- `/remote` in the dashboard lists the watched SSH hosts, and
`/remote add HOST` / `/remote remove HOST` change the set without a
restart. The list is read on every refresh and persisted to
`~/.local/state/agentview/ssh-targets.json` immediately; each host keeps
its own completed-history budget.

- `Enter` jumps into a remote session: the dashboard suspends and agentview
runs the provider's own attach or resume on that host over SSH —
`claude attach`/`--resume`, `opencode --session`, and `codex resume` are
supported; other harnesses are refused with a notice. Remote commands
export the per-user agent CLI homes into PATH and fall back to `~/.tmp`
for `TMPDIR` on hosts where `/tmp` is mounted noexec.

- SSH host support (the `--ssh-host` entries here, `/remote`, remote jump-in
and launch, and `agentview opencode attach` and `launch`) is contributed by
[@BaoshanPang](https://github.com/BaoshanPang).
- `--ssh-host HOST` observes the sessions a passwordless SSH host runs through
its own agentview: each refresh runs `agentview --json` on that host and
merges the snapshot into the dashboard, with remote rows tagged with the
host and inspect-only. The host list is remembered in
`~/.local/state/agentview/ssh-targets.json`, and a host running under
`AGENTVIEW_REMOTE=1` observes nothing so two machines watching each other
cannot fan out.

- When [agent-bouncer](https://github.com/moritzWa/agent-bouncer) is installed,
a panel above the input lists its running and waiting heavy jobs and when the
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ own interface.
- **Start in any folder** with `/cd` or `Ctrl+O`. Write multi-line drafts, paste
long text, attach clipboard images with `Ctrl+V`, and select text with `Shift+arrow`
or words with `Option+Shift+arrow`.
- **Watch other machines in the same list** with `--ssh-host 176`: one refresh
runs agentview on that passwordless-SSH host and merges its sessions in,
tagged with the host name. `Enter` jumps into a remote session over SSH,
`Ctrl+O` starts a new one in any of its folders (typed task included), and
`/remote add` or `/remote remove` changes the set mid-session. Thanks to
[@BaoshanPang](https://github.com/BaoshanPang).
- **Move or migrate a session:** `F6` changes folders; `/migrate` changes
harnesses through [session-migrate](https://session-migrate.github.io/).
OpenCode folder moves preserve the session ID and history.
Expand Down
80 changes: 80 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ betteragentview is already up to date.
| `--openhands-bin PATH` / `--no-host-openhands` | Select or disable OpenHands native control plus bounded event-store discovery. |
| `--docker-container NAME_OR_ID` | Observe Claude and Codex in one explicitly selected running container; repeatable. |
| `--docker-bin PATH` | Use a particular Docker executable; default `docker`. |
| `--ssh-host HOST` | Observe sessions on a passwordless SSH host that runs agentview; repeatable. The host list is remembered in the state directory after the first run. |
| `--ssh-bin PATH` | Use a particular SSH client for `--ssh-host` targets; default `ssh`. |
| `--session-migrate-bin PATH` | Use a particular session-migrate executable for `F6` moves and `/migrate`; default `session-migrate`. |
| `--harness` / `--launch-provider claude\|codex\|pi\|omp\|opencode\|cursor\|copilot\|antigravity\|mistral-vibe\|muse\|qwen\|kimi\|grok\|kilo\|openhands\|terminal` | Initial harness for new-session prompts; default Claude. Each configured coding harness opens its native full-screen UI; Terminal opens the user's shell. `oh-my-pi` and `kilo-code` are accepted aliases. |
| `--launch-cwd PATH` | Working directory for newly launched host sessions; default current directory. |
Expand Down Expand Up @@ -448,6 +450,19 @@ host Codex, missing Codex, active threads, external threads, Docker threads,
and providers without a documented archive operation are refused or reported
as ineligible. betteragentview does not call deletion an archive.

## Starting a managed session from the command line

```console
agentview opencode launch "fix the flaky test" --cwd ~/work/repo
agentview opencode launch "fix the flaky test" --cwd ~/work/repo --model anthropic/claude-opus-5-5
```

The supervisor creates the session on its own server, records ownership before
the turn starts, and submits the task. The created session prints as JSON. This
is the same launch path the dashboard composer uses, so the session is managed:
it shows Completed when idle, restarts resume it, and it can be opened,
replied to, and interrupted from any dashboard that owns it.

## Restarting the OpenCode server

betteragentview runs one OpenCode server that its attached OpenCode sessions use.
Expand Down Expand Up @@ -521,6 +536,71 @@ need a server whose `/tui/select-session` accepts `client`; betteragentview read
server's `/doc` to check, because older servers accept the field and then
switch every attached window.

## SSH host targets

`agentview --ssh-host HOST` observes the sessions another machine runs through
its own agentview. One refresh runs `agentview --json` on that host over SSH
and merges the result into the dashboard, so every provider installed there
appears once, tagged with its host:

```console
agentview --ssh-host 176
agentview --ssh-host 176 --ssh-host 177
```

Inside the dashboard, `/remote` lists the watched hosts and
`/remote add HOST` / `/remote remove HOST` change the set without a restart;
the change persists to `~/.local/state/agentview/ssh-targets.json` immediately.

Requirements and behavior:

- The host must be reachable non-interactively (`BatchMode`): keys set up with
`ssh-copy-id`, no passphrase prompt. Anything else fails fast as a dashboard
warning; the rest of the dashboard is unaffected.
- agentview must be installed on the remote host and on its PATH for
non-interactive shells (`~/.local/bin` is probed).
- Remote rows are tagged with the host and Peek shows it as their runtime.
`Enter` jumps in: the dashboard suspends, agentview runs the provider's own
attach/resume on that host over SSH (`claude attach`/`--resume`,
`opencode --session`, `codex resume`), and `Enter`/`Right` resumes a
backgrounded SSH client like any local session. Harnesses without a native
remote attach (including the Terminal harness and launch) are refused with a
notice, and inline reply/interrupt stay local-only.
- OpenCode jumps in attach through the host's own agentview
(`agentview opencode attach`), so the TUI connects to that supervisor's
server: turns typed there show as Working on both dashboards and idle ones
as Completed. A direct TUI would run on its own server instance whose state
managed discovery cannot see. Hosts running an older agentview reject the
subcommand and fall back to the direct TUI.
- `space` fetches a remote OpenCode session's full transcript for Peek from
the host (`opencode export` into a temp file, since that CLI truncates a
piped export at 64 KiB); the newest messages are kept. Claude and Codex
remote transcripts are not fetched yet.
- New sessions can start on a watched host: `ctrl+o` (and the directory view)
offers each host's known folders as `[host] /path`; picking one and
submitting a task hands the terminal to that harness on the host —
Claude and Codex receive the task as their argument, and OpenCode's task is
typed into its editor the moment the host's screen shows it accepting
input, exactly as a local native launch. Model picks and `--yolo`
permission bypass stay local-only.
- OpenCode sessions with a task start through the host's own agentview
supervisor (`agentview opencode launch` over SSH), so they are managed
there: Completed when idle, and controllable from the host's dashboard too.
The host must run an agentview that has the subcommand; older ones fall
back to the interactive TUI launch.
- The host list is persisted to
`~/.local/state/agentview/ssh-targets.json` after the first
`--ssh-host` run or `/remote add`, so later plain `agentview` launches keep
watching those hosts. Remove a host with `/remote remove HOST` or by
deleting it from that file.
- A host that is itself being observed (its agentview runs with
`AGENTVIEW_REMOTE=1`) observes nothing, so two machines pointing at each
other cannot fan out.
- Remote commands export a PATH with the per-user agent homes
(`~/.local/bin`, `~/.opencode/bin`, `~/.npm-global/bin`, `~/.bun/bin`,
`~/bin`) because non-interactive shells miss them, and fall back to
`~/.tmp` for `TMPDIR` on hosts where `/tmp` is mounted noexec.

## Managed Docker lifecycle

Managed Docker is distinct from `--docker-container`. The latter enrolls one
Expand Down
1 change: 1 addition & 0 deletions src/adapters/antigravity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ pub fn parse_antigravity_last_conversations(
let runtime_id = match &runtime {
Runtime::Host => "host",
Runtime::Docker { container_id, .. } => container_id,
Runtime::Ssh { host } => host,
};
let workspace_name = cwd
.file_name()
Expand Down
1 change: 1 addition & 0 deletions src/adapters/claude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ fn normalize_record(record: ClaudeRecord, runtime: Runtime) -> AgentSession {
let runtime_id = match &runtime {
Runtime::Host => "host",
Runtime::Docker { container_id, .. } => container_id,
Runtime::Ssh { host } => host,
};

AgentSession {
Expand Down
1 change: 1 addition & 0 deletions src/adapters/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ fn normalize_thread(thread: CodexThread, runtime: Runtime) -> AgentSession {
let runtime_id = match &runtime {
Runtime::Host => "host",
Runtime::Docker { container_id, .. } => container_id,
Runtime::Ssh { host } => host,
};
// The summary remains observable, but transcript/control capabilities are
// granted only after the host supervisor proves exact ownership.
Expand Down
1 change: 1 addition & 0 deletions src/adapters/copilot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ fn normalize_copilot_session(session: CopilotSessionInfo, runtime: Runtime) -> A
let runtime_id = match &runtime {
Runtime::Host => "host",
Runtime::Docker { container_id, .. } => container_id,
Runtime::Ssh { host } => host,
};
let fallback_name = session
.cwd
Expand Down
10 changes: 8 additions & 2 deletions src/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod pi;
mod qwen;
mod screen_status;
mod session_migrate_native;
pub(crate) mod ssh_remote;
mod terminal_harness;

use std::collections::{BTreeMap, BTreeSet};
Expand Down Expand Up @@ -84,13 +85,18 @@ pub use muse::{
};
pub use opencode::{
default_opencode_ownership_path, parse_opencode_session_list, OpenCodeController,
OpenCodeInvocation, OpenCodeOwnership, OpenCodeSource,
OpenCodeInvocation, OpenCodeOwnership, OpenCodeSource, OPENCODE_READY_MARKER,
};
pub use pi::{default_pi_session_dir, parse_pi_session, PiController, PiSource};
pub use qwen::{default_qwen_ownership_path, QwenController, QwenOwnership, QwenSource};
pub use session_migrate_native::{
SessionMigrateNativeController, SessionMigrateNativeOwnership, SessionMigrateNativeSource,
};
pub use ssh_remote::{
default_ssh_targets_path, load_ssh_targets, load_ssh_targets_at, save_ssh_targets,
save_ssh_targets_at, validate_host, SshHostSource, SshHostsSource, SshTargetList, SshTargets,
REMOTE_GUARD_ENV, REMOTE_PATH_PREFIX,
};
pub use terminal_harness::{is_shell_install_choice, shell_install_name, TerminalHarness};

use crate::domain::{AgentSession, Provider, Runtime, SessionKind, SessionSnapshot, SessionState};
Expand Down Expand Up @@ -459,7 +465,7 @@ fn deduplicate_sessions(sessions: &mut Vec<AgentSession>) {
sessions.extend(unique.into_values());
}

fn bound_completed_history(
pub(crate) fn bound_completed_history(
sessions: &mut Vec<AgentSession>,
kept: &std::collections::BTreeSet<String>,
request: &DiscoveryRequest,
Expand Down
6 changes: 5 additions & 1 deletion src/adapters/opencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const MANAGED_LIST_SHARED_FOR: Duration = Duration::from_millis(1500);
/// Quiet after the title changes, so the frame that set it has finished.
const SHARED_CLIENT_SETTLE: Duration = Duration::from_millis(40);
const MAX_RESTORABLE_SESSIONS: usize = 2_000;
const OPENCODE_READY_MARKER: &str = "Ask anything";
/// The empty OpenCode editor shows this once it accepts input; a launch
/// submits its task only after it is on screen.
pub const OPENCODE_READY_MARKER: &str = "Ask anything";

type HolderProbe = Arc<dyn Fn() -> Vec<Holder> + Send + Sync>;

Expand Down Expand Up @@ -1991,6 +1993,7 @@ impl OpenCodeSource {
match &self.runtime {
Runtime::Host => "host".into(),
Runtime::Docker { container_id, .. } => container_id.clone(),
Runtime::Ssh { host } => host.clone(),
}
}

Expand Down Expand Up @@ -2622,6 +2625,7 @@ fn normalize_record(record: OpenCodeRecord, runtime: Runtime) -> AgentSession {
let runtime_id = match &runtime {
Runtime::Host => "host",
Runtime::Docker { container_id, .. } => container_id,
Runtime::Ssh { host } => host,
};
let capabilities = if runtime == Runtime::Host {
BTreeSet::from([Capability::Inspect])
Expand Down
Loading
Loading