Skip to content

feat: SessionOptions.name and SessionUnavailableError - #369

Merged
xxchan merged 2 commits into
mainfrom
feat/session-name
Oct 12, 2026
Merged

xxchan merged 2 commits into
mainfrom
feat/session-name

Conversation

@xxchan

@xxchan xxchan commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Closes #368.

Why. A host that shares the user's native home (for example ~/.codex) has its sessions show up in the user's own app, unnamed. Two resume refusals follow from what the user does in that app, and both reached the host as generic errors:

  • the user archives the thread;
  • the user's app opens the thread and becomes its writer.

Session name

  • SessionOptions.name is the session's display name, set through each runtime's own interface:
    • claude: --name on a new session. A resume leaves it alone, because --name there replaces the name the session has, which may be the user's.
    • codex: thread/name/set once the thread is open and the open's checks pass. On resume, only when the thread/resume reply shows no name.
    • pi: a session_info entry on the session manager, as pi's own --name writes it, once the open's checks pass. On resume, only when the session never had one, so a name the user cleared stays cleared.
    • A blank name fails the open before anything starts.
  • cursor, kimi, grok, antigravity, opencode (both lines), pi-durable and morph refuse it with UnsupportedOptionError, declared in refusedSessionOptions.

Unavailable resume targets

  • SessionUnavailableError has sessionId, reason (archived or in_use) and cause: { method, native }, alongside SessionNotFoundError. It is exported from both contract entries.
  • codex maps its -32600 words to it: session <id> is archived. … and thread <id> already has an active writer. An unloaded sub-agent's refusal keeps its own error.
  • OAR never unarchives a thread: that reverses the user's own action and puts the thread back where they removed it from, so the host decides.

Behavior changes

  • RefusableSessionOption gains "name".
  • A codex resume of an archived or held thread now rejects with SessionUnavailableError, not a plain Error. The message and cause are unchanged.

Evidence (scripted providers, no tokens)

  • experiments/codex-session-name.ts, codex 0.162.0, with a second app-server standing in for the user's app:
    • a new thread has no name, and thread/name/set reads back on thread/read and on the resume reply;
    • both refusals carry the exact words above;
    • after thread/unarchive the resume works and a turn completes.
  • Vendor tests, run in CI against the real CLIs and SDK:
    • codex-session-name (codex-aimock): both refusals by reason, the name read back, a resume that keeps the existing name, and an unnamed thread named on resume.
    • claude-session-name (claude-aimock): claude reports the name as session_title_changed, and a resume given another name keeps the original.
    • pi-session-name (pi-aimock): pi's own session list shows the name, a resume keeps it, and an unnamed session gets one on resume.
  • Unit tests:
    • codex: naming on start, and on resume for null, "" and an existing name;
    • codex: a refused name fails the open, and both refusals are typed;
    • claude: launch arguments;
    • the refusal matrix.
  • A second review (subagent) found that a blank name was silently dropped on claude and pi, and that codex and pi could rename before a later check refused the open. Both are fixed in the second commit, with tests.
  • Typecheck, lint and the full unit suite (1753 tests) pass, as do the codex, claude and pi vendor suites.

🤖 Generated with Claude Code

exe.dev user and others added 2 commits October 12, 2026 09:35
A host that shares the user's native home has its sessions show up in the
user's own app, unnamed, and two resume refusals follow from the user's
app (codex 0.162.0): an archived thread and a thread another app-server
holds. Both reached the host as generic errors.

- SessionOptions.name: the session's display name, through claude
  `--name`, codex `thread/name/set` and pi `setSessionName`. A new session
  gets it; a resume sets it only where the runtime reports the current
  name and there is none (codex, pi), so a user's name is never replaced;
  claude keeps its name on resume. Every other runtime refuses it.
- SessionUnavailableError with reason `archived` or `in_use`, from codex's
  -32600 words. OAR never unarchives: that reverses the user's own action,
  and the host decides.

Evidence: experiments/codex-session-name.ts and vendor tests for codex,
claude and pi that read the name back through each runtime's own
interface; the codex one also produces both refusals with a second
app-server standing in for the user's app.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From a second review of the session name change:
- A blank SessionOptions.name fails the open before anything starts.
  claude and pi opened unnamed without a word, and codex refused it only
  after the thread opened.
