feat: agent-friendly CLI for full okena control + remote window model#138
Open
matej21 wants to merge 5 commits into
Open
feat: agent-friendly CLI for full okena control + remote window model#138matej21 wants to merge 5 commits into
matej21 wants to merge 5 commits into
Conversation
Expose multi-window state over the remote API so CLI/remote clients can see what the user actually sees: - ApiWindow / ApiWindowBounds DTOs and StateResponse.windows (serde default → backward compatible with old clients). - Optional `window` targeting field on FocusTerminal, SetProjectShowInOverview, and SetFullscreen, plus ActionRequest::target_window() to read it. Types only; backend wiring and CLI land in follow-up commits. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Read side: GET /v1/state now returns `windows` — each open OS window with its active flag, per-window focus (project + terminal), fullscreen target, visible projects (via the same visible_projects() the sidebar uses), folder filter, OS bounds, and sidebar state. Back-compat flat focused_project_id/fullscreen_terminal are derived from the active window. Write side: actions carrying `window: "main"|<uuid>` now land on that window's per-window FocusManager. FocusManagerResolver gained an Option<WindowId> target arg (None = focused/active window, as before); the bridge parses ActionRequest::target_window(), rejects malformed ids, and reports "window not found" for a missing extra. New Okena::focus_manager_for_window + build_api_windows; headless provides single-main-window equivalents. Also: AddProject now returns the new project_id alongside terminal_ids. Threads the new SetFullscreen/FocusTerminal/SetProjectShowInOverview `window` field through strip_remote_ids and GUI-internal constructions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the hand-rolled arg parser with a clap (derive) command tree and add full control over a running okena instance over the remote API: - Orientation: `ls` (windows + projects/layout tree, --json), `term ls`. - Projects: `project add/rm/show/hide/rename/color/focus`. - Worktrees: `worktree add/rm`. Folders: `folder add/rm/rename`. - Terminals/layout: `term new/close/focus/rename/split/tab/minimize/ fullscreen` — split/tab resolve the layout path from a terminal id. - I/O loop: `send`, `run`, `key`, `read`. - Global `--window` targets a specific window (main / id / unique prefix) for the per-window commands. Agent-friendly addressing: projects by name/id/path; terminals by id, `project/name`, or `project:index`; windows by id prefix. All resolvers are pure and unit-tested. Existing verbs (pair/health/state/action/ services/service/whoami) preserved. The CLI gate only engages on a known subcommand, so GUI/profile launch is untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The new StateResponse.windows field (a serde-default Vec) is omitted by two #[cfg(test)] construction sites that the non-test build never compiles. Initialize them to empty so `cargo test` builds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Note the state `windows` list and per-window action targeting in the remote server CLAUDE.md, and add src/cli/CLAUDE.md covering the clap gate, addressing scheme, and command conventions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gives the
okenaCLI (and the remote API it rides on) enough surface for an agent to drive the whole workspace and stay cooperative with what the user sees — create projects/worktrees, manage layout (tabs/splits), run commands, send input, read output, and see the user's windows/projects/terminals.The remote action API was already nearly complete, so most of this is CLI surface — plus one real API addition: a window model (the remote previously saw only a flat workspace).
What's new
Window model in the remote API
GET /v1/statenow returnswindows(ApiWindow[]): each open OS window with itsactiveflag, per-window focus (project + terminal), fullscreen target, visible projects (via the samevisible_projects()the sidebar uses), folder filter, OS bounds, and sidebar state. Built byOkena::build_api_windows.windowsis#[serde(default)]; the flatfocused_project_id/fullscreen_terminalare derived from the active window, so existing mobile/web clients keep working.Per-window action targeting (
--window)FocusTerminal,SetProjectShowInOverview,SetFullscreengained an optionalwindowfield ("main"| extra UUID). The bridge parses it and the generalizedFocusManagerResolver(Fn(&App, Option<WindowId>) -> Option<…>) routes the mutation to that window'sFocusManager;Nonekeeps today's focused-window default.AddProjectnow also returns the newproject_id(was terminal ids only).Agent-friendly CLI on clap
ls(windows + projects/layout tree,--json),term ls.project add|rm|show|hide|rename|color|focus.worktree add|rm. Folders:folder add|rm|rename.term new|close|focus|rename|split|tab|minimize|fullscreen— split/tab resolve the layout path from a terminal id client-side, so agents never compute tree paths.send,run,key,read.--window(main / full id / unique prefix) for the per-window commands.project/name, orproject:index. All resolvers are pure + unit-tested.pair/health/state/action/services/service/whoami) preserved. The CLI gate only engages on a known subcommand, so GUI launch and--profileflags are untouched.Commits (phased)
feat(api)— window-model + targeting DTOsfeat(remote)— backend: build_api_windows,--windowrouting, AddProject project_id, headless variantsfeat(cli)— clap command tree + resolverstest— StateResponse test-helper fixupsdocs— window model +src/cli/CLAUDE.mdTesting
cargo build -p okenaclean;cargo test: okena-core 80, okena-workspace 287, okena 110 — all green.okena lsagainst a running instance auto-registers and renders the real workspace.Note
Against an older running instance the
windowslist is empty (no crash — serde default), so thelsWINDOWS section and--windowonly light up after rebuilding + restarting okena.🤖 Generated with Claude Code