mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 18:39:33 +01:00
fix: apply the review items for #755 at merge
Say that settings.yaml is shared only until the session's first settings write (dsh saves by rename, which replaces the link), warn when a session's own DSH_HOME does not answer and the server's home is linked instead, test guardSessionConfigDirHome, and document the linkFromRealHome exception and what a custom-model dsh session does not carry over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c29aedbc5
commit
8c317d84c8
7 files changed
+83
-5
No files matched your search
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @fileoverview `guardSessionConfigDirHome` probes a session-supplied configDir home before
|
||||
* the apply runs synchronous fs calls on it (the #516 rule): a home that does not answer is
|
||||
* hidden from the apply, so it links from the server's own home instead and says so.
|
||||
*
|
||||
* The probe is mocked: a mount that never answers is the case under test, and a real one
|
||||
* cannot be made here.
|
||||
*/
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('../src/utils/bounded-path-probe.js', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('../src/utils/bounded-path-probe.js')>();
|
||||
return { ...actual, probePathKind: vi.fn() };
|
||||
});
|
||||
|
||||
import { getCli } from '../src/config/cli-registry/registry.js';
|
||||
import { probePathKind } from '../src/utils/bounded-path-probe.js';
|
||||
import { guardSessionConfigDirHome } from '../src/web/routes/session-routes.js';
|
||||
|
||||
const probe = vi.mocked(probePathKind);
|
||||
const deepseek = () => getCli('deepseek')!;
|
||||
const env =
|
||||
(values: Record<string, string>) =>
|
||||
(name: string): string | undefined =>
|
||||
values[name];
|
||||
|
||||
describe('guardSessionConfigDirHome', () => {
|
||||
afterEach(() => {
|
||||
probe.mockReset();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('hides only the home when it does not answer, and warns that the server home is used', async () => {
|
||||
probe.mockResolvedValue('unknown');
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
|
||||
const lookup = await guardSessionConfigDirHome(deepseek(), env({ DSH_HOME: '/mnt/dead/dsh', OTHER: 'kept' }));
|
||||
|
||||
expect(lookup('DSH_HOME')).toBeUndefined();
|
||||
expect(lookup('OTHER')).toBe('kept');
|
||||
expect(probe).toHaveBeenCalledWith('/mnt/dead/dsh', { pastCap: true });
|
||||
expect(warn).toHaveBeenCalledTimes(1);
|
||||
expect(String(warn.mock.calls[0][0])).toContain('/mnt/dead/dsh');
|
||||
});
|
||||
|
||||
it('passes a home that answers straight through', async () => {
|
||||
probe.mockResolvedValue('directory');
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
const base = env({ DSH_HOME: '/home/u/.dsh' });
|
||||
|
||||
expect(await guardSessionConfigDirHome(deepseek(), base)).toBe(base);
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('never probes a relative home: the apply refuses to join one', async () => {
|
||||
const base = env({ DSH_HOME: 'relative/dsh' });
|
||||
|
||||
expect(await guardSessionConfigDirHome(deepseek(), base)).toBe(base);
|
||||
expect(probe).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('never probes for a CLI with no linkFromRealHome recipe', async () => {
|
||||
const base = env({ CODEX_HOME: '/mnt/dead/codex' });
|
||||
|
||||
expect(await guardSessionConfigDirHome(getCli('codex')!, base)).toBe(base);
|
||||
expect(probe).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user