fix: adopted tmux targets, hung servers and the attach chain (release review)

Names tmux reads as target syntax (`@1`, `%1`, `=eq`, a bare `~`) passed the
has-session guard by name and then joined something else in new-session -t:
another session, or a fresh shell on the foreign server. They are refused at
discovery now, and take the existing skipped note.

One stopped tmux server emptied the whole local list and left a stuck client
per scan. Each server now gets a bounded ping with stdout at /dev/null first,
because a tmux client hands dups of its stdout to the server: a stopped server
holds our pipe open after the client is dead, so a watchdog around list-panes
cannot work. The probe runs in its own process group, all three transports
keep the rows read before a failure, and a missed ping becomes a note.

The attach and the probe pass -u, so a POSIX-locale container no longer garbles
the tab or lists a non-ASCII name as underscores. A docker attach gets the same
TERM and COLORTERM an owned container's exec gets.

A missing tmux no longer reads as "session is gone", and the launch line's `$`
now reaches bash unexpanded, so the ssh attach's PATH line is expanded at the
far end, as the probe's already was.

fix-plan/write, fix-plan/read and ralph-prompt/write refuse an adopted session:
its workingDir is the neutral /tmp, so they read and wrote a predictable name
in a folder anyone can write to.

FOREIGN_MAX_SOCKETS is gone: it capped nothing, and a real cap in glob order
would never reach `default` on a box with many `codeman-*` sockets (this one
has 212). Closing an adopted tab re-reads the outside-sessions list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-11-06 04:33:42 +01:00
1 parent 36d8942744
commit aa40cca343
9 files changed
+620 -81

No files matched your search

+28
View File
@@ -184,6 +184,34 @@ describe('closing the active session', () => {
});
});
describe('closing an adopted tab', () => {
it('re-reads the outside-sessions list once the wrapper is gone', async () => {
// The home screen loads that list as soon as the tab goes, which is BEFORE the DELETE
// lands, so the row kept saying "Go to tab" with no tab behind it until the next poll.
const app = makeApp(A, [A]);
app.sessions.set(A, { id: A, adopt: { targetSession: 'work' } });
const order: string[] = [];
app._apiDelete = vi.fn(async () => {
order.push('delete');
return { ok: true, status: 200 };
});
app.loadForeignSessions = vi.fn(async () => void order.push('reload'));
await app.closeSession(A);
expect(order).toEqual(['delete', 'reload']);
});
it('leaves the list alone for a session of our own', async () => {
const app = makeApp(A, [A]);
app.loadForeignSessions = vi.fn();
await app.closeSession(A);
expect(app.loadForeignSessions).not.toHaveBeenCalled();
});
});
describe('closing is optimistic', () => {
it('drops the tab and selects the next one BEFORE the server answers', async () => {
const app = makeApp(A);