feat(coding): add project identity UX

This commit is contained in:
2026-08-26 18:48:22 +08:00
parent 5ac08d509f
commit ce8e2103d9
10 changed files with 683 additions and 0 deletions

View File

@@ -50,4 +50,53 @@ describe('coding project Host facade', () => {
['/api/coding/conversations/conversation%2F1', { method: 'DELETE' }],
]);
});
it('sends explicit identity choices and a literal independent-copy confirmation', async () => {
hostApiFetch
.mockResolvedValueOnce({ snapshot: { project: { id: 'local-1' }, config: { projectId: 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa' }, knowledgeFiles: [] } })
.mockResolvedValueOnce({ snapshot: { project: { id: 'local-1' }, config: { projectId: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb' }, knowledgeFiles: [] } })
.mockResolvedValueOnce({ snapshot: { project: { id: 'local-1' }, config: { projectId: 'cccccccc-cccc-4ccc-8ccc-cccccccccccc' }, knowledgeFiles: [] } });
const {
createCodingProject,
isCanonicalCodingProjectId,
makeCodingProjectIndependentCopy,
resolveCodingProjectIdentity,
} = await import('@/lib/coding-projects');
await createCodingProject({
projectPath: 'C:/projects/new',
projectType: 'custom',
identity: { kind: 'create' },
});
await resolveCodingProjectIdentity('local-1', {
kind: 'bind',
projectId: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb',
});
await makeCodingProjectIndependentCopy('local-1');
expect(isCanonicalCodingProjectId('bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb')).toBe(true);
expect(isCanonicalCodingProjectId('BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB')).toBe(false);
expect(isCanonicalCodingProjectId('not-a-project-id')).toBe(false);
expect(hostApiFetch.mock.calls).toEqual([
['/api/coding/projects/create', {
method: 'POST',
body: JSON.stringify({
projectPath: 'C:/projects/new',
projectType: 'custom',
identity: { kind: 'create' },
}),
}],
['/api/coding/projects/identity', {
method: 'POST',
body: JSON.stringify({
localProjectId: 'local-1',
identity: { kind: 'bind', projectId: 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb' },
}),
}],
['/api/coding/projects/identity/independent-copy', {
method: 'POST',
body: JSON.stringify({ localProjectId: 'local-1', confirmed: true }),
}],
]);
});
});