Files
Codeman/test/remote-shared-sessions.test.ts
T
Aamer AkhterandClaude Opus 4.8 b2ebdcbf47 COD-106 shared/collaborative remote tmux sessions (window-size latest + shared badge)
Two Codeman clients attaching the same durable remote tmux session at different
viewports would fight: tmux sizes a window to the SMALLEST attached client by
default. Push `window-size latest` to the remote session config so the window
tracks the most-recently-active client instead, letting concurrent clients
coexist; surface the client count for a "shared · N" badge.

Reconciled onto upstream PR #145: #145 moved the durable remote session onto the
dedicated `-L codeman-remote` socket under a `codeman-ssh-` name and scoped every
tmux set-option PER-SESSION (`set -t <name>`, never `-g`) so a shared remote tmux
server's OTHER sessions keep their own prefix/mouse/sizing. The original COD-106
commit added `set -g window-size latest` (GLOBAL) on the old `-L codeman` socket —
a regression against #145's hardening. This commit layers the window-size feature
onto #145's structure as `set -t <name> window-size latest` (per-session, on the
codeman-remote socket). Test assertions updated to the per-session form
(remote-shared-sessions.test.ts) and the byte-identical launch-command test
(remote-ssh-options.test.ts) extended with the window-size line — which supersedes
the separate f09323c9 assertion fix (dropped: it targeted the global form and also
carried unrelated CLAUDE.md doc changes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 16:03:03 -04:00

40 lines
1.8 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { buildRemoteLaunchCommand } from '../src/tmux-manager.js';
import { parseRemoteSessionList } from '../src/remote-hosts.js';
import type { SessionRemote } from '../src/types.js';
// COD-106 — shared/collaborative remote sessions: window-size policy so concurrent
// clients don't fight, and a client-count surfaced for the "shared · N" badge.
describe('COD-106 shared remote sessions', () => {
const remote: SessionRemote = {
hostId: 'h',
label: 'aa',
host: '192.168.55.170',
username: 'aakht',
remotePath: '/tmp',
commands: { shell: 'exec bash -l' },
};
it('launch command sets window-size latest (so multi-client attach does not clamp to smallest)', () => {
const cmd = buildRemoteLaunchCommand({ mode: 'shell', remote, sessionId: 'cod106aaa' });
// Per-session scoped on the dedicated `codeman-remote` socket (PR #145 hardening).
expect(cmd).toContain('set -t codeman-ssh-cod106aa window-size latest');
// still has the COD-104 config (no regression)
expect(cmd).toContain('set -t codeman-ssh-cod106aa status off');
expect(cmd).toContain('new-session -A -s codeman-ssh-cod106aa');
});
it('parses session_attached as a CLIENT COUNT (>1 = shared)', () => {
const rows = parseRemoteSessionList(
['codeman-solo\\t1\\t100\\t1', 'codeman-shared\\t2\\t200\\t3', 'codeman-idle\\t0\\t300\\t1'].join('\n')
);
const byName = Object.fromEntries(rows.map((r) => [r.name, r]));
expect(byName['codeman-solo'].attachedClients).toBe(1);
expect(byName['codeman-solo'].attached).toBe(true);
expect(byName['codeman-shared'].attachedClients).toBe(2); // shared
expect(byName['codeman-shared'].attached).toBe(true);
expect(byName['codeman-idle'].attachedClients).toBe(0);
expect(byName['codeman-idle'].attached).toBe(false);
});
});