mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 18:39:33 +01:00
fix(adopt): never create a session on someone else's tmux server
Review items 1 and 2 on #510. `tmux new-session -t <name>` does not fail on a missing target. Measured on 3.3a: with only `work-prod` present it joined that session's group, with nothing matching it opened a fresh shell, and on an empty socket it started a tmux server that had none. The command re-runs whenever the wrapper pane is respawned, and boot recovery does that for every dead pane, so after the owner exits their session the next Codeman restart would put a new shell on their default socket, in their container, or on their ssh host. The invocation now begins with an exact-match `has-session -t '=<target>'` and exits with a message when it misses. Measured: `has-session` does not start a server on an empty socket, and the `=` prefix is what stops it matching `work-prod` by prefix. `=` cannot go on `new-session -t` itself — tmux reads it as part of the name and creates a group literally called `=work` — so it has to be its own command. The read-only `attach-session -r` fallback is gone rather than fixed. It hung off `||`, so it fired on ANY `new-session` failure and not just an old tmux: a leftover view from a previous adoption of the same Codeman session makes `new-session` report `duplicate session` (measured), and the user then got a read-only client showing the owner's status bar, with typed input dropped, while the API reported success. Our own stale view is now removed first with a `kill-session -t '=<our view>'` — the view name is derived from the Codeman session id so it is provably ours, and measured, killing by name touches only that session and leaves the owner's alone. Nothing to remove is the normal case, so that step must not abort the chain. `SessionAdopt.readOnly` goes with it. It was never set and never read, while its comment claimed the UI surfaced it. Adoption now either attaches a writable view or fails with a message; there is no third state.
This commit is contained in:
1 parent
245ee68c7c
commit
aec4867821
3 files changed
+119
-21
No files matched your search
@@ -424,12 +424,6 @@ export interface SessionAdopt {
|
||||
* Created with `destroy-unattached on` so it evaporates with our pane.
|
||||
*/
|
||||
viewSession: string;
|
||||
/**
|
||||
* True when the foreign tmux was too old to group and we fell back to a
|
||||
* READ-ONLY attach. Surfaced in the UI — the fallback must never silently be
|
||||
* a writable bare attach, which would resize the owner's terminal.
|
||||
*/
|
||||
readOnly?: boolean;
|
||||
/** The pane cwd at adoption time. Informational: an adopted pane is never `cd`'d. */
|
||||
paneCurrentPath?: string;
|
||||
remote?: AdoptRemoteConnection;
|
||||
|
||||
Reference in new issue
Block a user