#!/usr/bin/env node
import assert from 'assert';
import fs from 'fs';

const html = fs.readFileSync('./public/index.html', 'utf8');

assert(!html.includes('class="ws-tab-add"'), 'header should not render the standalone + workspace button');
assert(html.includes("div.onclick = () => switchWorkspace(ws.path);"), 'workspace list should switch the current window');
assert(html.includes("await switchWorkspace(picked.path);"), 'desktop folder picker should switch the current window');
assert(html.includes("if (_browseCurrentDir) switchWorkspace(_browseCurrentDir);"), 'directory browser select should switch the current window');
assert(html.includes('if (!currentWorkDir) {\n    resetConversationState();'), 'empty-workspace init should clear old chat state');
assert(html.includes("currentWorkDir = data.workDir || '';"), 'workspace_switched SSE should clear currentWorkDir when closing workspace');
assert(html.includes("if (!currentWorkDir) {\n      tree.innerHTML = '<div style=\"color:var(--text2);font-size:11px;padding:20px 10px;text-align:center;\">Select a project workspace from the top-left</div>';"), 'file tree should keep the empty-workspace placeholder');

console.log('\n── Workspace Selection UI Regression ──');
console.log('PASS test-workspace-selection-ui.js');
