mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-09 17:29:12 +00:00
fix: resume sessions with missing workdir (#1517)
This commit is contained in:
parent
9fb19154ac
commit
173bdfdab1
4 changed files with 28 additions and 4 deletions
5
.changeset/fix-missing-workdir-resume.md
Normal file
5
.changeset/fix-missing-workdir-resume.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@moonshot-ai/kimi-code": patch
|
||||
---
|
||||
|
||||
Fix resuming sessions whose original working directory no longer exists.
|
||||
|
|
@ -48,7 +48,7 @@ export class ConfigState {
|
|||
});
|
||||
if (changed.cwd) {
|
||||
this._cwd = changed.cwd;
|
||||
void this.agent.kaos.chdir(changed.cwd);
|
||||
this.agent.setKaos(this.agent.kaos.withCwd(changed.cwd));
|
||||
}
|
||||
if (changed.modelAlias) {
|
||||
this._modelAlias = changed.modelAlias;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,27 @@ import { emptyUsage } from '@moonshot-ai/kosong';
|
|||
import { ProviderManager } from '../../src/session/provider-manager';
|
||||
import type { KimiConfig } from '../../src/config';
|
||||
import { testAgent } from './harness';
|
||||
import { createFakeKaos } from '../tools/fixtures/fake-kaos';
|
||||
|
||||
describe('ConfigState model capabilities', () => {
|
||||
it('updates the agent cwd without requiring the directory to exist', () => {
|
||||
const chdir = vi.fn(async () => {
|
||||
throw Object.assign(new Error('missing workspace'), { code: 'ENOENT' });
|
||||
});
|
||||
const ctx = testAgent({
|
||||
kaos: createFakeKaos({
|
||||
getcwd: () => '/workspace',
|
||||
chdir,
|
||||
}),
|
||||
});
|
||||
|
||||
ctx.agent.config.update({ cwd: '/tmp/missing-workdir' });
|
||||
|
||||
expect(ctx.agent.config.cwd).toBe('/tmp/missing-workdir');
|
||||
expect(ctx.agent.kaos.getcwd()).toBe('/tmp/missing-workdir');
|
||||
expect(chdir).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('computes provider and model capabilities from ProviderManager metadata', () => {
|
||||
const ctx = testAgent({
|
||||
providerManager: new ProviderManager({
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ export function createFakeKaos(
|
|||
overrides?: Partial<Kaos>,
|
||||
envLayers: readonly Record<string, string>[] = [],
|
||||
): Kaos {
|
||||
// Hold cwd in a closure so `chdir` (which `config.update({cwd})` now
|
||||
// routes through) can mutate it and later `getcwd()` calls see the
|
||||
// update — mirroring real-kaos semantics without needing a backing fs.
|
||||
// Hold cwd in a closure so tests that call `chdir` directly can mutate it
|
||||
// and later `getcwd()` calls see the update — mirroring real-kaos semantics
|
||||
// without needing a backing fs.
|
||||
let cwd = overrides?.getcwd?.() ?? '/workspace';
|
||||
const base: Kaos = {
|
||||
name: 'fake',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue