mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 04:18:05 +00:00
fix(browser): reset blank attach path to default
This commit is contained in:
@@ -93,11 +93,13 @@ router.put('/', async (req: Request, res: Response): Promise<void> => {
|
||||
|
||||
try {
|
||||
const current = getBrowserConfig();
|
||||
const nextClaudeUserDataDir =
|
||||
claude?.userDataDir === undefined ? current.claude.user_data_dir : claude.userDataDir.trim();
|
||||
mutateUnifiedConfig((config) => {
|
||||
config.browser = {
|
||||
claude: {
|
||||
enabled: claude?.enabled ?? current.claude.enabled,
|
||||
user_data_dir: claude?.userDataDir?.trim() || current.claude.user_data_dir,
|
||||
user_data_dir: nextClaudeUserDataDir,
|
||||
devtools_port: claude?.devtoolsPort ?? current.claude.devtools_port,
|
||||
},
|
||||
codex: {
|
||||
|
||||
@@ -152,6 +152,49 @@ describe('browser routes', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('treats a blank user-data directory as a reset to the recommended path', async () => {
|
||||
const firstResponse = await fetch(`${baseUrl}/api/browser`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
claude: {
|
||||
enabled: true,
|
||||
userDataDir: '/tmp/ccs-browser-custom',
|
||||
devtoolsPort: 9333,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
expect(firstResponse.status).toBe(200);
|
||||
|
||||
const resetResponse = await fetch(`${baseUrl}/api/browser`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
claude: {
|
||||
userDataDir: ' ',
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
expect(resetResponse.status).toBe(200);
|
||||
const payload = await resetResponse.json();
|
||||
expect(payload.browser.config.claude).toMatchObject({
|
||||
enabled: true,
|
||||
userDataDir: join(tempHome, '.ccs', 'browser', 'chrome-user-data'),
|
||||
devtoolsPort: 9333,
|
||||
});
|
||||
|
||||
const config = loadOrCreateUnifiedConfig();
|
||||
expect(config.browser).toMatchObject({
|
||||
claude: {
|
||||
enabled: true,
|
||||
user_data_dir: join(tempHome, '.ccs', 'browser', 'chrome-user-data'),
|
||||
devtools_port: 9333,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects invalid DevTools ports at the route boundary', async () => {
|
||||
const response = await fetch(`${baseUrl}/api/browser`, {
|
||||
method: 'PUT',
|
||||
|
||||
Reference in New Issue
Block a user