- codex names the thread after the resume effort check, and pi after its
  model and effort checks, so a refused open renames nothing.
- pi writes the name as its own `--name` does, a session_info entry on the
  session manager, so no extension sees a rename event; a resume names
  only a session that never had one, keeping a name the user cleared.
- Docs: morph's refused list, the codex pinning comment, the matrix rows.
- Tests: blank names on claude, codex and pi; pi-durable's refusal; the
  unavailable error's redaction; an unnamed codex thread named on resume.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 633b724 into main Oct 12, 2026
17 checks passed
@xxchan
xxchan deleted the feat/session-name branch October 12, 2026 10:00
@xxchan xxchan mentioned this pull request Oct 12, 2026
xxchan added a commit that referenced this pull request Oct 12, 2026
Release OAR and CLI 0.59.0. This PR changes only the two package version
fields.

**Added: `SessionOptions.name`** (#368, #369)
- The session's display name in the runtime's own UI and session list,
so a user who shares the runtime's home with a host can tell the host's
sessions from their own:
  - claude: `--name`;
  - codex: `thread/name/set`;
  - pi: a `session_info` entry, as pi's own `--name` writes it.
- A new session gets it. A resume never replaces a name the session has,
which may be the user's:
- codex and pi name a resumed session only when it has none (pi: never
had one);
  - claude keeps its name on resume.
- The name is set only once the open's checks pass, and a blank name
fails the open before anything starts.
- cursor, kimi, grok, antigravity, opencode, pi-durable and morph refuse
it with `UnsupportedOptionError`.

**Added: `SessionUnavailableError`** (#368, #369)
- `session({ resume })` rejects with it when the runtime keeps the
conversation but will not open it now. It carries `sessionId`, `reason`
and `cause: { method, native }`.
- `archived`: the user archived it in their app. OAR never unarchives
it: that reverses the user's own action, so the host decides.
- `in_use`: another process, such as the user's app, holds it. Retry
once that process lets go.
- codex reports both (`session <id> is archived. …`, `thread <id>
already has an active writer`). Before, both were plain errors.

**Behavior changes**
- `RefusableSessionOption` gains `"name"`.
- A codex resume of an archived thread, or of one another app-server
holds, rejects with `SessionUnavailableError` instead of a plain
`Error`. The message and cause are unchanged.

Validation: #369 passed all 17 checks on its final head, and its merged
tree equals its CI tree. Verified with scripted providers and no tokens
(`experiments/codex-session-name.ts`, codex 0.162.0, a second app-server
standing in for the user's app). New vendor tests read the name back
through codex, claude and pi themselves, and produce both codex
refusals. A second review by a subagent found that a blank name was
silently dropped on claude and pi, and that a later check could refuse
an open after the rename. Both were fixed before merge. After this PR
passes CI and merges, tag its exact squash commit as `v0.59.0` to
trigger npm trusted publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan added a commit that referenced this pull request Oct 12, 2026
…372)

Found by Lookout's daily inspection of 0.59.0 (#369).

- A blank `SessionOptions.name` threw a plain `Error`. Invalid
`additionalDirectories` throw `UnsupportedOptionError` naming the
option, so a host that catches by type missed the name case.
- A name with a NUL character reached claude's command line and failed
in Node's spawn ("The argument 'args[12]' must be a string without null
bytes").

Both now reject with `UnsupportedOptionError` on `name` before anything
starts, on claude, codex and pi (the runtimes that take a name), with
the message `name must not be blank or contain NUL characters`. Docs and
the `SessionOptions` comment say so.

**Behavior change:** a blank name's error is now an
`UnsupportedOptionError` instead of a plain `Error`. Released in 0.59.0
earlier today.

Validation: `tests/refused-session-options.test.ts` covers `""`, `" "`
and `"a\0b"` on claude, codex and pi. Typecheck, lint and the full unit
suite (1754 tests) pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session name option, and distinct errors for archived and in-use resume targets

1 participant