mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 03:09:33 +01:00
docs(adopt): document the routes and the overlay, correct stale comments
The two routes are public under /api/v1, so they get an API reference section. The overlay gets an architecture note and a CLAUDE.md rule: an adopted session has session.remote and session.docker undefined and a neutral workingDir, so any new code that reads workingDir as a workspace must also test isAdopted. That is the class of bug this round fixed a dozen times. Records a measured limit: while the view exists an owner's kill-session leaves the window alive under it until the tab closes. Comments that still called workingDir the foreign pane's cwd now say what is true since the wrapper got its neutral folder. Also drops a zh-CN key that duplicated an existing one, and updates the two structure tests pinned on the lines this round changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d62fa10c01
commit
1f6f21fd24
15 files changed
+148
-34
No files matched your search
@@ -304,7 +304,9 @@ export async function discoverRemoteForeign(hosts: RemoteHost[]): Promise<Foreig
|
||||
const { stdout } = await runWithRemoteSshLimit(() => execAsync(foreignRemoteProbeCommand(host), PROBE_OPTS), {
|
||||
maxWaitMs: FOREIGN_PROBE_TIMEOUT_MS,
|
||||
});
|
||||
sessions.push(...candidatesFrom(stdout, 'remote', host.id, { hostId: host.id, hostLabel: host.label }, where, notes));
|
||||
sessions.push(
|
||||
...candidatesFrom(stdout, 'remote', host.id, { hostId: host.id, hostLabel: host.label }, where, notes)
|
||||
);
|
||||
} catch {
|
||||
notes.push(`${where}: unreachable, or no tmux`);
|
||||
}
|
||||
|
||||
+14
-1
@@ -627,6 +627,12 @@ export interface ForeignAttachTarget {
|
||||
* one would rewrite the owner's keys for every session on their server, and it would
|
||||
* outlive our detach. Same reason `window-size` is left alone above. The owner's
|
||||
* bindings stay reachable from a tab, behind our own `send-prefix`, as theirs to use.
|
||||
* - ⚠️ While the view exists the window has two sessions holding it, so an owner's
|
||||
* `kill-session` on their own session leaves the window alive under the view
|
||||
* (measured on tmux 3.4: `tmux ls` then shows only `codeman-view-…`, the shell keeps
|
||||
* running) until the tab closes and `destroy-unattached` lets go of it. Exiting the
|
||||
* shell inside the pane ends it at once, view and all. Nothing here can tell the two
|
||||
* apart without a hook on the owner's server, which is not ours to install.
|
||||
* - Single line: the string crosses `bash -c "..."`, where a real newline would
|
||||
* not survive JSON escaping.
|
||||
*/
|
||||
@@ -746,7 +752,14 @@ export interface ForeignRemoteAttachOptions extends ForeignAttachTarget {
|
||||
*/
|
||||
export function buildForeignRemoteAttachCommand(opts: ForeignRemoteAttachOptions): string {
|
||||
const [ssh, batchMode, ...rest] = opts.sshArgs;
|
||||
return [ssh, batchMode, '-t', ...rest, opts.sshTarget, fshq(foreignRemoteShellCommand(buildForeignTmuxInvocation(opts)))]
|
||||
return [
|
||||
ssh,
|
||||
batchMode,
|
||||
'-t',
|
||||
...rest,
|
||||
opts.sshTarget,
|
||||
fshq(foreignRemoteShellCommand(buildForeignTmuxInvocation(opts))),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
}
|
||||
+7
-7
@@ -461,13 +461,13 @@ export function resolveMuxAttachCwd(
|
||||
//
|
||||
// ⚠️ An ADOPTED session needs the same treatment and does NOT get it from the
|
||||
// two checks above: its connection facts live on `adopt.docker`/`adopt.remote`,
|
||||
// so `session.docker` is undefined even for an in-container adoption. Its
|
||||
// `workingDir` is the FOREIGN pane's cwd — a path that routinely does not exist
|
||||
// on this host. Measured against a real container: adopting an in-container
|
||||
// session produced `workingDir: /workspace/pythonserver`, the local PTY spawn
|
||||
// inherited it as its cwd, and the session came up with `pid: null` and a blank
|
||||
// terminal while the wrapper tmux session and the in-container grouped view had
|
||||
// both been created successfully — i.e. it looked half-alive rather than failed.
|
||||
// so `session.docker` is undefined even for an in-container adoption. Its pane
|
||||
// only attaches, so no folder on this host means anything to it. Measured against
|
||||
// a real container, when `workingDir` still held the foreign pane's cwd: the local
|
||||
// PTY spawn inherited `/workspace/pythonserver`, and the session came up with
|
||||
// `pid: null` and a blank terminal while the wrapper tmux session and the
|
||||
// in-container grouped view had both been created successfully, so it looked
|
||||
// half-alive rather than failed.
|
||||
return remote || docker || adopt ? '/tmp' : workingDir;
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -2727,9 +2727,8 @@ export class TmuxManager extends EventEmitter implements TerminalMultiplexer {
|
||||
|
||||
// Replace the shell with the actual command (no echo in terminal). Keep
|
||||
// pane launch in /tmp, then cd inside bash against the current mount table.
|
||||
// ⚠️ An adopted pane must NOT be `cd`'d: it only attaches, and its
|
||||
// `workingDir` is the FOREIGN pane's cwd observed at adopt time — a path
|
||||
// that need not exist on this host at all (a container path, a remote path).
|
||||
// ⚠️ An adopted pane is never `cd`'d: it only attaches, and its `workingDir`
|
||||
// is the neutral wrapper folder, not where the foreign pane is.
|
||||
const launchCmd = remote || docker || adopt ? fullCmd : `cd ${JSON.stringify(workingDir)} && ${fullCmd}`;
|
||||
execSync(
|
||||
`${this.tmux()} respawn-pane -k -c ${TMUX_LAUNCH_CWD} -t "${muxName}" bash -c ${JSON.stringify(launchCmd)}`,
|
||||
@@ -2992,9 +2991,8 @@ export class TmuxManager extends EventEmitter implements TerminalMultiplexer {
|
||||
this.applyEnvOverrides(muxName, envOverrides, unsetEnvKeys);
|
||||
|
||||
// -c /tmp + cd bounce — see createSession() for rationale (stale FUSE state).
|
||||
// ⚠️ An adopted pane must NOT be `cd`'d: it only attaches, and its
|
||||
// `workingDir` is the FOREIGN pane's cwd observed at adopt time — a path
|
||||
// that need not exist on this host at all (a container path, a remote path).
|
||||
// ⚠️ An adopted pane is never `cd`'d: it only attaches, and its `workingDir`
|
||||
// is the neutral wrapper folder, not where the foreign pane is.
|
||||
const launchCmd = remote || docker || adopt ? fullCmd : `cd ${JSON.stringify(workingDir)} && ${fullCmd}`;
|
||||
await execAsync(
|
||||
`${this.tmux()} respawn-pane -k -c ${TMUX_LAUNCH_CWD} -t "${muxName}" bash -c ${JSON.stringify(launchCmd)}`,
|
||||
|
||||
@@ -378,9 +378,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
rescan.dataset.foreignAction = 'rescan-wide';
|
||||
rescan.disabled = this._foreignWideLoading === true;
|
||||
rescan.title = foreignT('Scan containers and remote hosts again');
|
||||
rescan.textContent = this._foreignWideLoading
|
||||
? foreignT('Scanning…')
|
||||
: foreignT('Rescan');
|
||||
rescan.textContent = this._foreignWideLoading ? foreignT('Scanning…') : foreignT('Rescan');
|
||||
header.appendChild(rescan);
|
||||
}
|
||||
|
||||
|
||||
@@ -1379,13 +1379,12 @@
|
||||
'⟳ all': '⟳ 全部',
|
||||
'⟳ local': '⟳ 本机',
|
||||
'Scanning…': '扫描中…',
|
||||
'Rescan': '重新扫描',
|
||||
'Open': '打开',
|
||||
Rescan: '重新扫描',
|
||||
'Opening…': '正在打开…',
|
||||
'Go to tab': '转到标签页',
|
||||
'this machine': '本机',
|
||||
'container': '容器',
|
||||
'remote': '远程',
|
||||
container: '容器',
|
||||
remote: '远程',
|
||||
'No sessions found outside Codeman.': '未发现在 Codeman 之外打开的会话。',
|
||||
'Could not reach the server.': '无法连接服务器。',
|
||||
'Could not open that session. Refreshing the list.': '无法打开该会话,正在刷新列表。',
|
||||
|
||||
@@ -93,8 +93,7 @@ export function registerReadMyMindRoutes(app: FastifyInstance, ctx: SessionPort
|
||||
// Remote-SSH cases skip git: workingDir is not local. Docker cases are
|
||||
// fine (the workspace is bind-mounted at the same host path). An adopted
|
||||
// session's workingDir is a neutral wrapper folder, so it skips git too.
|
||||
const workspace =
|
||||
session.remote || session.isAdopted ? null : await collectWorkspaceSignals(session.workingDir);
|
||||
const workspace = session.remote || session.isAdopted ? null : await collectWorkspaceSignals(session.workingDir);
|
||||
|
||||
const lastPromptTs = profile.recentPrompts[profile.recentPrompts.length - 1]?.ts;
|
||||
const tracker = ctx.runSummaryTrackers.get(id);
|
||||
|
||||
Reference in new issue
Block a user