Implements the new-thread workspace model: every new thread starts from the
resolved default workspace mode instead of inheriting the previous thread's
choices, and worktree threads pin a fresh remote base with visible provenance.
Surface-derived defaults
- New `deriveThreadEnvModeFromSurface` setting (default on): attached
surfaces (desktop app, loopback browser on a host-managed environment)
default to the current checkout; detached surfaces (remote browser,
mobile, relay/SSH) default to a fresh worktree. Explicit
`defaultThreadEnvMode` still pins a mode globally when derivation is off,
keeping the wire value decodable by older clients.
- Sticky per-draft inheritance retired: sidebar/new-thread actions no longer
seed mode/branch/worktree from the active thread. `chat.newLocal` remains
the explicit current-checkout exception (draft-only).
- Per-project override (`projectThreadEnvModeOverrides` client setting) via
an explicit "Always … for this project" action in the workspace picker —
the only sanctioned way a composer choice retrains the default.
Fresh worktree bases without a blocking fetch
- `WorktreeBasePlanner`: fetch within the 30s freshness window counts as
fresh; concurrent fetches dedupe per repository; a failed fetch with a
successful fetch within the last hour proceeds on the last-known remote
commit (fail-visible, "stale" provenance); otherwise the bootstrap fails
closed and never silently falls back to a local ref.
- Composer prefetch: worktree-mode drafts fire `vcs.prefetchRemote` on open
so the send-time check almost always hits the fresh window.
- `newWorktreesStartFromOrigin` now defaults on.
Provenance and registry
- Bootstrap records a `worktree.base-pinned` thread activity (base ref, sha,
provenance, fetch time); the branch toolbar renders the pinned fact
("Worktree · a1b2c3f") with provenance on hover.
- `WorktreeRegistry` persists thread↔worktree records to
`stateDir/worktree-registry.json`, updated at bootstrap and on thread
deletion — groundwork for lifecycle/GC tooling.
- Deterministic branch naming: worktree branches derive from the thread id
(`t3code/<uuid-prefix>`), with collision suffixing server-side.
Composer UX
- Dirty-checkout disclosure both directions with one-click mode switch.
- Workspace picker labels choices as "this draft only".
Co-Authored-By: Claude Fable 5 <[email protected]>
Client Runtime
Shared client behavior for web and mobile. Public APIs are organized by package subpath. The package intentionally has no root export.
Public subpaths
| Subpath | Responsibility |
|---|---|
authorization |
Bearer and DPoP authorization plus token persistence contracts |
connection |
Targets, catalog, supervision, retries, registry, and onboarding |
environment |
Environment identity, descriptors, endpoints, and scoped keys |
errors |
Shared client error inspection |
operations |
Multi-step application workflows |
operations/projects |
Multi-step project creation workflows |
platform |
Platform capability and persistence service contracts |
relay |
Managed relay API and environment discovery |
rpc |
HTTP/RPC clients, protocol, sessions, and subscriptions |
state/<domain> |
Focused shared state, retention, reducers, and Atom constructors |
Dependency direction
Platform applications provide platform services. connection composes those
capabilities with authorization, relay, and rpc to supervise environment
sessions. Independent state modules consume the connection registry and expose
focused state or Atom constructors to application-owned runtimes.
Applications should import the narrowest relevant subpath. There is no broad
state export: use domain paths such as state/shell, state/threads,
state/terminal, or state/vcs. Subpath indices and explicitly exported domain
files are public API boundaries; all other files remain implementation details.