Skip to content

Commit 221b6f6

Browse files
authored
feat: redesign CLI session modes and add session management commands (#105)
## Summary - **Default CLI behavior changed**: `ox "task"` now creates an async session, prints the session ID to stdout, and exits immediately. Progress output goes to stderr for scriptability (`SESSION=$(ox "task")`). - **New flags**: `--follow`/`-f` (stream agent output), `--interactive`/`-i` (launch TUI), `--agent-mode`/`-M` (async/interactive/plan) - **New `session` command** (alias: `container`) with subcommands: `rm`, `stop`, `attach`, `ps`, `logs`, `info`, `clean` - **Internal rename**: `submitMode` → `agentMode` throughout codebase for consistency with `--agent-mode` flag ## CLI Examples ```bash ox "some task" # detached: print session ID, exit ox -f "some task" # follow: stream output, exit with agent code ox -i "some task" # interactive: launch TUI with auto-submit ox -M plan "some task" # start plan-mode agent, print ID, exit ox session ps # list sessions ox session info <name> # show session details ox session logs -f <name> # follow session logs ox session stop <name> # stop a session ox session rm <name> # remove a session ``` ## Flag Compatibility Matrix | Terminal Mode | Agent Mode | Valid? | |---|---|---| | detached (default) | async (default) | Yes | | detached | interactive | Yes | | detached | plan | Yes | | `--follow` | async | Yes | | `--follow` | interactive | **Error** | | `--follow` | plan | **Error** | | `--interactive` | interactive (implied) | Yes | | `--interactive` | async | Yes | | `--interactive` | plan | Yes | | `-f` + `-i` | — | **Error** | ## Changes - Rename `SubmitMode`/`submitMode` to `AgentMode`/`agentMode` across 11 files - Replace `--print`/`-p` with `--follow`/`-f`, add `--agent-mode`/`-M` - Gate PR instructions on `agentMode === 'async'` (not `detach` flag) - Add `resolveSession()` helper for session lookup by name/ID - Add `session` command with 7 subcommands sharing infrastructure with `sessions` - Export shared utilities from `sessions.tsx` (`sessionsAction`, `cleanAction`, `printTable`)
1 parent c47c808 commit 221b6f6

23 files changed

+1090
-369
lines changed

README.md

Lines changed: 157 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ curl -fsSL https://get.ox.build | bash
3030
# Run the interactive TUI
3131
ox
3232

33-
# Or start a task directly
33+
# Start a task (runs in background, prints session ID)
3434
ox "Add input validation to the signup form"
35+
36+
# Start a task and follow the output
37+
ox -f "Fix the broken unit tests"
38+
39+
# Check on your sessions
40+
ox session ps
3541
```
3642

3743
## Installation
@@ -85,24 +91,72 @@ Run `ox` with no arguments to open the full terminal UI. From here you can write
8591
ox
8692
```
8793

88-
### Single Task
94+
### Start a Task
8995

90-
Pass a natural-language description to start a task directly:
96+
Pass a natural-language description to start a task. By default, Ox creates the session in the background and prints the session ID:
9197

9298
```bash
9399
ox "Refactor the auth middleware to use JWT tokens"
100+
# Prints session ID to stdout, progress to stderr, exits immediately
94101
```
95102

96-
Ox will create a branch, set up a sandbox, and launch the configured agent with your prompt. The agent runs in the background -- use `ox sessions` to check on it, or `ox` to open the TUI and attach.
103+
This is designed for scripting -- you can capture the session ID:
104+
105+
```bash
106+
SESSION=$(ox "Add input validation to the signup form")
107+
ox session logs -f "$SESSION"
108+
```
109+
110+
### Follow Mode
111+
112+
Stream the agent's output to your terminal:
113+
114+
```bash
115+
ox -f "Fix the failing integration tests"
116+
```
117+
118+
The process exits with the agent's exit code when the session finishes.
97119

98120
### Interactive Mode
99121

100-
To work alongside the agent in a live terminal session:
122+
Launch the full TUI and work alongside the agent in a live terminal session:
101123

102124
```bash
103-
ox -i "Fix the failing integration tests"
125+
ox -i "Implement the new dashboard component"
104126
```
105127

128+
The `-i` flag implies `--agent-mode=interactive` unless you specify otherwise.
129+
130+
### Agent Modes
131+
132+
Control how the agent runs inside the sandbox with `--agent-mode` / `-M`:
133+
134+
| Mode | Description |
135+
|------|-------------|
136+
| `async` (default) | Agent runs in the background. Best for fire-and-forget tasks. |
137+
| `interactive` | Agent runs with a TTY for live interaction. Use with `-i`. |
138+
| `plan` | Agent runs in read-only/plan mode. Can review but not modify code. |
139+
140+
```bash
141+
# Start a plan-mode agent (detached)
142+
ox -M plan "Review the authentication flow for security issues"
143+
144+
# Start an async agent but view it in the TUI
145+
ox -i -M async "Add comprehensive test coverage"
146+
```
147+
148+
### Flag Compatibility
149+
150+
| Flags | Behavior |
151+
|-------|----------|
152+
| `ox "task"` | Detached async -- print session ID, exit |
153+
| `ox -f "task"` | Follow async -- stream output, exit with agent code |
154+
| `ox -i "task"` | Interactive TUI -- launch TUI, auto-submit |
155+
| `ox -M plan "task"` | Detached plan -- print session ID, exit |
156+
| `ox -i -M async "task"` | TUI + async -- launch TUI, show session detail |
157+
| `ox -f -i "task"` | **Error** -- mutually exclusive |
158+
| `ox -f -M interactive "task"` | **Error** -- follow requires async mode |
159+
106160
### Shell Access
107161

108162
Open a bash shell inside a new sandbox without starting an agent:
@@ -229,20 +283,82 @@ API_KEY=your-key-here
229283

230284
## Session Management
231285

286+
Ox provides two ways to manage sessions: the `ox session` command (alias: `ox container`) for individual session operations, and `ox sessions` for listing.
287+
288+
In all commands below, `<session>` can be the session name or ID. Tab completion is supported.
289+
232290
### Listing Sessions
233291

234292
```bash
235-
# Open the TUI session list
236-
ox sessions
293+
# Table of running sessions
294+
ox session ps
237295
238-
# Table output
239-
ox sessions --output table
296+
# Include stopped sessions
297+
ox session ps --all
240298
241299
# JSON output for scripting
242-
ox sessions --output json
300+
ox session ps -o json
243301
244-
# Include stopped sessions
245-
ox sessions --all
302+
# YAML output
303+
ox session ps -o yaml
304+
305+
# Open the TUI session list
306+
ox session ps -o tui
307+
```
308+
309+
`ox sessions` is an alias for `ox session ps` and supports the same flags.
310+
311+
### Session Details
312+
313+
```bash
314+
# Show detailed info for a session
315+
ox session info <session>
316+
317+
# JSON output
318+
ox session info -o json <session>
319+
```
320+
321+
### Session Logs
322+
323+
```bash
324+
# Print logs for a session
325+
ox session logs <session>
326+
327+
# Follow logs in real time (like tail -f)
328+
ox session logs -f <session>
329+
330+
# Show last N lines
331+
ox session logs --tail 50 <session>
332+
```
333+
334+
### Session URLs
335+
336+
```bash
337+
# Print proxied URLs for a session (if appPort configured)
338+
ox session urls <session>
339+
```
340+
341+
### Stopping and Removing Sessions
342+
343+
```bash
344+
# Stop a running session
345+
ox session stop <session>
346+
347+
# Remove a session (aliases: rm, remove, delete)
348+
ox session rm <session>
349+
350+
# Remove all stopped containers
351+
ox session clean
352+
353+
# Remove all containers including running
354+
ox session clean --all
355+
```
356+
357+
### Attaching to Sessions
358+
359+
```bash
360+
# Attach to a running session's terminal
361+
ox session attach <session>
246362
```
247363

248364
### Resuming Sessions
@@ -258,26 +374,43 @@ ox resume <session> "Continue by adding error handling"
258374
ox resume --detach <session>
259375
```
260376

261-
### Cleanup
377+
### Resource Cleanup
262378

263379
```bash
264-
# Remove stopped containers
265-
ox sessions clean
266-
267-
# Remove all containers (including running)
268-
ox sessions clean --all
269-
270380
# Clean up old images, volumes, and snapshots
271381
ox resources clean
272382
```
273383

274384
## CLI Reference
275385

386+
### Root Command
387+
276388
| Command | Description |
277389
|---------|-------------|
278-
| `ox [prompt]` | Start a new task or open the TUI |
279-
| `ox sessions` | List and manage sessions |
390+
| `ox [prompt]` | Start a new task (detached) or open the TUI (no prompt) |
391+
| `ox -f [prompt]` | Start a task and follow the agent output |
392+
| `ox -i [prompt]` | Start a task in the interactive TUI |
393+
| `ox -M <mode> [prompt]` | Start a task with a specific agent mode (async/interactive/plan) |
394+
395+
### Session Management
396+
397+
| Command | Description |
398+
|---------|-------------|
399+
| `ox session ps` | List sessions (aliases: `list`, `ls`) |
400+
| `ox session info <id>` | Show detailed session information |
401+
| `ox session logs <id>` | Print session logs (`-f` to follow) |
402+
| `ox session stop <id>` | Stop a running session |
403+
| `ox session rm <id>` | Remove a session (aliases: `remove`, `delete`) |
404+
| `ox session attach <id>` | Attach to a running session |
405+
| `ox session urls <id>` | Print proxied URLs for a session |
406+
| `ox session clean` | Remove stopped containers (`-a` for all) |
407+
| `ox sessions` | Alias for `ox session ps` |
280408
| `ox resume <session>` | Resume a stopped session |
409+
410+
### Other Commands
411+
412+
| Command | Description |
413+
|---------|-------------|
281414
| `ox shell` | Open a shell in a new sandbox |
282415
| `ox config` | Interactive configuration wizard |
283416
| `ox auth check <provider>` | Check authentication status |
@@ -286,7 +419,9 @@ ox resources clean
286419
| `ox logs` | View ox logs |
287420
| `ox upgrade` | Check for and install updates |
288421
| `ox completions [shell]` | Set up shell tab completions |
422+
| `ox feedback <message>` | Send product feedback to the ox team |
289423
| `ox claude [args...]` | Run Claude Code inside a sandbox |
424+
| `ox codex [args...]` | Run Codex inside a sandbox |
290425
| `ox opencode [args...]` | Run OpenCode inside a sandbox |
291426
| `ox gh [args...]` | Run the GitHub CLI inside a sandbox |
292427
| `ox colors` | Display theme color swatches |

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"zustand": "^5.0.11"
5353
},
5454
"patchedDependencies": {
55-
"@deno/sandbox@0.13.1": "patches/@deno%2Fsandbox@0.13.1.patch"
55+
"@deno/sandbox@0.13.1": "patches/@deno%2Fsandbox@0.13.1.patch",
56+
"@bomb.sh/tab@0.0.14": "patches/@bomb.sh%2Ftab@0.0.14.patch"
5657
}
5758
}

0 commit comments

Comments
 (0)