feat: confirm creating missing session cwd
This commit is contained in:
@@ -353,6 +353,17 @@ async function main() {
|
||||
const defaultCodexSession = await nextMessage(messages, ws, (msg) => msg.type === 'session_info' && msg.agent === 'codex' && msg.title === 'New Chat');
|
||||
assert(defaultCodexSession.cwd === homeDir, 'Codex new_session without cwd should default to HOME');
|
||||
|
||||
const missingCwd = path.join(tempRoot, 'missing-space', 'nested-project');
|
||||
ws.send(JSON.stringify({ type: 'new_session', agent: 'codex', cwd: missingCwd, mode: 'plan' }));
|
||||
const missingCwdError = await nextMessage(messages, ws, (msg) => msg.type === 'error' && msg.code === 'new_session_cwd_missing');
|
||||
assert(missingCwdError.cwd === missingCwd, 'Missing cwd error should return the requested absolute path');
|
||||
assert(!fs.existsSync(missingCwd), 'Missing cwd should not be created before explicit confirmation');
|
||||
|
||||
ws.send(JSON.stringify({ type: 'new_session', agent: 'codex', cwd: missingCwd, mode: 'plan', createCwd: true }));
|
||||
const createdCwdSession = await nextMessage(messages, ws, (msg) => msg.type === 'session_info' && msg.agent === 'codex' && msg.cwd === missingCwd);
|
||||
assert(createdCwdSession.cwd === missingCwd, 'Codex new_session should allow creating a missing cwd');
|
||||
assert(fs.existsSync(missingCwd), 'Missing cwd should be created when createCwd is enabled');
|
||||
|
||||
const directoryPayload = await fetchAuthedJson(port, token, `/api/fs/directories?path=${encodeURIComponent(pickerRoot)}`);
|
||||
assert(directoryPayload.currentPath === pickerRoot, 'Directory picker should return requested absolute path');
|
||||
assert(directoryPayload.defaultPath === homeDir, 'Directory picker should expose HOME as default path');
|
||||
|
||||
Reference in New Issue
Block a user