mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 11:19: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
@@ -33,7 +33,10 @@ const ELSEWHERE = [
|
||||
];
|
||||
const ALL = [...FROM_MODULE, ...LOCATION_WORDS, ...TOGGLE, ...ELSEWHERE];
|
||||
|
||||
const dom = new JSDOM('<!doctype html><html><body></body></html>', { runScripts: 'outside-only', url: 'http://localhost/' });
|
||||
const dom = new JSDOM('<!doctype html><html><body></body></html>', {
|
||||
runScripts: 'outside-only',
|
||||
url: 'http://localhost/',
|
||||
});
|
||||
vm.runInContext(I18N, dom.getInternalVMContext(), { filename: 'i18n.js' });
|
||||
const api = (dom.window as unknown as { CodemanI18n: Api }).CodemanI18n;
|
||||
api.configure({ language: 'zh-CN' });
|
||||
@@ -61,8 +64,10 @@ describe('the outside-sessions block in zh-CN', () => {
|
||||
});
|
||||
|
||||
it('adds each key to the dictionary once', () => {
|
||||
// Prettier leaves a key that is one word unquoted.
|
||||
for (const source of new Set(ALL)) {
|
||||
expect(I18N.split(`'${source}':`).length - 1, source).toBe(1);
|
||||
const bare = /^\w+$/.test(source) ? I18N.split(`\n ${source}: `).length - 1 : 0;
|
||||
expect(I18N.split(`'${source}':`).length - 1 + bare, source).toBe(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -95,7 +95,11 @@ describe('the wide scan is one-shot', () => {
|
||||
calls.push(path);
|
||||
return ok(
|
||||
path.includes('docker=1')
|
||||
? { sessions: [LOCAL, DOCKER], notes: ['docker box: not running, no tmux, or engine unreachable'], canScanWide: true }
|
||||
? {
|
||||
sessions: [LOCAL, DOCKER],
|
||||
notes: ['docker box: not running, no tmux, or engine unreachable'],
|
||||
canScanWide: true,
|
||||
}
|
||||
: { sessions: [LOCAL], notes: ['local: 1 session(s) skipped'], canScanWide: true }
|
||||
);
|
||||
});
|
||||
|
||||
@@ -483,7 +483,11 @@ describe('the docker and ssh transports', () => {
|
||||
|
||||
it('goes through the saved connection for an ssh host', () => {
|
||||
const cmd = buildAdoptSessionCommand(
|
||||
{ ...adopt, location: 'remote', remote: { hostId: 'h1', label: 'b', host: 'h.example', username: 'me', port: 2222 } },
|
||||
{
|
||||
...adopt,
|
||||
location: 'remote',
|
||||
remote: { hostId: 'h1', label: 'b', host: 'h.example', username: 'me', port: 2222 },
|
||||
},
|
||||
'abc12345'
|
||||
);
|
||||
expect(cmd.startsWith('ssh -o BatchMode=yes -t ')).toBe(true);
|
||||
@@ -506,7 +510,9 @@ describe('the docker and ssh transports', () => {
|
||||
mkdirSync(bin);
|
||||
// The real thing hands its LAST argument to the remote login shell.
|
||||
writeFileSync(join(bin, 'ssh'), '#!/bin/sh\nfor last; do :; done\nexec sh -c "$last"\n', { mode: 0o755 });
|
||||
writeFileSync(join(bin, 'tmux'), '#!/bin/sh\nfor a; do printf "<%s>" "$a"; done\nprintf "\\n"\n', { mode: 0o755 });
|
||||
writeFileSync(join(bin, 'tmux'), '#!/bin/sh\nfor a; do printf "<%s>" "$a"; done\nprintf "\\n"\n', {
|
||||
mode: 0o755,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -450,7 +450,10 @@ describe('an adopted session has no workspace of ours', () => {
|
||||
expect(status.json()).toMatchObject({ success: true, data: { state: 'unsupported', reason: 'adopted' } });
|
||||
const fetch = await app.inject({ method: 'POST', url: `/api/sessions/${ctx._sessionId}/git-fetch` });
|
||||
expect(fetch.json()).toMatchObject({ success: true, data: { state: 'unsupported', reason: 'adopted' } });
|
||||
const diff = await app.inject({ method: 'GET', url: `/api/sessions/${ctx._sessionId}/git-diff?repo=x&path=y&kind=z` });
|
||||
const diff = await app.inject({
|
||||
method: 'GET',
|
||||
url: `/api/sessions/${ctx._sessionId}/git-diff?repo=x&path=y&kind=z`,
|
||||
});
|
||||
expect(diff.statusCode).toBe(400);
|
||||
expect(git).not.toHaveBeenCalled();
|
||||
await app.close();
|
||||
|
||||
@@ -94,9 +94,11 @@ describe('Session Options modal structure', () => {
|
||||
expect(modal.match(/<button[^>]*data-tab="git"[^>]*>/)?.[0]).not.toContain('data-claude-only');
|
||||
const open = methodBody('openSessionOptions(sessionId)');
|
||||
expect(open).toContain('.set-rail-item[data-tab="git"]');
|
||||
// Remote and Docker sessions answer 'unsupported' on both git routes and the scheduler never fetches them,
|
||||
// so the entry goes the same way the Claude-only ones do.
|
||||
expect(open).toMatch(/gitTabBtn\.style\.display = session\.remote \|\| session\.docker \? 'none' : ''/);
|
||||
// Remote, Docker and adopted sessions answer 'unsupported' on both git routes and the scheduler never fetches
|
||||
// them, so the entry goes the same way the Claude-only ones do.
|
||||
expect(open).toMatch(
|
||||
/gitTabBtn\.style\.display = session\.remote \|\| session\.docker \|\| session\.adopt \? 'none' : ''/
|
||||
);
|
||||
});
|
||||
|
||||
it('makes the Git rows inert while a session follows the app, the way the keep-warm rows go inert', () => {
|
||||
@@ -150,6 +152,10 @@ describe('Session Options modal structure', () => {
|
||||
const open = methodBody('openSessionOptions(sessionId)');
|
||||
expect(open).toContain("getElementById('modalSessionPath')");
|
||||
expect(open).toContain('session.workingDir');
|
||||
expect(methodBody('async copySessionPath()')).toContain('_copyText(session.workingDir)');
|
||||
// An adopted session's workingDir is the neutral wrapper folder, so the row shows where the pane was.
|
||||
expect(open).toContain('session.adopt?.paneCurrentPath || session.workingDir');
|
||||
const copy = methodBody('async copySessionPath()');
|
||||
expect(copy).toContain('session?.adopt?.paneCurrentPath || session?.workingDir');
|
||||
expect(copy).toContain('_copyText(path)');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user