feat(opencode): open a new or named workspace #90

Merged
claudiomaradonna merged 2 commits from feat/opencode-new-workspace into master 2026-11-23 13:26:09 +01:00
Collaborator

Why

The launcher runs one OpenCode container per workspace folder: state and
container name derive from the folder's path, so a second opencode
launch on a checkout stops with already serves this workspace. The way
around it was a Git worktree outside the repository for each session,
but the launcher mounts only the launch folder, so the worktree's parent
.git stays outside the container and git fails there. Running several
sessions on the main checkout, each with a worktree of its own inside
the repository, needs a second session on the same folder.

What changed

opencode --new-workspace <folder> gives a launch a state folder and a
container of its own on a folder another container already serves.
Before, that launch was refused. The workspace's name comes from the UTC
time and the launcher's PID, and the launch announces it on standard
error.

opencode --workspace-name NAME <folder> opens the folder's workspace
of that name, creating it when absent, so a later launch finds its
sessions again; the announced name of a new workspace works here too. A
named workspace lies beside the folder's own as
workspaces/<name>-<hash>-<NAME>, is served by one container at a time,
and shares login, configuration, and cache. NAME follows the identity
and account name rule, up to 64 characters. The two options cannot be
combined.

codex and claude refuse both options with a message: they keep no
state per workspace and already run side by side. An adapter opts in
with AZK_CLIENT_WORKSPACE_STATE, described in
docs/adding-a-client.md.

The already serves this workspace message now names --new-workspace.
Launches without either option behave as before, and the launcher
deletes no workspace folder.

How to verify

Base master (87e7aac), branch feat/opencode-new-workspace
(29a785f). The repository needs no setup; see
Verification.

Run on the branch, against the vendored Podman stub:

make test TESTS=opencode_state FILTER='workspace'
make test TESTS=arg_parsing FILTER='workspace|help|missing_values'

Both pass on the branch. With the two test files copied onto master,
the five new tests and the four extended ones fail at their assertions
of the new behavior.

Not run, untested: the trial on a real host, which this machine cannot
run for lack of Podman. On a Linux host with rootless Podman and the
OpenCode image, with an opencode link to the branch's bin/azkaban:

# terminal 1
opencode ~/projects/example
# terminal 2, while the first runs
opencode --new-workspace ~/projects/example
# later, with the name terminal 2 announced
opencode --workspace-name 20261123-112630-48213 ~/projects/example -- session list

Expected: on master the second launch stops with
already serves this workspace; on the branch it starts without a
login, git status and git worktree add work in both sessions, and
session list shows only the second session's own.

Verify, make lint && .agents/hooks/shellcheck.sh repo && make test,
passed on the branch's tree: 59 files clean, 349 tests, 0 failures.

Considerations

Sessions on one folder share its working tree; what keeps their changes
apart is a worktree for each inside the repository, which the launcher
does not create. Workspace folders accumulate under workspaces/ until
the user deletes them. Two low review findings were set aside as low in
a later round: the pattern <name>-<hash>-<NAME> in
docs/configuration.md uses two placeholders that differ only in case,
and a note on the work file's status, since updated.

## Why The launcher runs one OpenCode container per workspace folder: state and container name derive from the folder's path, so a second `opencode` launch on a checkout stops with `already serves this workspace`. The way around it was a Git worktree outside the repository for each session, but the launcher mounts only the launch folder, so the worktree's parent `.git` stays outside the container and git fails there. Running several sessions on the main checkout, each with a worktree of its own inside the repository, needs a second session on the same folder. ## What changed `opencode --new-workspace <folder>` gives a launch a state folder and a container of its own on a folder another container already serves. Before, that launch was refused. The workspace's name comes from the UTC time and the launcher's PID, and the launch announces it on standard error. `opencode --workspace-name NAME <folder>` opens the folder's workspace of that name, creating it when absent, so a later launch finds its sessions again; the announced name of a new workspace works here too. A named workspace lies beside the folder's own as `workspaces/<name>-<hash>-<NAME>`, is served by one container at a time, and shares login, configuration, and cache. `NAME` follows the identity and account name rule, up to 64 characters. The two options cannot be combined. `codex` and `claude` refuse both options with a message: they keep no state per workspace and already run side by side. An adapter opts in with `AZK_CLIENT_WORKSPACE_STATE`, described in `docs/adding-a-client.md`. The `already serves this workspace` message now names `--new-workspace`. Launches without either option behave as before, and the launcher deletes no workspace folder. ## How to verify Base `master` (`87e7aac`), branch `feat/opencode-new-workspace` (`29a785f`). The repository needs no setup; see [Verification](docs/development.md#verification). Run on the branch, against the vendored Podman stub: ```bash make test TESTS=opencode_state FILTER='workspace' make test TESTS=arg_parsing FILTER='workspace|help|missing_values' ``` Both pass on the branch. With the two test files copied onto `master`, the five new tests and the four extended ones fail at their assertions of the new behavior. Not run, untested: the trial on a real host, which this machine cannot run for lack of Podman. On a Linux host with rootless Podman and the OpenCode image, with an `opencode` link to the branch's `bin/azkaban`: ```bash # terminal 1 opencode ~/projects/example # terminal 2, while the first runs opencode --new-workspace ~/projects/example # later, with the name terminal 2 announced opencode --workspace-name 20261123-112630-48213 ~/projects/example -- session list ``` Expected: on `master` the second launch stops with `already serves this workspace`; on the branch it starts without a login, `git status` and `git worktree add` work in both sessions, and `session list` shows only the second session's own. Verify, `make lint && .agents/hooks/shellcheck.sh repo && make test`, passed on the branch's tree: 59 files clean, 349 tests, 0 failures. ## Considerations Sessions on one folder share its working tree; what keeps their changes apart is a worktree for each inside the repository, which the launcher does not create. Workspace folders accumulate under `workspaces/` until the user deletes them. Two low review findings were set aside as low in a later round: the pattern `<name>-<hash>-<NAME>` in `docs/configuration.md` uses two placeholders that differ only in case, and a note on the work file's status, since updated.
One container serves a folder's OpenCode state, so a second session on
a checkout was refused, and a worktree outside the repository, the way
around it, lacks the parent .git in the container.

--new-workspace gives a launch a state folder and container of its own
on the folder, named from the UTC time and the launcher's PID, and
--workspace-name opens one by name, so its sessions can be found again.
Codex and Claude refuse both: they keep no state per workspace and
already run side by side.
Say how to run another OpenCode session on a folder, where its state
lies and that it stays until deleted, and what an adapter sets to take
the two options.
claudiomaradonna deleted branch feat/opencode-new-workspace 2026-11-23 13:26:17 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/azkaban!90
No description provided.