diff --git a/docs/testing.md b/docs/testing.md index b5f9f43..dea7f62 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -2,6 +2,42 @@ The gates a change has to pass, and the drivers that prove the window works. Setup is in the [README](../README.md). +## Backend v0.8.0 compatibility + +The submodule pins `3259f8b`, the upstream `v0.8.0` release. +The bridge uses policy-audited model-list decoding and Bedrock's per-model names and +context windows. Trust maps are rooted in the session project. Resuming a terminal +session preserves its saved side conversations and rewind checkpoints. +The UI does not yet present fetch-host, language-server, or manifest-plan approvals; +those new requests are refused without consuming another pending approval. + +## Current regression checks + +- `npm run build`: bridge and secure-file helper builds, TypeScript, and Electron bundles. +- After building, `node --test scripts/*.test.mjs`: renderer state, models, file access, + memory retention, avatar motion and traits. File tests use the actual secure-file helper. +- `cargo test --all` and `cargo clippy --all-targets --all-features -- -D warnings`: bridge + and secure-file helper gates, including deterministic parent-directory replacement attacks. +- After building, `node scripts/drive-ux-acceptance.mjs`, `node scripts/drive-bot-history.mjs`, + and `node scripts/drive-models.mjs`: isolated Electron acceptance checks with deterministic + provider replies. These cover the current tab layout, search, history, drafts, approvals, + memory, and model selection. Command approvals include the resolved execution plan and + files written by redirections. +- `node scripts/drive-secure-files.mjs`: real preview and memory IPC, symlink rejection, + edit conflicts, history deletion and bot recreation, without model calls. To verify packaging, + build with `node scripts/package.mjs`, then set `SECURE_FILES_APP` to the packaged executable + when running the same driver. Both `bravebot-rpc` and `bravebot-ui-files` must ship in Resources. +- For a submodule update, also run + `cargo test --manifest-path vendor/bravebot/Cargo.toml --target-dir target --all --locked`. + On Apple Silicon with an Intel Rust toolchain, add `--target aarch64-apple-darwin` + and `--config 'target.aarch64-apple-darwin.runner=["/usr/bin/arch","-arm64"]'` + (install the target with `rustup target add aarch64-apple-darwin`). The upstream confinement tests + need native subprocesses: translated binaries can fail with `Failed to open libRosettaRuntime`. + +The session-store and confinement tests need filesystem and subprocess access outside the +Codex sandbox. A missing temporary session record under that sandbox is not a passing test; +rerun with the required access. + The Rust side has eight integration suites under `crates/bravebot-bridge/tests/` — the protocol projections, dispatch, the layering rules the crate docs describe, and the refusal guarantees that the security model rests on. diff --git a/docs/ui-ux-redesign.md b/docs/ui-ux-redesign.md new file mode 100644 index 0000000..822bd7a --- /dev/null +++ b/docs/ui-ux-redesign.md @@ -0,0 +1,103 @@ +# UI and UX implementation audit + +Branch: `codex/ui-ux-redesign` + +The full review is the scope. Runtime checks use the actual Electron application and isolated test projects. +Compilation, interaction assertions, screenshots, and live-agent checks provide +complementary evidence; their boundaries are recorded below. + +## Requirements and evidence + +- [x] 1. Persist per-session drafts and scroll; background sessions; visible run, + approval, completion and failure states; safe explicit stopping. +- [x] 2. Actionable errors with diagnostic details and safe recovery actions. +- [x] 3. Growing composer, secondary toolbar, header export, keyboard hints, + drafting during runs, explicit queue, persistent Stop. +- [x] 4. Conversation-first widths, responsive inspector drawer, focus mode, + softer message colors and retained avatars. +- [x] 5. Overview / Changes / Files inspector; compact empties; persistent + pending decisions; event navigation; accurate trust distinctions. +- [x] 6. Near-bottom follow, new-activity button, approval navigation, + reduced-motion scrolling and retained reading position. +- [x] 7. Approval summaries, readable expandable diffs, visible permission scope, + revocation controls, separate approval and application outcomes. +- [x] 8. Bot overview and conversation history; continue/new actions; bot badges; + titles and status; search; session pin/archive and discoverable menus. +- [x] 9. Wider bot editor; project explanation/duplication; readable/raw memory, + update history, deliberate edit/reset; persistent-memory explanation. +- [x] 10. Copy/wrap code; conversation search; project-wide filename search; + preview/open-in-editor; validated local references; explicit file attachments. +- [x] 11. Typography, contrast, density, hit targets, composer name, status + announcements, modal focus containment/restoration, keyboard verification. +- [x] 12. Welcome actions and recent projects; first-project guidance; backend + readiness/diagnostics; recent models; app-supported capabilities and context limits. + +## Acceptance evidence + +The Electron driver is `scripts/drive-ux-acceptance.mjs`. It launches the production +build with a fresh user-data directory and disposable project. It records 41 +screenshots and fails on assertion failures or renderer exceptions. Screenshots +were opened and visually inspected, including the final dark scrollbar and +memory-reset confirmation refinements. + +| Requirement | Visual evidence (screenshot prefixes) | Functional evidence | +| --- | --- | --- | +| 1. Conversation continuity | 02, 14–16, 40 | Independent drafts across switching and reload; background question remains reachable; Stop invalidates pending question; queue remains paused until Resume; failed first turn remains one sidebar row even with a stale session list. Native restart also retained a draft. | +| 2. Error recovery | 15, 17, 35–36, 38, 40 | Cancellation, rate-limit and authentication states; continuation appends to an existing draft and does not resend actions; setup help and diagnostics open; readiness can be checked again. | +| 3. Composer | 02, 10, 13, 15, 17, 37 | Growing multiline input; draft while busy; queue, Stop and Resume; attachments; header Export; keyboard hints. Queue waits across both the start and completion of automatic memory maintenance. | +| 4. Layout and identity | 02–04, 19, 26–27 | Focus hides sidebars and restores their prior state; reading width stays bounded; 950 px window uses an inspector overlay; comfortable/compact density; light/dark colors and avatars. | +| 5. Inspector | 02, 29–32 | Overview, Changes and Files; compact empties; pending write visible; one normalized path despite a reference-backed tool target; applied state follows the tool outcome. | +| 6. Reading position | 33–34 | Incoming events preserve scroll position while reading; switching restores it; New activity returns to the bottom; reduced-motion preference exercised. | +| 7. Approvals and grants | 05–06, 28–31 | Trusted parent path, untrusted exception and exact command scope; revoke both grant types; expanded numbered diff; waiting → applying → applied distinct from the approval decision. Native backend also applied a reviewed disposable-file update. | +| 8. Bots and sessions | 14, 18–19, 39–41 | Pin, archive and restore; bot conversation history; Continue and New; badges/status; duplicate appears as a separate bot in its chosen project. Search controls inspected. | +| 9. Memory/editor | 20–25, 41 | Real main-process storage: edit → save → readable/raw → explicit reset → revision review → restore → save. Project remains fixed; duplication creates a new bot. Reset confirmation scrolls clear of the sticky footer. | +| 10. Content tools | 07–10, 32 | Conversation search, copy to clipboard, code wrap, local-reference preview, default-app dispatch, attachment selection/removal, filename search. Real file boundary/search/attachment validation covered by regression tests and native file search/preview. | +| 11. Accessibility | 03–08, 20, 23, 27 | Modal Tab wrapping, Escape and launcher-focus restoration; input names; visible focus; density; semantic status/alerts; readable accent text; built-in accent/message foreground contrast tests. | +| 12. Onboarding/models | 01, 11–12, 35–36, 38–39 | Welcome/recent projects; project trust choice; disabled send with missing backend; Check again; model selection, Recent ordering, context windows and only app-supported capability badges. | + +## Verification boundaries + +The deterministic driver replaces provider/bridge replies and native file-picker +answers, including permission-list fixtures and the default-app dispatch endpoint. +It uses the real renderer, preload IPC, experience persistence, bot definitions, +and memory/history file operations. It does not spend tokens with a provider or +alter a user's project. These fixtures verify UI state and interaction behavior; +they do not claim a new live-provider integration run for every screenshot. + +Earlier native tests exercised the actual backend: an unanswered question remained +active in a background conversation; answering it sent the queued follow-up; Stop +woke a pending request without approval; an explicitly resumed queue completed; +and a reviewed untrusted patch changed only the disposable sample file. Native +search found an unopened source path and previewed its contents. The draft survived +an application quit/relaunch. Inconsistent native captures were discarded and the +remaining visual work was completed with the authorized Electron driver. + +## Fixes found during acceptance + +- Cancellation now wakes a waiting confirmer; reused request IDs cannot rewrite + answers or approvals from earlier turns. +- Failed first turns migrate to their durable ID without losing their sidebar row. +- Reference-backed writes and approval paths produce one Changes row. +- Queued work stays paused after Stop/error, but a new explicit task with no old + queue does not inherit a stale pause. Automatic bot memory maintenance reserves + the session until its completion announcement releases the queue. +- Recovery preserves an existing draft and asks to review current project state + before continuing, rather than automatically repeating writes or commands. +- Dialog focus, sticky editor controls, readable memory headings, reset visibility, + primary-button styling, text accent contrast and dark scrollbars were corrected + against screenshots. Empty archives have a direct, useful explanation. + +## Checks and reproduction + +- `npm run build`: passed (TypeScript, bridge, main, preload and renderer). +- `node --test scripts/ux-state.test.mjs scripts/bot-model.test.mjs`: 14 passed. +- `cargo test -p bravebot-bridge`: 87 passed during this implementation. +- `cargo clippy --all-targets --all-features -- -D warnings`: passed. +- `node scripts/drive-ux-acceptance.mjs`: full acceptance run passed. +- `git diff --check`: passed. + +Build before running the driver. GUI execution needs permission outside the +sandbox on macOS. By default screenshots go to `/private/tmp/bravebot-ux-final`; +set `UX_OUTPUT` to choose a different evidence directory. Provider credentials +remain a deployment/environment requirement, and the setup UI describes that +boundary without exposing credentials. diff --git a/scripts/drive-bot-history.mjs b/scripts/drive-bot-history.mjs index cf7cbf8..ee28d50 100644 --- a/scripts/drive-bot-history.mjs +++ b/scripts/drive-bot-history.mjs @@ -77,6 +77,22 @@ try { await overview();await page.locator('.bot-conversations button').filter({hasText:'Review the sample project'}).click(); await page.getByText('Review the project and show a code example.',{exact:true}).waitFor(); await snap('03-open-archived-conversation'); + await page.getByRole('tab',{name:'Files',exact:true}).click(); + assert.equal(await page.locator('#panel-files .panel-head').count(),0); + assert.equal(await page.getByRole('searchbox',{name:'Search project files by name'}).count(),0); + const panel=await page.locator('.context').boundingBox(); + const tree=await page.locator('.tree-body').boundingBox(); + assert.ok(Math.abs(panel.y+panel.height-tree.y-tree.height-14)<2,'File list fills panel height'); + await snap('03-files-full-height'); + await page.getByRole('button',{name:'Search files',exact:true}).click(); + const fileSearch=page.getByRole('searchbox',{name:'Search project files by name'}); + await fileSearch.fill('sample'); + await page.locator('.file-search-results button').filter({hasText:'src/nested/sample.txt'}).waitFor(); + await snap('03-files-search'); + await fileSearch.press('Escape'); + assert.equal(await fileSearch.count(),0); + assert.equal(await page.getByRole('button',{name:'Search files',exact:true}).evaluate(el=>el===document.activeElement),true); + await overview();await page.getByRole('button',{name:'New conversation',exact:true}).click(); await page.getByRole('button',{name:"Don't trust",exact:true}).click();await page.getByRole('dialog').waitFor({state:'hidden'}); await page.getByRole('textbox',{name:'Message the agent'}).fill('Keep this newer conversation draft'); diff --git a/scripts/drive-models.mjs b/scripts/drive-models.mjs index be4d141..2c6a543 100644 --- a/scripts/drive-models.mjs +++ b/scripts/drive-models.mjs @@ -66,7 +66,7 @@ try { await trigger.click() await page.getByRole('option', { name: /Claude Sonnet/ }).waitFor() - assert.deepEqual(await page.getByRole('option', { name: /Claude Sonnet/ }).locator('.model-capability').allTextContents(), ['Text', 'Vision', 'Tools', 'Reasoning']) + assert.deepEqual(await page.getByRole('option', { name: /Claude Sonnet/ }).locator('.model-capability').allTextContents(), ['Text', 'Tools']) assert.equal(await page.getByRole('option', { name: /Brave model/ }).locator('.model-capability').count(), 0) const search = page.getByRole('combobox', { name: 'Search models' }) await search.fill('VISION') diff --git a/scripts/drive-ux-acceptance.mjs b/scripts/drive-ux-acceptance.mjs new file mode 100644 index 0000000..13cac9e --- /dev/null +++ b/scripts/drive-ux-acceptance.mjs @@ -0,0 +1,144 @@ +// Real Electron renderer acceptance with isolated persistence and deterministic bridge events. +// No provider requests or changes to the user's projects. Screenshots accompany assertions. +import assert from 'node:assert/strict' +import { mkdtempSync, mkdirSync, writeFileSync, existsSync } from 'node:fs' +import { join } from 'node:path' +import { _electron as electron } from 'playwright-core' +const output = process.env.UX_OUTPUT || '/private/tmp/bravebot-ux-final' +mkdirSync(output, { recursive: true }) +const profile = mkdtempSync('/private/tmp/bravebot-ux-profile-') +const directory = mkdtempSync('/private/tmp/bravebot-ux-project-') +mkdirSync(directory+'-copy') +const idA = '11111111-1111-4111-8111-111111111111', idB = '22222222-2222-4222-8222-222222222222' +writeFileSync(join(profile, 'bravebot-ui.json'), JSON.stringify({ bots: [{slug:'review-bot', name:'Review Bot', purpose:'Review a disposable project and remember preferences.', avatar:'review-bot', model:null, directory, session:idA, conversations:[idA,idB], archived:0, remembered:0, quiet:0, retired:0, created:1}], recents:[directory] })) +mkdirSync(join(directory,'.bravebot-ui/bots'), {recursive:true}) +writeFileSync(join(directory,'.bravebot-ui/bots/review-bot.md'), '# Preferences\n\n- Keep reviews concise.\n') +const app = await electron.launch({args:['.',`--user-data-dir=${profile}`],cwd:process.cwd(),timeout:40000}) +let page +const originalClipboard = await app.evaluate(({clipboard})=>clipboard.readText()) +try { + page = await app.firstWindow(); page.setDefaultTimeout(7000) + const errors=[]; page.on('pageerror',e=>{errors.push(e.message);console.error('RENDERER',e.message)}) + await app.evaluate(({ipcMain,BrowserWindow}, {directory,idA,idB})=>{ + const rows=[{id:idA,title:'Review the sample project'},{id:idB,title:'Plan the next iteration'}].map(r=>({...r,directory,project:'sample-project',branch:'main',updated:Date.now(),bytes:20})) + const emit=(event,data,session='s-'+idA)=>BrowserWindow.getAllWindows()[0].webContents.send('bravebot:event',{event,data,session}) + globalThis.ux={emit,sent:[],configured:true,choose:directory,grants:{paths:[{path:'',integrity:'trusted'},{path:'private',integrity:'untrusted'}],commands:[{program:'/usr/bin/git',args:['status'],display:'git status'}]}} + const replace=(name,fn)=>{ipcMain.removeHandler(name);ipcMain.handle(name,fn)} + replace('bravebot:choose-directory',()=>globalThis.ux.choose) + replace('bravebot:request',async(_,method,p={})=>{ + const ux=globalThis.ux + if(method==='agent.info') return {ok:{configured:ux.configured,build:'acceptance fixture',version:'1'}} + if(method==='doctor') return {ok:{found:true,text:'Backend not configured. Install a configured build or rebuild with the approved environment.'}} + if(method==='session.list') return {ok:{sessions:rows}} + if(method==='models.list') return {ok:{defaultModel:'sample/fast',warnings:[],models:[{id:'sample/fast',name:'Fast model',provider:'Sample',premium:false,contextWindow:200000,capabilities:['text','tools','vision']},{id:'sample/deep',name:'Deep model',provider:'Sample',premium:false,contextWindow:100000,capabilities:['text','tools']}]}} + if(method==='session.new') return {ok:{session:'s-new',directory,branch:'main',model:'sample/fast'}} + if(method==='session.open') return {ok:{session:'s-'+p.id,model:'sample/fast',record:{...rows.find(r=>r.id===p.id),started:1,turns:1,tokens:100,build:'fixture'},said:p.id===idA?[{kind:'user',text:'Review the project and show a code example.'},{kind:'assistant',text:'The project is ready for review.\n\n```js\nconst message = "A long example line for testing wrapping and copying without losing content.";\nconsole.log(message);\n```\n\nSee [sample.txt](src/nested/sample.txt).'}]:[],todos:{},context:'',trust:{known:true,rules:[]},archived:0,branchNote:null,buildNote:null}} + if(method==='turn.send'){ux.sent.push(p);emit('turn.started',{turn:ux.sent.length},p.session);return {ok:{turn:ux.sent.length}}} + if(method==='turn.cancel'){emit('turn.error',{kind:'cancelled',message:'Cancelled by user',turn:1,id:p.session==='s-new'?'33333333-3333-4333-8333-333333333333':p.session.slice(2)},p.session);return {ok:{}}} + if(method==='permissions.list') return {ok:ux.grants} + if(method==='permissions.revoke'){if(p.kind==='path')ux.grants.paths=ux.grants.paths.filter(g=>g.path!==p.path);else ux.grants.commands=[];return {ok:ux.grants}} + return {ok:{}} + }) + replace('bravebot:bots:send',(_,p)=>{globalThis.ux.sent.push(p);emit('turn.started',{turn:globalThis.ux.sent.length},p.session);return {ok:{turn:globalThis.ux.sent.length}}}) + replace('bravebot:files:list',()=>({path:'',rows:[],truncated:false})) + replace('bravebot:files:search',()=>({paths:['src/nested/sample.txt'],incomplete:false})) + replace('bravebot:files:preview',(_,session,path)=>({path,text:'Alpha\nDelta\nGamma\n',truncated:false})) + replace('bravebot:files:open',()=>{globalThis.ux.opened=true;return {status:'opened'}}) + replace('bravebot:files:choose-attachments',()=>[{id:'fixture-attachment',path:'src/nested/sample.txt',bytes:18}]) + },{directory,idA,idB}) + const snap=async name=>{if(/^2[1245]-memory/.test(name)) await page.locator('.memory-actions').scrollIntoViewIfNeeded();await page.waitForTimeout(400);await page.screenshot({path:join(output,name+'.png'),scale:'css'});console.log('VISUAL',name)} + const emit=async(event,data,session='s-'+idA)=>app.evaluate((_,v)=>globalThis.ux.emit(v.event,v.data,v.session),{event,data,session}) + const done=async(session='s-'+idA,reply='Review complete.')=>emit('turn.done',{id:session.slice(2),turn:1,reply,model:'sample/fast',steps:1,clean:true,tokens:10,outputTokens:10,notices:[],trust:{rules:[]},archived:0},session) + await page.reload();await page.getByRole('button',{name:'Open project',exact:true}).waitFor();await snap('01-welcome') + // Playwright clicks bypass native window dragging; assert the native hit-test exclusion too. + for (const name of ['Conversations', 'Archived']) assert.equal(await page.getByRole('button', {name, exact:true}).evaluate(e => getComputedStyle(e).getPropertyValue('-webkit-app-region')), 'no-drag', `${name} must receive native mouse clicks inside the draggable header`) + await page.locator('.session').filter({hasText:'Review the sample project'}).click() + const composer=page.getByRole('textbox',{name:'Message the agent'}) + await composer.fill('Draft retained across conversations.');await snap('02-conversation') + await page.locator('.session').filter({hasText:'Plan the next iteration'}).click();await composer.fill('Independent draft.') + await page.locator('.session').filter({hasText:'Review the sample project'}).click();assert.equal(await composer.inputValue(),'Draft retained across conversations.') + await page.getByRole('button',{name:'Focus',exact:true}).click();await snap('03-focus');await page.getByRole('button',{name:'Exit focus'}).click() + await page.getByRole('button',{name:'Compact view',exact:true}).click();await snap('04-compact');await page.getByRole('button',{name:'Comfortable view',exact:true}).click() + await page.getByRole('button',{name:'Permissions',exact:true}).click();await page.getByRole('button',{name:'Revoke',exact:true}).first().waitFor();await snap('05-permissions') + await page.getByRole('button',{name:'Revoke',exact:true}).first().click();await page.getByText('No trusted path grants.',{exact:true}).waitFor() + await page.getByRole('button',{name:'Revoke',exact:true}).click();await page.getByText('No remembered command grants.',{exact:true}).waitFor();await snap('06-revoked') + await page.getByRole('button',{name:'Done',exact:true}).focus();await page.keyboard.press('Tab');assert.equal(await page.getByRole('button',{name:'Refresh',exact:true}).evaluate(e=>e===document.activeElement),true) + await page.keyboard.press('Escape');assert.equal(await page.getByRole('button',{name:'Permissions',exact:true}).evaluate(e=>e===document.activeElement),true) + await page.getByRole('button',{name:'Find',exact:true}).click();await page.getByRole('searchbox',{name:'Find in conversation'}).fill('example');await snap('07-search');await page.getByRole('button',{name:'Close search'}).click() + await page.getByRole('button',{name:'Copy code',exact:true}).click();await page.getByRole('button',{name:'Copied',exact:true}).waitFor();assert.match(await app.evaluate(({clipboard})=>clipboard.readText()),/console.log\(message\)/);await page.getByRole('button',{name:'Wrap',exact:true}).click();await snap('08-code-wrap') + await page.getByRole('button',{name:'sample.txt',exact:true}).click();await page.getByRole('dialog').waitFor();await snap('09-preview');await page.getByRole('button',{name:'Open in default app'}).click();assert.equal(await app.evaluate(()=>globalThis.ux.opened),true);await page.getByRole('button',{name:'Done',exact:true}).click() + await page.getByRole('button',{name:'Attach files'}).click();await page.locator('.attachment-chips').waitFor();await snap('10-attachment');await page.getByRole('button',{name:'Remove attachment src/nested/sample.txt'}).click() + await page.locator('.model-trigger').click();await page.getByRole('option',{name:/Deep model/}).waitFor();await snap('11-models');await page.getByRole('option',{name:/Deep model/}).click();await page.locator('.model-trigger').click();await snap('12-recent-model');await page.keyboard.press('Escape') + await composer.fill('Start review');await page.getByRole('button',{name:'Send',exact:true}).click() + await emit('ask.request',{request:1,prompts:[{header:'Color',question:'Which color should the sample use?',rows:[{index:0,label:'Blue',detail:'A cool accent'},{index:1,label:'Green',detail:'A natural accent'}],multiple:false,key:'color'}]}) + await composer.fill('Follow up after this review');await page.getByRole('button',{name:'Queue message',exact:true}).click();await snap('13-question-queue') + await page.locator('.session').filter({hasText:'Plan the next iteration'}).click();await snap('14-background') + await page.locator('.session').filter({hasText:'Review the sample project'}).click();await page.getByRole('button',{name:'Stop',exact:true}).click();await page.getByText('Task stopped',{exact:true}).waitFor();await snap('15-stopped-queue') + assert.equal((await app.evaluate(()=>globalThis.ux.sent)).length,1) + await page.getByRole('button',{name:'Resume queue',exact:true}).click();await page.waitForFunction(()=>document.querySelector('.stop')) + assert.equal((await app.evaluate(()=>globalThis.ux.sent)).length,2);await done();await snap('16-resumed') + await composer.fill('Keep this draft');await emit('turn.error',{kind:'chat',message:'429 rate limit exceeded; retry later',turn:2,id:idA});await page.getByText('The provider is busy',{exact:true}).waitFor();await page.getByRole('button',{name:'Draft continuation'}).last().click();assert.match(await composer.inputValue(),/^Keep this draft/);await snap('17-recovery') + await page.getByRole('button',{name:'Actions for Review the sample project'}).click();await page.getByRole('menuitem',{name:'Pin conversation'}).click();await page.getByLabel('Pinned',{exact:true}).waitFor() + await page.getByRole('button',{name:'Actions for Review the sample project'}).click();await page.getByRole('menuitem',{name:'Archive conversation'}).click();await page.getByRole('button',{name:'Archived',exact:true}).click();await snap('18-archived') + await page.getByRole('button',{name:'Actions for Review the sample project'}).click();await page.getByRole('menuitem',{name:'Restore conversation'}).click();await page.getByText('No archived conversations.',{exact:true}).waitFor();await page.getByRole('button',{name:'Conversations',exact:true}).click() + await composer.fill('Review one change');await page.getByRole('button',{name:'Send',exact:true}).click() + const changes=[{kind:'kept',text:'Alpha'},{kind:'removed',text:'Beta'},{kind:'added',text:'Delta'},{kind:'kept',text:'Gamma'}] + const activity={verb:'Update',target:'ref:1(U,pub):src/nested/sample.txt',note:null,failed:false,untrusted:true,changes:[]} + await emit('tool.started',activity) + await emit('confirm.request',{request:2,path:'src/nested/sample.txt',intent:'update',untrusted:true,existing:true,added:1,removed:1,exact:true,changes}) + await page.getByRole('button',{name:'Expand diff'}).click();await snap('28-expanded-diff');await page.getByRole('button',{name:'Done',exact:true}).click() + await page.getByRole('tab',{name:'Overview',exact:true}).click();await snap('29-waiting-write') + await page.getByRole('button',{name:'Apply this change',exact:true}).click();await page.locator('.files .applying').waitFor();await snap('30-approved-write') + await emit('tool.finished',{...activity,note:'Updated sample.txt',changes});await page.locator('.files .applied').waitFor();assert.equal(await page.getByRole('tab',{name:'Overview',exact:true}).count(),1);await snap('31-applied-write');await done() + const executionPlan='/usr/bin/printf hello > /tmp/result.txt && /usr/bin/true'; + await emit('run.request',{request:3,directory,stages:[{program:'printf',resolved:'/usr/bin/printf',args:['hello'],display:'printf hello > /tmp/result.txt'},{program:'true',resolved:'/usr/bin/true',args:[],display:'true'}],plan:executionPlan,writes:['/tmp/result.txt'],releasesPrivate:false,vouches:[],summary:'run two steps'}); + await page.getByText(executionPlan,{exact:true}).waitFor(); + await page.getByText('Files created or modified:',{exact:true}).waitFor(); + await page.locator('.confirm.run').scrollIntoViewIfNeeded(); + await snap('42-command-plan'); + await page.getByRole('button',{name:'Don’t run',exact:true}).click(); + await page.getByText('You refused this command',{exact:true}).waitFor(); + await page.getByRole('tab',{name:'Files',exact:true}).click();await page.getByRole('button',{name:'Search files',exact:true}).click();await page.getByRole('searchbox',{name:/Find files|Search/}).fill('sample');await page.getByRole('button',{name:'src/nested/sample.txt',exact:true}).waitFor();await snap('32-file-search') + await page.getByRole('tab',{name:'Overview',exact:true}).click() + for(let n=0;n<30;n++)await emit('narration',{text:`Review observation ${n}: verify layout and retain reading position.`}) + await page.locator('.entries').evaluate(e=>e.scrollTop=150);await page.waitForTimeout(250) + const reading=await page.locator('.entries').evaluate(e=>e.scrollTop) + await emit('narration',{text:'New work arrived while reading older content.'});await page.getByRole('button',{name:'New activity ↓',exact:true}).waitFor();assert.equal(await page.locator('.entries').evaluate(e=>e.scrollTop),reading);await snap('33-new-activity') + await page.locator('.session').filter({hasText:'Plan the next iteration'}).click();await page.locator('.session').filter({hasText:'Review the sample project'}).click();assert.equal(await page.locator('.entries').evaluate(e=>e.scrollTop),reading) + await emit('narration',{text:'Another observation arrived.'});await page.emulateMedia({reducedMotion:'reduce'});await page.getByRole('button',{name:'New activity ↓',exact:true}).click();await snap('34-follow-latest') + await composer.fill('Finish a long bot turn');await page.getByRole('button',{name:'Send',exact:true}).click();await composer.fill('Wait for memory maintenance');await page.getByRole('button',{name:'Queue message',exact:true}).click() + const beforeMaintenance=(await app.evaluate(()=>globalThis.ux.sent)).length + await emit('turn.done',{id:idA,turn:4,reply:'Conversation compacted; updating memory.',model:'sample/deep',steps:1,clean:true,tokens:10,outputTokens:10,notices:[],trust:{rules:[]},archived:1,consolidating:true}) + await page.waitForTimeout(250);assert.equal((await app.evaluate(()=>globalThis.ux.sent)).length,beforeMaintenance) + await app.evaluate(({BrowserWindow},session)=>BrowserWindow.getAllWindows()[0].webContents.send('bravebot:bots:consolidating',{session,slug:'review-bot'}),'s-'+idA);await snap('37-memory-maintenance-queue') + await emit('turn.done',{id:idA,turn:5,reply:'Memory updated.',model:'sample/deep',steps:1,clean:true,tokens:10,outputTokens:10,notices:[],trust:{rules:[]},archived:1,consolidating:true});await page.waitForTimeout(250);assert.equal((await app.evaluate(()=>globalThis.ux.sent)).length,beforeMaintenance) + await app.evaluate(({BrowserWindow},session)=>BrowserWindow.getAllWindows()[0].webContents.send('bravebot:bots:consolidated',{session,slug:'review-bot',delivered:true}),'s-'+idA) + await page.waitForFunction(()=>document.querySelector('.queued-messages')===null);assert.equal((await app.evaluate(()=>globalThis.ux.sent)).length,beforeMaintenance+1);await done() + await page.getByRole('button',{name:'Bots',exact:true}).click();await page.locator('.bot').filter({hasText:'Review Bot'}).click();await snap('19-bot-overview') + await page.getByRole('button',{name:'Edit bot and memory'}).click();await page.getByRole('button',{name:'Edit memory',exact:true}).waitFor();await snap('20-bot-editor') + await page.getByRole('button',{name:'Edit memory',exact:true}).click();await page.getByRole('textbox',{name:'Edit persistent memory'}).fill('# Saved preference\n\n- Use a blue accent.');await page.getByRole('button',{name:'Save memory'}).click();await page.locator('.memory-readable').getByText('Saved preference',{exact:true}).waitFor();await snap('21-memory-read') + await page.getByRole('button',{name:'Raw',exact:true}).click();await snap('22-memory-raw');await page.getByRole('button',{name:'Reset memory…',exact:true}).click();await snap('23-memory-reset');await page.getByRole('button',{name:'Reset saved memory'}).click() + await page.getByRole('button',{name:'History',exact:true}).click();await page.locator('.memory-history details').filter({hasText:'Saved preference'}).locator('summary').first().click();await snap('24-memory-history');await page.locator('.memory-history details').filter({hasText:'Saved preference'}).getByRole('button',{name:'Review for restore'}).first().click();await page.getByRole('button',{name:'Save memory'}).click();await page.getByRole('button',{name:'Read',exact:true}).click();await page.locator('.memory-readable').getByText('Saved preference',{exact:true}).waitFor();await snap('25-memory-restored');await page.keyboard.press('Escape') + await app.evaluate(({BrowserWindow})=>BrowserWindow.getAllWindows()[0].setSize(950,780));await page.getByRole('button',{name:'Context panel',exact:true}).click();await snap('26-narrow-drawer');await page.getByRole('button',{name:'Close context panel'}).click() + await page.emulateMedia({colorScheme:'dark',reducedMotion:'reduce'});await page.waitForFunction(()=>matchMedia('(prefers-color-scheme: dark)').matches);await snap('27-dark');await page.emulateMedia({colorScheme:'light',reducedMotion:'reduce'}) + await app.evaluate(({BrowserWindow,nativeTheme})=>{BrowserWindow.getAllWindows()[0].setSize(1280,820);nativeTheme.themeSource='light';globalThis.ux.configured=false}) + await page.reload();await page.getByRole('button',{name:'Sessions',exact:true}).click();await page.locator('.session').filter({hasText:'Plan the next iteration'}).click();await page.getByText('Backend setup needed',{exact:true}).waitFor();assert.equal(await composer.inputValue(),'Independent draft.');await snap('35-backend-not-ready');await page.getByRole('button',{name:'Diagnostics',exact:true}).click();await snap('38-diagnostics');await page.keyboard.press('Escape') + await page.getByRole('button',{name:'Setup help'}).click();await snap('36-setup-help');await page.keyboard.press('Escape') + await app.evaluate(()=>globalThis.ux.configured=true);await page.getByRole('button',{name:'Check again'}).click();await page.getByText('Backend setup needed',{exact:true}).waitFor({state:'hidden'}) + await page.getByRole('button',{name:'Bots',exact:true}).click();await page.locator('.bot').filter({hasText:'Review Bot'}).click();await page.locator('.bot-conversations button').filter({hasText:'Review the sample project'}).click();await page.locator('.transcript-head').count() + await page.locator('.bot').filter({hasText:'Review Bot'}).click();await page.getByRole('button',{name:'New conversation',exact:true}).click();await page.getByRole('button',{name:"Don't trust",exact:true}).click();await snap('39-new-bot-conversation') + await composer.fill('First turn failure fixture');await page.getByRole('button',{name:'Send',exact:true}).click();await emit('turn.error',{kind:'chat',message:'401 credentials rejected',turn:1,id:'33333333-3333-4333-8333-333333333333'},'s-new');await page.getByText('The provider could not authenticate this request',{exact:true}).waitFor() + await page.getByRole('button',{name:'Sessions',exact:true}).click();assert.equal(await page.locator('.session').filter({hasText:'First turn failure fixture'}).count(),1);await snap('40-first-turn-failure') + await page.getByRole('button',{name:'Bots',exact:true}).click();await page.locator('.bot').filter({hasText:'Review Bot'}).click();await page.getByRole('button',{name:'Edit bot and memory'}).click();await app.evaluate(()=>globalThis.ux.choose+='-copy');await page.getByRole('button',{name:'Duplicate into another project'}).click();await page.getByRole('dialog').waitFor({state:'hidden'});await page.locator('.bot').filter({hasText:'Review Bot copy'}).click();await snap('41-duplicated-bot');assert.match(await page.getByRole('dialog').innerText(),/-copy/);await page.keyboard.press('Escape') + const localHistory = await page.evaluate(() => window.bravebot.readMemoryHistory('review-bot')); + assert.ok(localHistory.length > 0, 'fixture has local memory revisions before removal'); + await page.evaluate(() => window.bravebot.removeBot('review-bot')); + const memoryFiles = ['memory-history.json', 'ground.md'].map(name => existsSync(join(profile, 'bots', 'review-bot', name))); + assert.deepEqual(memoryFiles, [false, false]); + const replacementBot = await page.evaluate(async directory => window.bravebot.writeBot({name:'Review Bot',purpose:'New identity',directory}), directory); + assert.equal(replacementBot.slug, 'review-bot'); + assert.deepEqual(await page.evaluate(() => window.bravebot.readMemoryHistory('review-bot')), []); + assert.deepEqual(errors,[]) + console.log('PASS UX acceptance', {output,profile,directory}) +} catch(error) {if(page){await page.screenshot({path:join(output,'failure.png')});console.error((await page.locator('body').innerText()).slice(-7000))}throw error} +finally {await app.evaluate(({clipboard},text)=>clipboard.writeText(text),originalClipboard);await app.close()} diff --git a/scripts/ux-state.test.mjs b/scripts/ux-state.test.mjs index 991136a..63a524d 100644 --- a/scripts/ux-state.test.mjs +++ b/scripts/ux-state.test.mjs @@ -81,6 +81,18 @@ test('memory edits use compare-and-replace and preserve recoverable history', () } finally { rmSync(directory, { recursive: true, force: true }) } }) +test('write status follows execution outcome even when its tool row precedes the approval', () => { + const { written } = load('src/renderer/components/Context.tsx') + const approval = { kind: 'confirm', id: 'approval', request: { path: 'a.ts' }, decision: 'approve' } + const tool = (note, failed = false) => ({ kind: 'tool', id: 'tool', activity: { verb: 'Write', target: 'a.ts', note, failed, changes: [] } }) + assert.equal(written([approval])[0].state, 'approved') + assert.equal(written([tool(null), approval])[0].state, 'applying') + assert.equal(written([tool('done'), approval])[0].state, 'applied') + assert.equal(written([tool('disk full', true), approval])[0].state, 'failed') + assert.equal(written([tool('done'), approval, tool(null)])[0].state, 'applying') +}) + + test('attachment grants are per session and revalidate changed files at send', async () => { const root = mkdtempSync(join(tmpdir(), 'bravebot-ux-attachment-')) const selected = join(root, 'notes.txt') @@ -138,6 +150,30 @@ test('request IDs reused in later turns never rewrite prior answers or approvals }) +test('built-in accent and message foregrounds meet normal-text contrast', () => { + const { BUILTINS, roleVariables } = load('src/shared/theme.ts') + const luminance = (hex) => { + const linear = hex.slice(1).match(/../g).map((channel) => parseInt(channel, 16) / 255).map((c) => c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4) + return .2126 * linear[0] + .7152 * linear[1] + .0722 * linear[2] + } + for (const theme of BUILTINS) for (const dark of [false, true]) { + const vars = roleVariables(theme, dark) + for (const role of ['note', 'primary']) { + const a = luminance(vars[`--role-${role}`]), b = luminance(vars[`--role-${role}-ink`]) + assert.ok((Math.max(a, b) + .05) / (Math.min(a, b) + .05) >= 4.5, `${theme.name} ${role}`) + } + } +}) + + +test('reference-backed writes and approval paths share one execution outcome', () => { + const { written } = load('src/renderer/components/Context.tsx') + const tool = { kind: 'tool', id: 'tool', activity: { verb: 'Write', target: 'ref:3(U,priv):src/sample.txt', note: 'done', failed: false, changes: [] } } + const approval = { kind: 'confirm', id: 'approval', request: { path: 'src/sample.txt' }, decision: 'approve' } + assert.deepEqual(written([tool, approval]), [{ target: 'src/sample.txt', state: 'applied' }]) + assert.equal(written([{ ...approval, decision: null, interrupted: true }])[0].state, 'cancelled') +}) + test('bot history includes every saved, associated and draft conversation without mixing bots or projects', () => { const { botHistory } = load('src/shared/bot-history.ts') const { parseExperience, conversationKey } = load('src/shared/experience.ts') diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 08071e9..2cb82bf 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -1226,7 +1226,7 @@ export function App(): React.JSX.Element { onReset={reset} onNudge={nudge} /> - + toggle('right')} /> {[...openedLives.current.values()].some((item) => item.handle !== live?.handle && item.running) && (
{[...openedLives.current.values()].filter((item) => item.handle !== live?.handle && item.running).map((item) => ( diff --git a/src/renderer/columns.ts b/src/renderer/columns.ts index c0bdd29..27a516d 100644 --- a/src/renderer/columns.ts +++ b/src/renderer/columns.ts @@ -9,8 +9,8 @@ /** What each side column may be, and where it starts. */ export const SIDES = { - left: { min: 200, max: 460, initial: 280 }, - right: { min: 240, max: 520, initial: 320 }, + left: { min: 200, max: 400, initial: 250 }, + right: { min: 240, max: 420, initial: 300 }, } as const export type Side = keyof typeof SIDES @@ -21,7 +21,7 @@ export type Side = keyof typeof SIDES * The transcript is the reason the window is open; the other two columns are apparatus. * So when something has to give, it is never this. */ -const CENTER_MIN = 380 +const CENTER_MIN = 480 /** * The two 1px dividers, which are part of the window even though nobody sizes them. @@ -99,6 +99,9 @@ const clamp = (value: number, min: number, max: number): number => * clamped at the moment it comes back, which is the moment it starts to mean something. */ export function fit(widths: Widths, available: number, collapsed: Record): Widths { + // On small windows the inspector overlays the conversation and consumes no grid width. + if (available <= 1120) collapsed = { ...collapsed, right: true } + let left = collapsed.left ? widths.left : clamp(widths.left, SIDES.left.min, SIDES.left.max) let right = collapsed.right ? widths.right : clamp(widths.right, SIDES.right.min, SIDES.right.max) diff --git a/src/renderer/components/Context.tsx b/src/renderer/components/Context.tsx index 4e6f288..d98e044 100644 --- a/src/renderer/components/Context.tsx +++ b/src/renderer/components/Context.tsx @@ -1,8 +1,7 @@ -import { useEffect, useRef, useState } from 'react' +import { useState } from 'react' import { Fold } from './Fold' import { FileTree } from './FileTree' -import { PanelIcon } from './PanelIcon' -import { PANEL_NAMES, type PanelName } from '../../shared/state' +import { type PanelName } from '../../shared/state' import type { Activity, Phase, Shown, TodoRow } from '../../shared/protocol' import type { Entry } from '../transcript' @@ -27,7 +26,7 @@ interface Live { * name in the preferences file is a panel at all — so the column, the bar and the file on disk are * all talking about the same five things. */ -const PANELS = PANEL_NAMES + /** * The right-hand column: what this session has touched, and the folder it is touching it in. @@ -37,44 +36,16 @@ const PANELS = PANEL_NAMES * the disk, because the question it answers — what else is in there, and what does this file look * like in a real editor — is not one the transcript can be asked. */ -export function Context({ live }: { live: Live | null }): React.JSX.Element { - // Which panels are *off*. Held here rather than in each panel, because the row of buttons at the - // top has to be able to say so — and declared above the empty case, so the hooks run on every - // render the way the rules require. - // - // The off ones rather than the on ones, all the way down to the file: a panel added to this - // window in a later build then arrives visible under a preference written before it existed, - // which is the column's own default. `shared/state.ts` says the same thing about the shape. - const [off, setOff] = useState>(() => new Set()) - - // Read once, and written on every change after the read has landed — the arrangement the - // session list keeps for its own preference, and the `ready` guard is why: without it the empty - // initial state races the read and writes "every panel is on" over what somebody chose. - const ready = useRef(false) - useEffect(() => { - void window.bravebot - .readPanels() - .then((panels) => setOff(new Set(panels.off))) - .catch(() => undefined) - .finally(() => (ready.current = true)) - }, []) - useEffect(() => { - if (!ready.current) return - try { - window.bravebot.writePanels({ off: [...off] }) - } catch { - // The column is still arranged the way it was asked to be, for this session at least. - } - }, [off]) - - const toggle = (panel: PanelName): void => - setOff((was) => { - const next = new Set(was) - if (!next.delete(panel)) next.add(panel) - return next - }) +export function Context({ live, onClose }: { live: Live | null; onClose: () => void }): React.JSX.Element { + const [tab, setTab] = useState<'overview' | 'files'>('overview') + const off = new Set(tab === 'overview' ? ['files'] : ['plan', 'read', 'writes', 'confined']) + const reveal = (path: string) => { + const entry = [...(live?.entries ?? [])].reverse().find((entry) => + entry.kind === 'tool' ? fileTarget(entry.activity.target) === path : entry.kind === 'confirm' ? entry.request.path === path : false) + if (entry) document.dispatchEvent(new CustomEvent('bravebot:reveal-entry', { detail: entry.id })) + } - if (!live) return
- setQuery(event.target.value)} - onKeyDown={(event) => event.key === 'Escape' && setQuery('')} - /> - - {/* Said whenever a query is running, because the tree is listed a folder at a time and a - filter can only search what has been read. Somebody typing a filename they know is in - the project and getting nothing has been told something false unless this line is - here. */} - {terms.length > 0 && ( -

Only folders you have opened have been read.

- )} + {searchOpen &&
+ setQuery(event.target.value)} + onKeyDown={event => { if (event.key === 'Escape') { event.stopPropagation(); closeSearch() } }} /> + +
} {problem &&

{problem}

} @@ -182,7 +191,13 @@ export function FileTree({ with forty things in its root would otherwise push the column's own scrollbar down and take the header with it. */}
- {rootListing === undefined ? ( + {terms.length > 0 ?
+ {searching &&

Searching project…

} + {!searching && results?.paths.length === 0 &&

No matching files.

} + {results?.paths.map((path) => )} +

Search skips .git, node_modules, target and dist. Symbolic-link directories are not followed.

+ {results?.incomplete &&

Results are limited or some folders could not be read. Narrow the search.

} +
: rootListing === undefined ? (

{unreadable.has('') ? 'That folder cannot be read.' : 'Reading…'}

) : ( )}
+ {previewPath && setPreviewPath(null)} />} ) } diff --git a/src/renderer/components/Gutter.tsx b/src/renderer/components/Gutter.tsx index d78bd5d..62779d9 100644 --- a/src/renderer/components/Gutter.tsx +++ b/src/renderer/components/Gutter.tsx @@ -43,7 +43,7 @@ export function useColumns(): { nudge: (side: Side, by: number) => void toggle: (side: Side) => void } { - const [layout, setLayout] = useState(INITIAL_LAYOUT) + const [layout, setLayout] = useState(() => ({ ...INITIAL_LAYOUT, collapsed: { left: false, right: window.innerWidth <= 1120 } })) const [dragging, setDragging] = useState(null) // Armed by a fold and by nothing else. A drag, an arrow key and a window resize all // change the same widths and must all land instantly; only a fold is a movement anyone @@ -61,7 +61,7 @@ export function useColumns(): { if (live && stored) { setLayout({ widths: fit(stored.widths, window.innerWidth, stored.collapsed), - collapsed: stored.collapsed, + collapsed: window.innerWidth <= 1120 ? { ...stored.collapsed, right: true } : stored.collapsed, }) } loaded.current = true @@ -76,8 +76,15 @@ export function useColumns(): { const from = useRef<{ x: number; widths: Widths } | null>(null) useEffect(() => { - const onResize = (): void => - setLayout((old) => ({ ...old, widths: fit(old.widths, window.innerWidth, old.collapsed) })) + let narrow = window.innerWidth <= 1120 + const onResize = (): void => { + const nextNarrow = window.innerWidth <= 1120 + setLayout((old) => { + const collapsed = nextNarrow && !narrow ? { ...old.collapsed, right: true } : old.collapsed + return { ...old, collapsed, widths: fit(old.widths, window.innerWidth, collapsed) } + }) + narrow = nextNarrow + } window.addEventListener('resize', onResize) return () => window.removeEventListener('resize', onResize) }, []) @@ -209,7 +216,7 @@ export function Gutter({ return (
{children} }, a({ href, children }) { const url = safeUrl(href) + const local = href?.replace(/^\.\//, '').replace(/(?::\d+|#L\d+)$/, '') + if (!url && local && isSubpath(local) && !local.includes(':')) return // `target="_blank"` is load-bearing, not decoration. The main process refuses // in-window navigation outright and answers a window-open by opening the user's // browser, so this is the only form of link that does anything at all. @@ -115,6 +121,27 @@ const COMPONENTS: Components = { }, } +function plain(node: ReactNode): string { + if (typeof node === 'string' || typeof node === 'number') return String(node) + if (Array.isArray(node)) return node.map(plain).join('') + return isValidElement<{ children?: ReactNode }>(node) ? plain(node.props.children) : '' +} + +function CodeBlock({ children }: { children: ReactNode }): React.JSX.Element { + const [wrap, setWrap] = useState(false) + const [copied, setCopied] = useState(false) + const [error, setError] = useState(false) + const language = isValidElement<{ className?: string }>(children) ? children.props.className?.replace('language-', '') : undefined + return
+
{language || 'Code'} + + +
+ {error &&

Could not copy. Select the code and copy it manually.

} +
{children}
+
+} + /** * Memoised on the one string it takes. * diff --git a/src/renderer/components/ModelPicker.tsx b/src/renderer/components/ModelPicker.tsx index d8b463f..be3a0a5 100644 --- a/src/renderer/components/ModelPicker.tsx +++ b/src/renderer/components/ModelPicker.tsx @@ -1,5 +1,6 @@ import { useEffect, useId, useMemo, useRef, useState } from 'react' import type { ModelCatalogue, ModelOption } from '../../shared/protocol' +import { setExperience, useExperience } from '../experience' const CAPABILITIES: Record = { text: ['Text', 'Generates text'], @@ -21,6 +22,7 @@ export function ModelPicker({ model, disabled, onChoose, scope = 'conversation' onChoose: (model: string) => void }): React.JSX.Element { const [open, setOpen] = useState(false) + const preferences = useExperience() const [catalogue, setCatalogue] = useState(null) const [loading, setLoading] = useState(false) const [problem, setProblem] = useState(null) @@ -72,8 +74,11 @@ export function ModelPicker({ model, disabled, onChoose, scope = 'conversation' `${key} ${CAPABILITIES[key]?.join(' ') ?? ''}`).join(' ') const searchable = `${row.name} ${row.id} ${row.provider} ${capabilities}`.toLowerCase() return words.every((word) => searchable.includes(word)) + }).sort((a, b) => { + const rank = (row: ModelOption) => row.id === model ? -2 : preferences.recentModels.includes(row.id) ? preferences.recentModels.indexOf(row.id) : 100 + return rank(a) - rank(b) }) - }, [catalogue, model, query]) + }, [catalogue, model, query, preferences.recentModels]) useEffect(() => { setActive(0) }, [query, catalogue]) useEffect(() => { list.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView({ block: 'nearest' }) @@ -83,7 +88,10 @@ export function ModelPicker({ model, disabled, onChoose, scope = 'conversation' const selected = catalogue?.models.find((row) => row.id === model) const label = selected?.name ?? model ?? 'Configured default' const compactLabel = label.split('/').pop() || label - const choose = (row: ModelOption) => { onChoose(row.id); close() } + const choose = (row: ModelOption) => { + setExperience('recentModels', [row.id, ...preferences.recentModels.filter((id) => id !== row.id)].slice(0, 8)) + onChoose(row.id); close() + } return
{ if (!event.currentTarget.contains(event.relatedTarget)) setOpen(false) @@ -126,11 +134,11 @@ export function ModelPicker({ model, disabled, onChoose, scope = 'conversation' onMouseDown={(event) => event.preventDefault()} onMouseEnter={() => setActive(index)} onClick={() => choose(row)}> {row.name} - {row.provider}{row.premium ? ' · Premium' : ''} + {row.provider}{row.premium ? ' · Premium' : ''}{row.contextWindow ? ` · ${row.contextWindow.toLocaleString()} context tokens` : ''}{preferences.recentModels.includes(row.id) ? ' · Recent' : ''} {!!row.capabilities?.length && - {row.capabilities.map((key) => { + {row.capabilities.filter((key) => ['text', 'tools'].includes(key)).map((key) => { const badge = CAPABILITIES[key] - return badge ? + return badge ? {badge[0]} : null })} @@ -141,6 +149,7 @@ export function ModelPicker({ model, disabled, onChoose, scope = 'conversation'
{!loading && options.length === 0 &&

{query ? 'No models match your search.' : 'No models available. Check your backend settings.'}

}
{scope === 'bot' ? 'Saved with this bot. Applies to its next message.' : 'Applies to the next message in this conversation.'}
+

Brave Bot uses text and tools. Other provider capabilities, such as image or audio generation, are not available here. Pricing is not supplied by this catalogue.

} } diff --git a/src/renderer/components/Notice.tsx b/src/renderer/components/Notice.tsx index 9db1406..d2cb158 100644 --- a/src/renderer/components/Notice.tsx +++ b/src/renderer/components/Notice.tsx @@ -1,55 +1,7 @@ -import { useEffect, useRef } from 'react' - -/** - * Something the app has to say, with nothing to decide about it. - * - * The opposite of [`TrustPrompt`] in every way that matters. That one is modal because an - * answer is load-bearing and there is deliberately no way past it; this one is modal only - * because it is on top of the window, and every ordinary way out of it works: Escape, the - * scrim, the button. A panel showing a build stamp has no business trapping anybody. - * - * It holds what a menu item found out — the agent's build, or what `bravebot doctor` said — - * and both of those are text of unknown length, so the body scrolls and the text is - * monospaced rather than being made to look like prose it is not. - */ -export function Notice({ - title, - body, - onClose, -}: { - title: string - body: string - onClose: () => void -}): React.JSX.Element { - const close = useRef(onClose) - close.current = onClose - - useEffect(() => { - const onKey = (event: KeyboardEvent): void => { - if (event.key === 'Escape') close.current() - } - window.addEventListener('keydown', onKey) - return () => window.removeEventListener('keydown', onKey) - }, []) - - return ( -
{ - if (event.target === event.currentTarget) onClose() - }} - > -
-

{title}

-
{body}
-
- -
-
-
- ) +import { Modal } from './Modal' +export function Notice({ title, body, onClose }: { title: string; body: string; onClose: () => void }): React.JSX.Element { + return +

{title}

{body}
+
+
} diff --git a/src/renderer/components/ThemePicker.tsx b/src/renderer/components/ThemePicker.tsx index aa82b7c..9089323 100644 --- a/src/renderer/components/ThemePicker.tsx +++ b/src/renderer/components/ThemePicker.tsx @@ -1,3 +1,4 @@ +import { Modal } from './Modal' import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react' import { BRAVE, findTheme, roleVariables, type Theme } from '../../shared/theme' import { applyTheme } from '../theme' @@ -104,14 +105,7 @@ export function ThemePicker(props: Props): React.JSX.Element { const dark = window.matchMedia('(prefers-color-scheme: dark)').matches return ( -
-
event.stopPropagation()} - > +

Theme

Add your own as JSON in {directory}.

-
-
+
+ ) } diff --git a/src/renderer/components/TrustPrompt.tsx b/src/renderer/components/TrustPrompt.tsx index d0392e8..c71b864 100644 --- a/src/renderer/components/TrustPrompt.tsx +++ b/src/renderer/components/TrustPrompt.tsx @@ -1,3 +1,4 @@ +import { Modal } from './Modal' interface Props { directory: string onAnswer: (trusted: boolean) => void @@ -12,8 +13,7 @@ interface Props { */ export function TrustPrompt({ directory, onAnswer }: Props): React.JSX.Element { return ( -
-
+

Do you trust this directory?

{directory}

@@ -26,8 +26,7 @@ export function TrustPrompt({ directory, onAnswer }: Props): React.JSX.Element { see every change before it is applied.

- Either way, every write is shown to you first. This answer lasts for this session - only. + Trusted writes may apply directly. Changes involving untrusted content require review. Your trust choice is saved with this conversation.

-
-
+ ) } diff --git a/src/renderer/styles.css b/src/renderer/styles.css index 641ee60..38ec867 100644 --- a/src/renderer/styles.css +++ b/src/renderer/styles.css @@ -2,6 +2,7 @@ Light and dark both defined; the app follows the system. */ :root { + color-scheme: light dark; --bg: #ffffff; --bg-side: rgba(246, 246, 248, 0.7); --ink: #1c1c1e; @@ -13,7 +14,8 @@ /* The accent with the shout taken out — the orange mixed about half and half with `--ink-dim`. For text that should read as *ours* without competing with the accent proper, which in this window means a selected row and a button somebody can press. */ - --accent-quiet: #b56539; + --accent-quiet: #9b4315; + --accent-text: #9b4315; --bubble-user: #f2600c; --bubble-user-ink: #ffffff; --bubble-agent: #f1f1f4; @@ -51,7 +53,8 @@ --line: rgba(255, 255, 255, 0.1); /* Mixed against the dark theme's own `--ink-dim`, so it lifts off the darker ground rather than sinking into it the way the light-mode value would. */ - --accent-quiet: #cd7d52; + --accent-quiet: #efa77f; + --accent-text: #efa77f; --bubble-agent: #2c2c2e; --added: #3fb950; --added-bg: rgba(63, 185, 80, 0.13); @@ -105,6 +108,7 @@ --tree-bg: color-mix(in srgb, var(--role-text) 6%, var(--role-background)); --bubble-agent: color-mix(in srgb, var(--role-text) 9%, var(--role-background)); --accent: var(--role-note); + --accent-text: var(--role-text); --accent-ink: var(--role-note-ink); --accent-quiet: color-mix(in srgb, var(--role-note) 55%, var(--role-muted)); --bubble-user: var(--role-primary); @@ -278,6 +282,11 @@ button { font: inherit; color: inherit; cursor: pointer; } -webkit-app-region: drag; } +/* Every header control must opt out of native window dragging, including scope tabs. */ +.sessions-head :is(button, input, select, textarea, a) { + -webkit-app-region: no-drag; +} + .new { -webkit-app-region: no-drag; width: 100%; @@ -289,11 +298,21 @@ button { font: inherit; color: inherit; cursor: pointer; } text-align: left; } .new:hover { background: rgba(127, 127, 127, 0.1); color: var(--ink); } -.plus { color: var(--accent); font-weight: 600; margin-right: 4px; } +.plus { color: var(--accent-text); font-weight: 600; margin-right: 4px; } /* The filter and the grouping toggle share a row, so the spacing above them is set once here rather than by whichever of them happens to come first. */ .session-tools { display: flex; gap: 4px; align-items: stretch; margin-top: 6px; } +.sidebar-actions { display: flex; align-items: stretch; gap: 4px; } +.sidebar-create { flex: 1; min-width: 0; } +.sidebar-actions .new { border-color: transparent; color: var(--ink); font-size: 13px; } +.sidebar-actions .new-split { width: 100%; } +.sidebar-actions .new-recent { background: transparent; } +.sidebar-search-toggle, .sidebar-actions .session-group { display: grid; place-items: center; flex: none; width: 30px; min-height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-dim); } +.sidebar-search-toggle:hover, .sidebar-actions .session-group:hover { background: var(--bubble-agent); color: var(--ink); } +.sidebar-search-toggle[aria-expanded='true'], .sidebar-actions .session-group[aria-pressed='true'] { background: var(--bubble-agent); color: var(--accent-text); } +.sidebar-search { display: flex; gap: 4px; margin-top: 8px; } +.sidebar-search button { width: 28px; border: 0; background: transparent; border-radius: 6px; font-size: 18px; } /* `no-drag` for the same reason `.new` has it: the header this sits in is a window drag region, and without it the box cannot be clicked into or selected in — the pointer moves @@ -332,7 +351,7 @@ button { font: inherit; color: inherit; cursor: pointer; } line-height: 1; } .session-group:hover { color: var(--ink); } -.session-group[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); } +.session-group[aria-pressed='true'] { border-color: var(--accent); color: var(--accent-text); } .session-group:focus-visible { outline: none; border-color: var(--accent); } .session-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; } @@ -408,7 +427,7 @@ button { font: inherit; color: inherit; cursor: pointer; } font-weight: 600; line-height: 1; } -.session-group-new:hover { color: var(--accent); } +.session-group-new:hover { color: var(--accent-text); } /* The column narrows to 200px, which is not enough for every checkout's name. */ .session-group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } @@ -592,7 +611,7 @@ button { font: inherit; color: inherit; cursor: pointer; } } .bubble.user:hover .fork-here, .fork-here:focus-visible { opacity: 1; } -.fork-here:hover { color: var(--accent); border-color: var(--accent); } +.fork-here:hover { color: var(--accent-text); border-color: var(--accent); } .fork-here:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; } /* Shown on hover like the others, and plainly unavailable: a control that vanishes mid-turn is one the reader has to go looking for when the turn ends. */ @@ -602,6 +621,7 @@ button { font: inherit; color: inherit; cursor: pointer; } /* The mark on a session that came out of another one, wherever one is drawn: beside a name in the list, and at the head of the banner. One rule, because they mean one thing — the control a prompt offers on hover uses the same mark and colours it for itself. */ +.session-pin { display: inline-block; vertical-align: -2px; margin-right: 5px; } .fork-mark { color: var(--accent-quiet); margin-right: 5px; } /* Sat on the text baseline rather than hung off the line box, so a mark before a title lines up with the title instead of riding above it. */ @@ -641,7 +661,7 @@ button { font: inherit; color: inherit; cursor: pointer; } text-decoration: underline; cursor: pointer; } -.fork-banner .link:hover { color: var(--accent); } +.fork-banner .link:hover { color: var(--accent-text); } .fork-banner .link:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; } /* Where a fork's link landed. `display: contents` on `.entry-hit` means the wrapper cannot be @@ -768,7 +788,7 @@ button { font: inherit; color: inherit; cursor: pointer; } } .bubble.assistant th { font-weight: 600; background: var(--code-bg); } -.bubble.assistant a { color: var(--accent); } +.bubble.assistant a { color: var(--accent-text); } /* A link that will not open is drawn as the text it wraps, marked but not clickable. */ .md-dead-link { text-decoration: underline dotted var(--ink-faint); } .md-image { @@ -804,7 +824,7 @@ button { font: inherit; color: inherit; cursor: pointer; } .tool .note { color: var(--ink-faint); } .tool.failed { border-left-color: var(--removed); } .tool.failed .note { color: var(--removed); } -.tool.running .ellipsis { color: var(--accent); } +.tool.running .ellipsis { color: var(--accent-text); } /* A replayed line has no outcome to show, so it is drawn quieter than a live one. */ .tool.replayed { opacity: 0.55; font-family: var(--mono); font-size: 11px; } @@ -930,7 +950,7 @@ button { font: inherit; color: inherit; cursor: pointer; } /* A series of questions. Drawn in the accent rather than the confine purple: unlike the output and vouch cards, nothing here is untrusted — the planner may only ask at all when it has not been shown untrusted content, so these are the model's own words. */ -.confirm.ask .confirm-head .intent { color: var(--accent); } +.confirm.ask .confirm-head .intent { color: var(--accent-text); } .confirm.ask .confirm-head .path { font-family: inherit; color: var(--ink-dim); } .ask-question { margin: 0; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); } @@ -990,7 +1010,7 @@ button { font: inherit; color: inherit; cursor: pointer; } /* Remembering answers every later question about these programs, so it is drawn as the weightier of the two approvals rather than the easier one. */ -.confirm-actions .approve.always { background: transparent; color: var(--accent); border: 1px solid var(--accent); } +.confirm-actions .approve.always { background: transparent; color: var(--accent-text); border: 1px solid var(--accent); } .confirm-head { display: flex; @@ -1004,7 +1024,7 @@ button { font: inherit; color: inherit; cursor: pointer; } text-transform: uppercase; font-size: 10px; font-weight: 700; - color: var(--accent); + color: var(--accent-text); } .confirm-head .path { font-family: var(--mono); font-size: 12px; flex: 1; } .confirm-head .counts { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); } @@ -1138,7 +1158,7 @@ button { font: inherit; color: inherit; cursor: pointer; } } .model-trigger svg { flex: 0 0 auto; } .model-current { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.model-trigger:hover, .model-trigger[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); } +.model-trigger:hover, .model-trigger[aria-expanded="true"] { color: var(--accent-text); border-color: var(--accent); } .model-trigger:disabled { cursor: default; } .model-trigger:focus-visible, .model-refresh:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } .model-popover { @@ -1150,15 +1170,15 @@ button { font: inherit; color: inherit; cursor: pointer; } } .model-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; } .model-heading strong { font-size: 12px; font-weight: 600; } -.model-refresh { border: 0; background: transparent; color: var(--accent); font: inherit; font-size: 11px; cursor: pointer; } +.model-refresh { border: 0; background: transparent; color: var(--accent-text); font: inherit; font-size: 11px; cursor: pointer; } .model-refresh:disabled { opacity: .45; cursor: default; } .model-search { width: 100%; padding: 8px 10px; font: inherit; color: var(--ink); background: var(--bg-side); border: 1px solid var(--line); border-radius: 6px; } .model-search:focus { outline: none; border-color: var(--accent); } .model-options { overflow-y: auto; min-height: 0; margin-top: 8px; } .model-option { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-radius: 6px; cursor: pointer; } .model-option.active { background: var(--bg-side); } -.model-option[aria-selected="true"] .model-name { color: var(--accent); } -.model-check { width: 14px; flex: 0 0 auto; color: var(--accent); } +.model-option[aria-selected="true"] .model-name { color: var(--accent-text); } +.model-check { width: 14px; flex: 0 0 auto; color: var(--accent-text); } .model-description { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; } .model-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .model-detail { font-size: 10px; color: var(--ink-dim); } @@ -1173,7 +1193,7 @@ button { font: inherit; color: inherit; cursor: pointer; } .context { background: var(--bg-side); overflow-y: auto; - padding-top: 46px; + padding-top: 0; } /* The row of connected buttons at the top of the column, one per panel. @@ -1209,7 +1229,7 @@ button { font: inherit; color: inherit; cursor: pointer; } `aria-pressed` is what says it to a screen reader either way. */ .panel-pick[aria-pressed='true'] { background: var(--tree-bg); - color: var(--accent); + color: var(--accent-text); } .panel-icon { display: block; } @@ -1273,7 +1293,7 @@ button { font: inherit; color: inherit; cursor: pointer; } .todos li { display: flex; gap: 6px; padding: 3px 0; color: var(--ink-dim); } .todos li.done { text-decoration: line-through; color: var(--ink-faint); } .todos li.active { color: var(--ink); font-weight: 500; } -.todos .marker { color: var(--accent); } +.todos .marker { color: var(--accent-text); } .files li { display: flex; @@ -1377,7 +1397,7 @@ button { font: inherit; color: inherit; cursor: pointer; } line-height: 1; } .tree-tool:hover { background: rgba(127, 127, 127, 0.14); color: var(--ink-dim); } -.tree-tool.on { color: var(--accent); } +.tree-tool.on { color: var(--accent-text); } /* Wide enough for two characters, and in the mono face so `.*` reads as the filename it is. */ .tree-tool.dotfiles { width: auto; padding: 0 4px; font-family: var(--mono); font-size: 10px; } @@ -1423,6 +1443,18 @@ button { font: inherit; color: inherit; cursor: pointer; } overscroll-behavior: contain; } +.context-files { display: flex; flex-direction: column; overflow: hidden; } +.context-files .context-head { flex: none; } +.files-panel.off { display: none; } +.files-panel { flex: 1; min-height: 0; padding: 8px 14px 14px; display: flex; } +.files-panel .tree { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; } +.files-panel .tree-body { flex: 1; min-height: 0; max-height: none; } +.tree-tools { flex: none; } +.tree-tools .tree-tool { display: grid; place-items: center; min-width: 28px; height: 28px; } +.tree-search { display: flex; gap: 4px; flex: none; margin-bottom: 8px; } +.tree-search .tree-find { flex: 1; min-width: 0; margin-bottom: 0; } +.tree-search .tree-tool { width: 28px; height: 28px; font-size: 18px; } + .tree-list { list-style: none; margin: 0; padding: 0; } /* The indent rides on `--depth`, set per row from React, so a deep row is still one flex box the @@ -1473,7 +1505,7 @@ button { font: inherit; color: inherit; cursor: pointer; } .tree-glyph.doc { color: var(--ink-dim); } .tree-glyph.image { color: var(--added); } .tree-glyph.media { color: var(--removed); } -.tree-glyph.archive { color: var(--accent); } +.tree-glyph.archive { color: var(--accent-text); } .tree-name { font-family: var(--mono); @@ -2006,7 +2038,7 @@ button { font: inherit; color: inherit; cursor: pointer; } font-size: 11px; } .bot-archived button:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; } -.bot-restore:hover { color: var(--accent); } +.bot-restore:hover { color: var(--accent-text); } /* The one act in this window that cannot be taken back. @@ -2024,9 +2056,8 @@ button { font: inherit; color: inherit; cursor: pointer; } .bot-asking { background: var(--removed-bg); } .bot-asking .bot-name { color: var(--ink); } .bot-warning { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + white-space: normal; + overflow-wrap: anywhere; color: var(--removed); font-size: 11px; } @@ -2056,26 +2087,27 @@ button { font: inherit; color: inherit; cursor: pointer; } the mark sits on the word rather than above it. */ .transcript-head h1 { display: flex; align-items: center; gap: 7px; } -.sessions-head :is(button, input, select, textarea, a) { -webkit-app-region: no-drag; } -:root { --accent-text: var(--ink); } -.sidebar-actions { display: flex; align-items: stretch; gap: 4px; } -.sidebar-create { flex: 1; min-width: 0; } -.sidebar-actions .new { border-color: transparent; color: var(--ink); font-size: 13px; } -.sidebar-actions .new-split { width: 100%; } -.sidebar-actions .new-recent { background: transparent; } -.sidebar-search-toggle, .sidebar-actions .session-group { display: grid; place-items: center; flex: none; width: 30px; min-height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-dim); } -.sidebar-search-toggle:hover, .sidebar-actions .session-group:hover { background: var(--bubble-agent); color: var(--ink); } -.sidebar-search-toggle[aria-expanded='true'], .sidebar-actions .session-group[aria-pressed='true'] { background: var(--bubble-agent); color: var(--accent-text); } -.sidebar-search { display: flex; gap: 4px; margin-top: 8px; } -.sidebar-search button { width: 28px; border: 0; background: transparent; border-radius: 6px; font-size: 18px; } - - - +/* Conversation workspace: readable defaults, compact mode by choice. */ +:root { --accent-ink: #24180f; --ink-faint: #707078; --bubble-user: #fff0e5; --bubble-user-ink: #632c12; } +@media (prefers-color-scheme: dark) { + :root { --ink-faint: #a6a6af; --bubble-user: #443125; --bubble-user-ink: #ffe2cc; } +} +body { font-size: 14px; } button, input, textarea, select { font: inherit; } button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; } .app { position: relative; } +.app.comfortable .session { padding-top: 12px; padding-bottom: 12px; } +.app .session-where, .app .where, .app .none, .app .model-current { font-size: 12px; } +.app .panel-head { font-size: 12px; letter-spacing: .02em; text-transform: none; } +.app .entries { padding: 24px clamp(18px, 3vw, 44px); gap: 18px; } +.app .bubble { max-width: 100%; font-size: 14px; line-height: 1.65; } +.app .bubble.user { max-width: 85%; align-self: flex-end; padding: 10px 16px; border-radius: 14px 14px 4px 14px; } +.app .bubble.assistant { background: transparent; padding: 6px 0; width: 100%; } +.app .bubble pre { font-size: 12px; } +.app.compact .entries { gap: 10px; padding: 16px 22px; } +.app.compact .bubble { font-size: 13px; line-height: 1.5; } .conversation-toolbar { display: flex; gap: 6px; padding: 5px 20px 10px; align-items: center; } .conversation-toolbar > button, .conversation-toolbar .export-open { min-height: 30px; padding: 4px 10px; background: transparent; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; } .conversation-toolbar .export-menu { margin-left: auto; } @@ -2109,13 +2141,37 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus .background-tasks { position: fixed; left: 12px; bottom: 12px; width: 220px; z-index: 25; display: grid; gap: 6px; } .background-tasks button { padding: 8px 10px; background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; font-size: 12px; box-shadow: 0 3px 10px #0001; text-align: left; } .welcome-mark { width: 50px; height: 50px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 24px; font-weight: 700; border-radius: 15px; margin-bottom: 22px; } +.empty-body > div { width: min(560px, 100%); padding: 24px; } +.empty-body h1 { font-size: 27px; line-height: 1.2; letter-spacing: -.5px; } +.empty-body p { line-height: 1.6; } .primary { border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); padding: 10px 18px; font-weight: 600; } .welcome-recents { display: grid; gap: 6px; margin-top: 32px; } .welcome-recents h2 { font-size: 13px; color: var(--ink-dim); } .welcome-recents button { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 10px 12px; background: transparent; border: 1px solid var(--line); border-radius: 8px; } .welcome-recents span { font-size: 12px; color: var(--ink-dim); overflow-wrap: anywhere; } .welcome-hint { font-size: 12px; color: var(--ink-dim); margin-top: 24px; } +@media (max-width: 1120px) { + .app { grid-template-columns: var(--col-left) 1px minmax(0, 1fr) 0 0; } + .app .context { position: absolute; right: 0; top: 0; bottom: 0; width: 310px; z-index: 35; background: var(--bg); box-shadow: -12px 0 32px #0002; } + .app.right-folded .context { pointer-events: none; } + .app .gutter.right { display: none; } + .composer-hint { display: none; } +} @media (prefers-reduced-motion: reduce) { .entries { scroll-behavior: auto; } } + +.inspector-title { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; font-size: 13px; } +.inspector-title button { background: transparent; border: 0; min-width: 28px; min-height: 28px; font-size: 20px; } +.inspector-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); } +.inspector-tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 8px; font-size: 12px; flex: 1; } +.inspector-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; } +.app .context-head { padding: 14px 14px 8px; } +.app .panel-inner .none { padding: 0; margin: 4px 0 10px; } +.app .panel-inner { padding: 8px 14px 14px; } +.app .panel { flex: none; } +.context-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; border: 0; background: transparent; font: 12px var(--mono); padding: 4px 0; color: var(--ink); min-width: 0; } +.context-link:hover { text-decoration: underline; } +.files .approved .tag, .files .applying .tag { color: var(--warn); } +.files .failed .tag { color: var(--removed); } .conversation-toolbar .export-split { margin-left: auto; } .code-block, .diff-review { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; margin: 12px 0; } .code-toolbar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bubble-agent); border-bottom: 1px solid var(--line); font-size: 12px; } @@ -2144,6 +2200,13 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus .session-badges .working, .session-badges .needs-approval { color: var(--warn); background: var(--warn-bg); } .session-badges .failed { color: var(--removed); background: var(--removed-bg); } .session-badges .completed { color: var(--added); } + +.file-search-scope { display: flex; margin: 10px 0 8px; gap: 4px; } +.file-search-scope button, .preview-actions button { padding: 6px 8px; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; font-size: 12px; } +.file-search-scope button[aria-pressed="true"] { background: var(--bubble-agent); font-weight: 600; } +.file-search-results { padding: 6px; } +.file-search-results > button { display: block; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px; overflow-wrap: anywhere; font: 12px var(--mono); } +.file-search-results > button:hover { background: var(--bubble-agent); } .file-preview { width: min(1000px, calc(100vw - 48px)); } .file-preview .code-toolbar strong { flex: 1; overflow-wrap: anywhere; } .preview-boundary { padding: 10px 12px; background: var(--confine-bg); border-left: 3px solid var(--confine); font-size: 12px; } @@ -2182,10 +2245,14 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus .memory-history pre { max-height: 240px; overflow: auto; white-space: pre-wrap; font-size: 12px; } .bot-memory-panel > textarea { width: 100%; font: 13px/1.5 var(--mono); padding: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; } .memory-reset { padding: 12px; border: 1px solid var(--warn); border-radius: 8px; } +.theme-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; } +.theme-actions button { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 7px 12px; } .backend-status { display: flex; flex-direction: column; gap: 5px; padding: 12px 20px; background: var(--warn-bg); font-size: 12px; } .backend-status > div { display: flex; gap: 6px; } .backend-status button { border: 1px solid var(--line); background: var(--bg); border-radius: 5px; padding: 5px 8px; } +.app .model-capability, .app .model-detail, .app .model-footnote { font-size: 11px; } +.app .model-name { font-size: 13px; } .permission-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); } .permission-row code { font-size: 12px; overflow-wrap: anywhere; } @@ -2199,8 +2266,11 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus .app.no-session { grid-template-columns: var(--col-left) 1px minmax(0, 1fr) 0 0; } .app.no-session .context, .app.no-session .gutter:last-of-type { visibility: hidden; } +.app .transcript.empty-state .empty-body { text-align: left; align-items: flex-start; justify-content: center; overflow-y: auto; } +.app .transcript.empty-state .empty-body h1 { font-size: 28px; margin: 0 0 14px; color: var(--ink); } .app .session.current .session-title { color: var(--ink); } .app .session.current .session-where { color: var(--ink-dim); opacity: 1; } +.app .panel:has(.none) .panel-inner { padding: 0 14px 4px; } .app .composer-toolbar { flex-wrap: wrap; } .app .composer-hint { min-width: 130px; } @@ -2223,6 +2293,9 @@ button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus .memory-readable { white-space: normal; } .memory-readable p { margin: 0 0 12px; } .memory-readable pre { white-space: pre-wrap; overflow-wrap: anywhere; } + +/* Keep focus mode readable on wide windows while leaving space for code and diffs. */ +.app .entries, .app.compact .entries { padding-inline: max(20px, calc((100% - 840px) / 2)); } .app .composer { padding-inline: max(20px, calc((100% - 880px) / 2)); } .app .attention-bar { padding-inline: max(20px, calc((100% - 880px) / 2)); } diff --git a/src/shared/theme.ts b/src/shared/theme.ts index af287af..224b4f9 100644 --- a/src/shared/theme.ts +++ b/src/shared/theme.ts @@ -429,6 +429,14 @@ function isLight(hex: string): boolean { return 2126 * r + 7152 * g + 722 * b > 1_270_000 } +/** Choose the higher WCAG contrast, using linear-light luminance rather than encoded RGB. */ +function contrastInk(hex: string): string { + const channels = channel6(hex.replace(/^#/, '')) ?? [0, 0, 0] + const linear = channels.map((channel) => { const c = channel / 255; return c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4 }) + const luminance = .2126 * linear[0]! + .7152 * linear[1]! + .0722 * linear[2]! + return (luminance + .05) / .05 >= 1.05 / (luminance + .05) ? '#000000' : '#ffffff' +} + function channel6(hex: string): [number, number, number] | null { if (!/^[0-9a-fA-F]{6}$/.test(hex)) return null return [ @@ -514,8 +522,8 @@ export function roleVariables(theme: Theme, dark: boolean): Record = {} for (const role of ROLE_NAMES) variables[`--role-${role}`] = resolved[role] - variables['--role-note-ink'] = isLight(resolved.note) ? '#000000' : '#ffffff' - variables['--role-primary-ink'] = isLight(resolved.primary) ? '#000000' : '#ffffff' + variables['--role-note-ink'] = contrastInk(resolved.note) + variables['--role-primary-ink'] = contrastInk(resolved.primary) variables['--role-scheme'] = isLight(resolved.background) ? 'light' : 'dark' return variables }