mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 16:39:42 +02:00
fix(review): harden + wire remote-host SSH cases end-to-end (PR #145)
- UI: add the missing data-tab="case-remote" tab button; dispatch it through submitCaseModal()/switchCaseModalTab() to linkRemoteCase() (was dead code). - Restore: restoreMuxSessions() now passes remote (muxSession.remote ?? savedState.remote) into the Session constructor, so remote metadata round-trips on restart instead of reattaching from a local cwd / respawning LOCAL / being erased from state.json. Recovery tests added. - Run flows: runClaude()/runShell() route remote cases through /api/quick-start (POST /api/sessions stat-validates workingDir locally); run*() skip the /api/*/status pre-check and omit inert config/env for remote cases. - Quick-start: resolve the remote case BEFORE the local CLI availability gates and skip isCodex/Gemini/OpenCodeAvailable() when remote; REJECT envOverrides/effort/codex/gemini/openCode config for remote (they don't cross ssh) instead of silently dropping them. - Injection: reject $, backtick, $( in remotePath + identityFile at the schema layer (they survive shellescape into the bash -c launch double-quote layer). Regression tests for $(...) and backtick payloads added. - Remote socket/name: launch on a DEDICATED -L codeman-remote socket under a codeman-ssh-<id> name that fails a remote Codeman's SAFE_MUX_NAME_PATTERN, so a remote instance can't adopt the session; scope tmux set-options per-session (never -g) so they don't mutate other sessions. - Kill: best-effort ssh 'tmux -L codeman-remote kill-session' on remote session kill (fire-and-forget, never blocks/throws the local kill) so the remote agent isn't orphaned forever. - Probe: wire checkRemoteTmuxAvailable() into POST /api/quick-start (structured OPERATION_FAILED) and as courtesy validation in remote-link; add a default -o ConnectTimeout=10 to buildSshConnectionArgs (overridable via extraSshOptions). - Command default: remote claude default is now 'exec claude --dangerously-skip-permissions' (per-host override stays the escape hatch), mirroring local non-interactive semantics. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -174,4 +174,24 @@ describe('session attachment history', () => {
|
||||
).toBe('/tmp');
|
||||
expect(resolveMuxAttachCwd('/opt/projects/Codeman')).toBe('/opt/projects/Codeman');
|
||||
});
|
||||
|
||||
it('round-trips remote metadata through the Session constructor (restart-recovery contract)', () => {
|
||||
// restoreMuxSessions() reconstructs recovered sessions via
|
||||
// `new Session({ ..., remote: muxSession.remote ?? savedState.remote })`. If that
|
||||
// remote does not survive toState(), the next persistSessionState() erases it from
|
||||
// state.json AND the attach cwd falls back to the (nonexistent-locally) remote path.
|
||||
const remote = {
|
||||
hostId: 'gpu-box',
|
||||
label: 'GPU Box',
|
||||
host: '10.0.0.42',
|
||||
username: 'ubuntu',
|
||||
remotePath: '/home/ubuntu/work',
|
||||
commands: { claude: 'exec claude --dangerously-skip-permissions' },
|
||||
};
|
||||
const restored = new Session({ workingDir: '/home/ubuntu/work', remote });
|
||||
const state = restored.toState();
|
||||
expect(state.remote).toEqual(remote);
|
||||
// Recovered attach cwd must be a LOCAL path, never the remote-only workingDir.
|
||||
expect(resolveMuxAttachCwd(state.workingDir, state.remote)).toBe('/tmp');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user