mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-16 14:22:34 +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 {
|
try {
|
||||||
const current = getBrowserConfig();
|
const current = getBrowserConfig();
|
||||||
|
const nextClaudeUserDataDir =
|
||||||
|
claude?.userDataDir === undefined ? current.claude.user_data_dir : claude.userDataDir.trim();
|
||||||
mutateUnifiedConfig((config) => {
|
mutateUnifiedConfig((config) => {
|
||||||
config.browser = {
|
config.browser = {
|
||||||
claude: {
|
claude: {
|
||||||
enabled: claude?.enabled ?? current.claude.enabled,
|
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,
|
devtools_port: claude?.devtoolsPort ?? current.claude.devtools_port,
|
||||||
},
|
},
|
||||||
codex: {
|
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 () => {
|
it('rejects invalid DevTools ports at the route boundary', async () => {
|
||||||
const response = await fetch(`${baseUrl}/api/browser`, {
|
const response = await fetch(`${baseUrl}/api/browser`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
|
|||||||
Reference in New Issue
Block a user