Task 9: Delete the Local PTY runtime
Summary
Delete the Local PTY runtime for parent plan #436. After Task 8 (#451 on task-8-drop-profiles) sqlite profiles / mapping tables are DROPped, notes live on checkout_notes, and Herdr is already the production default — but TWOCODE_RUNTIME=local / --twocode-runtime=local still constructs LocalAdapter, spawns portable-pty sessions, writes pty_sessions, and keeps a dual-runtime RuntimeRouter. This task removes that second owner: Local adapter, PTY spawn path, Local-only IPC, the env/flag fallback, and the pty_sessions table. Do not leave an unused dual-runtime router "just in case".
A profile remains an open Herdr workspace. The profile id is the Herdr workspace_id (wN). Join key: canonical projects.folder ↔ live checkout / pane cwd (Task 1 contract, docs/herdr-integration.md). projects / project_groups / checkout_notes stay. Do not launch/adopt the project-folder default (Task 10). Do not start a second events.subscribe / name HerdrRuntimeSync in lib.rs. Pin stays v0.9.0. GUI exit still does not server stop. Local must never own a worktree Herdr already owns — after this branch Local cannot own anything.
This branch finishes #446 by deleting the Local-flag path (no git worktree remove from TWOCODE_RUNTIME=local). Do not implement a live-path Local-delete lock instead of deletion. #447 is already closed by Task 6/8 (pane_id / leftover UUID removal); DROP pty_sessions here is leftover-table cleanup, not a session-store rewrite.
Dependencies: Parent plan #436. Prerequisites: #437 (Task 1), #439 (Task 2), #441 (Task 3), #443 (Task 4), #445 (Task 5), #448 (Task 6), #449 (Task 7), #451 (Task 8). Open #438, #440, #442, #444, #450 are line-count tracking only — not blockers. Open #394 issues #395–#434 (including #394 Task 9 / #419, #394 Task 22 / local agent detector, and #403) must not be implemented or closed here.
Work to complete
-
Remove the Local fallback and Local adapter
- Delete
TWOCODE_RUNTIME=localand--twocode-runtime=local.select_gui_backend/build_gui_runtime/bridge::build_runtimealways attach Herdr (ensure_herdr_listener+ JSON clients). Do not add a Settings runtime toggle. Do not silently fail over to a Local shell when the sidecar is absent — keep today’s fail-closedHerdrServerAbsent/HerdrServerIncompatible. - Delete
LocalAdapterand the Local field onRuntimeRouter. Collapse the router to Herdr-only: nowith_backend(Local)production path, no Local match arms increate_with_runtime/list_with_runtime/reconcile_profile_checkout/ notes / watcher / Git. Remove syntheticdefault-{project_id}list/create/delete (list_synthetic_local_profiles,reconcile_local_profile_checkout,local_extras_*_closed). Checkout is live Herdr only. - Remove
RuntimeBackend::Localfrom production (enum + generated TS union).get_session_backendmay be deleted if unused, or may always return Herdr — do not keep a code path that still returns"local". Dual-ownership Local+Herdr refusal becomes vacuous; do not keep unused Local-PTY kill-refusal "just in case".
- Delete
-
Delete the PTY spawn path and Local-only IPC
- Remove portable-pty spawn (
infra::pty), Local session lifecycle (service::ptycreate/restore/close/gc), pty_log files, and LocalPtySessionMap/ flush-sender /PtyOutputSinksbyte plumbing inlib.rs/bridge.rs. Dropmark_all_closed/gc_orphan_logsstartup that only served sqlite PTY rows. Shell-init ZDOTDIR injection used only by Local spawn goes with it. Keep Herdrpane.send_inputinit/startup. Keeplist_available_shells(GUI shell picker, not a spawn backend). - Local-only IPC is dead:
stream_pty_output/ Localattach_pty_outputsinks, Localrestore_pty_sessionspawn,get_pty_session_historylog files,delete_pty_session_recordsqlite delete,flush_pty_outputas a Local log flush. Keep Herdr-backed commands the GUI already uses (create_pty_session,write_to_pty,resize_pty,close_pty_session,list_project_sessions,stream_herdr_output, Herdr attach). Frontend always uses the Herdr frame stream (startHerdrFrameStream); deletestartLocalByteStreamand the Local branch inTerminal.tsx. hydrateRestorableSessionsalways reattaches Herdrpane_idtabs (Task 6). Delete the Local pending-restore path (restorePtySessionspawn,sessionHistorysqlite scrollback map). Same New Tab / tab strip clicks and labels. Do not remove the frontend xterm agent detector (detector// OSC) — that is #394 Task 22 leftover, not this plan.
- Remove portable-pty spawn (
-
DROP
pty_sessions- New embedded Diesel migration DROPs
pty_sessions. Keepprojects/project_groups/checkout_notes. Regenerateschema.rsvia Diesel; do not hand-edit. Removerepo::ptyand Diesel#[diesel(table_name = pty_sessions)]models. - IPC DTO
PtySessionRecord(id=pane_id,profile_id=workspace_id, …) stays as a derived GUI type fromsession.snapshot, same as Task 8’sProfile. Decouple it from the dropped table. Herdr still must not INSERT/UPDATE/DELETE sqlite session rows (there are none).
- New embedded Diesel migration DROPs
-
Prove without swallowing Task 10
- Colocated / integration tests: production constructor has no Local backend;
TWOCODE_RUNTIME/--twocode-runtime=localare gone from production source;create_session/ New Tab never increment a live portable-pty count; Herdr-down still fail-closes (no Local spawn); list/create/delete/Git/FS/watcher/notes have no Local syntheticdefault-{project_id}arm; after migratepty_sessionsis absent andprojects/checkout_notesremain; Herdr list still liveworkspace_id/pane_id; production guards (noLocalAdapter, nonative_pty_systemspawn, noINSERT INTO pty_sessions, noHerdrRuntimeSyncname inlib.rs). - Rewrite or delete tests that construct
RuntimeRouter::with_backend(Local)/TWOCODE_RUNTIME=local/ sqlitepty_sessionsas the session store. Keep Herdr adapter fakes. Invert frontend transport/restoration tests that mockgetSessionBackend("local"). - Update
docs/herdr-integration.md: Task 9 done on this branch; Local PTY / env flag /pty_sessionsgone; dual-runtime router not retained. Do not bump v0.9.0. If line count grows past the estimate, open a tracking issue; do not fold Task 10 into this branch.
- Colocated / integration tests: production constructor has no Local backend;
Likely files and directories
- Delete:
src-tauri/crates/service/src/runtime/local.rs, Local spawn insrc-tauri/crates/infra/src/pty.rs/src-tauri/crates/infra/src/pty_log.rs, Local lifecycle insrc-tauri/crates/service/src/pty.rs,src-tauri/crates/repo/src/pty.rs. Local-only shell-init injection if unused after spawn removal. - New:
src-tauri/migrations/<timestamp>_drop_pty_sessions/— DROPpty_sessionsonly. - Update:
src-tauri/crates/model/src/schema.rs(regenerate),src-tauri/crates/model/src/runtime.rs(no Local variant),src-tauri/crates/model/src/pty.rs(DTO, not Diesel table). - Update:
src-tauri/crates/service/src/runtime.rs— Herdr-only router; delete env/flag parse and Local adapter field. - Update:
src-tauri/crates/service/src/runtime/herdr.rs,src-tauri/crates/service/src/project.rs,src-tauri/crates/service/src/profile.rs,src-tauri/crates/service/src/filesystem.rs,src-tauri/crates/service/src/watcher.rs— remove Local match arms only; do not change Herdr list/create/close/live-cwd behavior. - Update:
src-tauri/src/bridge.rs,src-tauri/src/lib.rs,src-tauri/src/handler/pty.rs— drop Local byte sinks / session map; keep Herdr commands. - Update frontend:
src/features/terminal/lib/terminalTransport.ts,src/features/terminal/Terminal.tsx,src/features/terminal/restoration.tsand colocated tests — Herdr-only transport/reattach. - Update:
docs/herdr-integration.md— Task 9 done on this branch. - Update tests: colocated runtime/profile/project tests plus
src-tauri/tests/integration_pty_db.rs,src-tauri/tests/integration_migrations.rs.bun run typegenif IPC signatures change; do not editsrc/generated/by hand. - Do not change: Herdr adapter create/list/close/attach internals beyond deleting Local branches, sidecar pin, Settings runtime toggle, launch/adopt on project open (Task 10), Git/file-tree/notes/tab UI redesign,
lib.rsnamingHerdrRuntimeSync, frontenddetector/agent manifests.
Estimated changes: 700–1100 lines total, additions plus deletions, including tests and migration SQL; excluding generated files, lockfile churn and binary artifacts. Material scope growth should become a separate issue.
Acceptance criteria
- [ ] Local PTY is gone: no
LocalAdapter, no portable-pty spawn, noTWOCODE_RUNTIME/--twocode-runtime=local, no productionRuntimeBackend::Local.RuntimeRouteris Herdr-only; there is no unused dual-runtime Local arm. - [ ] Diesel migration DROPs
pty_sessions.projects/project_groups/checkout_notesremain. sqliteprofilesstays absent (Task 8). sqliteprofilesis not source of truth. - [ ] New Tab / write / resize / close / list / restore use Herdr (
pane_id/ snapshot). GUI always uses the Herdr frame stream. Local byte stream IPC and sqlite scrollback restore are gone. Herdr-down still fail-closes; it does not spawn a Local PTY. - [ ] Profile list/create/delete, Git, file tree, watchers, and notes have no Local synthetic
default-{project_id}catalog. Checkout stays live Herdr cwd.projectsstill round-trip in sqlite. - [ ] Named UX exceptions: route ids are
workspace_id; tab ids arepane_id; empty Herdr profile list until Task 10; splits flattened as extra tabs; non-git New Profile is folderworkspace.create; Herdr-down New Tab errors instead of a Local shell.TWOCODE_RUNTIME=localis gone (not a GUI click/label). Default Herdr New Profile / Delete Profile / tab clicks and labels stay. Do not add a Settings runtime toggle. - [ ] No launch/adopt of the project-folder default. No second
events.subscribe.lib.rsstill does not nameHerdrRuntimeSync. Pin stays v0.9.0. GUI exit still does notserver stop. Frontend xterm agent detector stays (#394 Task 22 leftover). - [ ] Tests:
cargo test --workspacefromsrc-tauri(orcargo test --workspace --exclude codewhere GTK is unavailable). Frontend lint/typecheck/tests for transport/restoration/Terminal scope.bun run typegenif IPC signatures change; do not editsrc/generated/by hand. - [ ] No pull request until parent #436 is complete.
Out of scope
- Launch/adopt of the project-folder default (
worktree.open/workspace.createon project open) (Task 10). - Reintroducing a Local fallback, Settings runtime toggle, or unused dual-runtime Local arm.
- Starting a new
HerdrRuntimeSync/events.subscribe, changing the v0.9.0 pin, or #394 Task 16 / #432. - Removing the frontend xterm agent detector (#394 Task 22).
- Implementing or closing #394 issues #395–#434 (including #394 Task 9 / #419 and #403) or line-count trackers.
- Opening a pull request.
Standing constraints
- Do not treat sqlite
profilesas source of truth. Do not add a path cache that can disagree with live Herdr and still win. projects(and project groups / notes-as-2code-data) remain 2code sqlite.- Join key remains path ↔ live Herdr cwd/worktree group.
- Deleting the Local PTY/agent spawn path is in scope. Never let Local and Herdr own the same worktree (Local is removed).
- Preserve existing 2code interaction. UX change is allowed only when Herdr cannot back the old clicks/labels; this task names no new GUI exception. Removing the Local env/flag is not a click/label redesign.
- One task; stack on
task-8-drop-profiles. Do not open a PR until the parent plan is complete.