30 Commits
Author SHA1 Message Date
NB 1cb593044f Move the tab shape with the frame layout on header changes (#13659)
* Move the tab shape with the frame layout on header changes

The TabShape MutationObserver called place() in a microtask after each
header change. Each call read the layout and forced a full page layout.
A chat switch did this about 16 times. Now the callback asks the
existing ResizeObserver for a new notification. The ResizeObserver runs
after the frame layout and before paint, so the shape is still correct
on the first painted frame and no forced layout occurs.

Add the s16-switch-md bench scenario (20 chat switches with a markdown
history) with a long-task counter for the switch phase, a reset for the
renderer probes, and a bench agent model that does not change at start.

* Place the tab shape at once for fit changes from a ResizeObserver

The model picker fit (data-model-fit) and the thread row fit (data-mode,
data-fold) change the header from ResizeObserver callbacks. A new
observation of the row made in the same delivery is not deeper than the
elements already reported, so Chromium skips it. Then the shape is one
frame late and the window gets a "ResizeObserver loop" error. For these
attributes, TabShape calls place() at once, as before. Other changes
keep the re-observe path.
2026-11-20 19:41:02 +01:00
NB 73f9fb506b Add performance probes and bench scenarios (#13408)
* Add performance probes and bench scenarios

A bench build (bun run build:bench) adds probes for the main process,
the database, IPC, timers and the renderer. The probes install only with
OPENBOT_PERF_PROBES=1 in an unpackaged app. A release build has no probe
code. Renderer probes use window.__openbotPerfProbes over CDP; nothing goes
through preload or IPC.

dev:bench gets --probes, new idle, streaming, chat-window and 100-agent
scenarios, CPU by process kind, and a hot-spot report (dev:bench:hotspots).
New scripts: joined-stream-perf-e2e.ts and team-api-broadcast-bench.ts.

* Add --trace-act to record a trace during the bench act

The flag records a Chrome trace and a renderer CPU profile for 8 s,
starting 5 s into the act of the first run. It stops early when the act
ends. This shows the frames and paint work while agents stream.

* Remove probe exports that no file uses
2026-11-20 15:46:40 +01:00
Aleksander DygońandClaude Opus 5.5 03c2ff34c2 Remove code comments and add the no-comments rule (#12604)
* Remove code comments and add the no-comments rule

Remove the comments from first-party code and configuration files:
TS/JS, JSX, CSS, SQL migrations, Swift, Kotlin, Gradle, shell,
Docker, systemd, Nix, YAML, TOML, JSONC and GritQL.

Keep only what a tool reads: license headers, shebangs, compiler
and lint directives, JSDoc types in plain .js files, generated file
headers, GritQL scope lines, the install-server.sh help text and the
openbot-boat-pre-stop marker. Vendored code, fixtures and released
schemas keep their comments.

Add the rule to AGENTS.md, and change the docs that asked for
comments. Add two i18n keys that only comments named to
RELEASED_SOURCE_KEYS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep comments that are data in strings

The benchmark task files in opencode-free-models-bench.ts tell the
model what each function must do. The sample file and HTML page in
the two stories are display content. Put their comments back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep released migrations and mobile native inputs unchanged

check:migrations compares each released migration with v0.73.0 byte
for byte, so restore src/backend/migrations. A change to a native
build input of apps/mobile makes a new runtime version, so restore
those files and the extra fingerprint sources.

List these files and the comment markers that a tool reads in
AGENTS.md. Remove the last requests for comments in
src/renderer/AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 12:19:28 +01:00
NBandClaude Opus 5.5 fc67098f20 Stop the hopping balls of sidebar rows that are off screen (#11856)
With 100 working agents, the sidebar ran 282 ball animations, most of them in rows that were
scrolled away. Each frame restyled and layerized all of them. A working badge now stops its balls
while it is off screen. The avatar and the badge use one shared visibility observer.

The 100-agent bench also records the style and layout time of the window.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 10:30:51 +01:00
NBandClaude Opus 5.5 cd5e63bc82 Use less CPU while many agents stream (#11651)
* Use less CPU while many agents work

Streamed text, channel messages, the agent list, the sidebar, Team API
broadcasts, unread-count reads and the Computer Use rim do less work
for each change. See changelog.d/t3-optimize-cpu-at-scale.md.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Add a dev:bench scenario with 100 agents that stream

s14-agents-100 streams 96 agents at once with a fake Codex, so it spends
no model quota. Two agents write in a channel of 2,000 messages, as the
channel runs two tasks at once. The scenario records main-process CPU,
event-loop delay and the app window's busy time and lag while the
agents stream, and can write a CPU profile of each process.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Save streamed text of all agents in one transaction

The streamed text of all agents that waits for the 100 ms tick is saved
in one transaction, not in one for each agent. The hot helpers of a
streamed write keep their prepared statements. The sidebar badges read
their widths together in the next frame, so the window calculates the
page style once per frame, not once for each badge.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Write only the changed agent rows on a roster write

A send or a turn end writes the roster to save one agent's preview. The write
deleted and inserted every agent row and set a new revision on the thread of
every agent. With 96 agents, one preview write changed 96 thread revisions, so
each reader of an unchanged chat read it again.

Now the write keeps the rows that did not change, and the thread row of an
unchanged agent changes only when it is missing or names another agent. The
roster event still holds the whole list for the recovery path.

Measured with 96 agents: 0.64 ms to 0.46 ms for each write, and 96 to 1
changed thread revisions.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Keep the face of an avatar that is off screen

With 100 working agents, the avatars changed faces about 50 times a
second, most of them in sidebar rows that were scrolled away. One shared
IntersectionObserver stops the face timer of an avatar off screen.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Publish the Dynamic Island state at most every 100 ms

Each streamed delta published the island state over IPC. With many
agents, this took about 3% of window CPU.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Stop a leaving sidebar badge from halting the window

With Solid 2.0.0, the built badge reads the `shown` memo itself in
place of the narrowed `Show` accessor. When a badge closed, its class
effect ran once more, read `undefined.kind`, and threw. Solid then
stopped all updates (REACTIVITY_HALTED), so the window froze. The
`s14-agents-100` bench showed it in each run after the move to 2.0.0.

The badge now reads the last badge that showed.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Add the sidebar badge freeze fix to the release notes

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 08:57:48 +01:00
NB d42f88fee9 Load a joined-server workspace one time and start signed in from the saved session (#8888)
* Load a joined-server workspace one time and start signed in from the saved session

The app is signed in from the stored profile at start. /v1/me confirms the session in the
background: a 401 signs the user out, and any other failure keeps the session.

A new connection sets capabilitiesPending on the server summary until the capability read
ends. The renderer waits for it, so one workspace load reads all the data. Before, a load
without capabilities ran first and a second full load followed.

* Keep the end of the capability read and its event together

Review fixes: the event that ends the capability wait is sent on each exit of the read, the
signed-in state is set before the session confirmation starts, and a failed reorder reads
the server list again.
2026-11-13 13:36:36 +01:00
Aleksander Dygoń 23360ff943 Add a record-demo skill and a dev:automation record command (#5716)
* Add a record-demo skill and a dev:automation record command

`dev:automation record` writes a .webm video of one page of the dev app
with the Playwright screencast. It is read-only and stops at --duration
or on SIGINT/SIGTERM. The record-demo skill tells agents how to record a
change, check the frames, and attach the video to the PR with gh --attach.

* Report the video length and keep the stop handlers in record

durationMs now starts when the screencast starts, not before the connect
and --wait-for. The SIGINT/SIGTERM handlers stay installed, so a second
signal while the encoder flushes does not truncate the file. The skill
example uses a --out name with no slash.
2026-11-08 12:29:00 +01:00
NBandClaude Opus 5.5 77300f79a7 Add a light theme to the desktop app and the web client (#2949)
* Add a light theme to the desktop app and the web client

Settings has a new Theme row: System, Light and Dark. Dark is the
default, so the app does not change after an update.

- tokens-light.css changes the palette when the root element has
  data-openbot-color-scheme="light". Light mode has no drop shadows.
- Desktop: main keeps the choice in a userData file and sets
  nativeTheme.themeSource. Each window follows prefers-color-scheme.
  The Dynamic Island stays dark.
- Web /app: this browser keeps the choice. A head script shows it
  before the first paint. The public pages stay dark.
- Toasts, Mermaid and chat visuals follow the theme.
- dev:automation removes the light color-scheme emulation of
  playwright-core, and scripts/appearance-e2e.ts checks each choice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep visited websites and native menus on the computer's colors

Main no longer sets nativeTheme.themeSource. That setting applies to
the whole app, so the default Dark also made websites in the in-app
browser and the native menus dark on a light Mac.

Now each OpenBot window applies the saved choice itself and resolves
System from prefers-color-scheme, as the web client does. A copy in
the window's localStorage gives the first paint. Main sets the native
window background from the choice.

The E2E script now checks that Light and Dark do not change
prefers-color-scheme. Web /app clears its theme when another tab
clears the browser storage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 19:12:58 +02:00
NBandClaude Opus 5.5 fcf3a95f50 Remove most exactOptionalPropertyTypes type errors (#2496)
* Remove exactOptionalPropertyTypes errors in contracts and team-client

Add `| undefined` to optional fields that callers already set to
`undefined`: the channel read cursor, the marketplace query fields and
the v4 base adapter option. These are type changes only; the wire
format does not change.

The team client now sends `contentType` only when it has an upload. A
transfer ID exists only with an upload, so the request is the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove exactOptionalPropertyTypes errors in the account service

Add `| undefined` to optional inputs that the routes already set to
`undefined`: skill marketplace queries, host registration and Mobile
Connect tickets, and the article figure props.

The R2 list and the footer route link now leave out a missing cursor or
hash. Both APIs read a missing value and `undefined` the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove exactOptionalPropertyTypes errors in scripts

Add `| undefined` to optional options that the scripts already set to
`undefined`. The renderer dev server port is now left out of the Vite
config when it is not set; Vite skips an undefined value the same way.

`ConversationMessage` fields now include `undefined`, as
`isConversationMessage` already accepts. The seed scripts and the
backend build messages with `undefined` fields. Two renderer helpers
that read these messages accept the same fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove exactOptionalPropertyTypes errors in the backend

Optional fields that the backend sets to undefined now say so in their type. The
MCP server bridge leaves out missing options instead of passing undefined, and
update_profile forwards only the profile fields that the agent sent.

Two errors stay: the MCP SDK transport classes declare onclose and sessionId as
accessors that can return undefined, and its Transport interface does not allow it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove exactOptionalPropertyTypes errors in the main process

Widen optional fields that receive undefined, and use conditional spreads for
DOM, Electron and fetch option objects. The Team protocol options are coerced
with `=== true`; the adapters read them only by truthiness. The ICE server
schema drops absent credentials so parsed servers match `IceServer`.

Two MCP SDK transport errors stay in github-mcp-proxy.ts: the SDK typings
are not compatible with the flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove exactOptionalPropertyTypes errors in shared UI

Widen optional props that callers set to undefined. Pass external props
that can be undefined through conditional spreads, or with the default
that the library uses. Add selectValue for a Select option that can be
missing. Keep the Switch input id error: an explicit undefined removes
the Kobalte generated id today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove exactOptionalPropertyTypes errors in the renderer

Add `| undefined` to optional props and fields that callers already set
to `undefined`: the shared agent and message models, renderer state, and
helper parameters. In contracts and team-client, this applies to
`AgentModelChoice.providerAccountId`, the direct conversation
`readState`, the host analytics `agentId`, the remote request `upload`
and `timeoutMs`, and the parameters of the agent policy and chat visual
helpers. These are type changes only; the wire format does not change.

Portal mounts use `?? document.body`, which is the Solid default. The
skill switch and the story select pass `false` in place of `undefined`.
The preview search mock omits absent filters. Stories share named render
functions and decorators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Fix Settings and model picker after the shared UI type changes

A conditional JSX spread on a Kobalte component stops it from rendering in
Solid 2.0.0-rc.0. Settings showed an empty page and the model picker with an
effort select did not open.

Pass disabled and step as plain props with the Kobalte defaults. Restore the
plain value prop of the effort and display selects, and keep their two
exactOptionalPropertyTypes errors in the baseline: no form that the checker
accepts keeps an undefined value uncontrolled. Remove selectValue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Use plain Link props for the footer hash

A conditional JSX spread can stop a Solid 2.0 component from rendering. The footer link now uses
a plain `hash` prop when the link has a hash, and no `hash` prop when it has none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Let linkFavicons take undefined

`MarkdownMessageText` passes `props.linkFavicons` through, and the value can be undefined. The
prop type now says so, as the other optional props of the branch do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:25:35 +02:00
Aleksander DygońandClaude Opus 5.5 212eff2a80 Remove unit tests and keep E2E and protected tests (#2051)
* Remove unit tests and keep E2E and protected tests

Delete 591 vitest unit test files and their test-only harnesses. Keep
E2E and smoke scripts under scripts/, and keep vitest files only for
migrations, schema parity, the renderer-to-main trust boundary, secret
redaction, and check-rule fixtures.

Remove the test runners that have no tests now (site-router, remote/api,
contracts, brand, auth-api client), their CI jobs, and the transfer
budget report. Remove code and dependencies that only the deleted tests
used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Set the E2E-only test policy and remove references to deleted tests

AGENTS.md now permits vitest files only for migrations, the trust
boundary, secret redaction and check-rule fixtures. All other behaviour
gets an E2E script under scripts/.

Remove references to deleted tests, harnesses and commands from docs,
AGENTS.md files and skills. The release-upgrade-safety gates that ran a
deleted test now use a manual check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep migration tests and fix CI checks after the test removal

Move the migration cases out of the deleted mixed test files into
three migration test files: the v15 agent usage upgrade and rollback,
the read-state baseline from schema v2, and the remote control plane
and permanent invitation D1 migrations.

Keep error.agent.noStartingModel for the text that older hosts send,
and let i18n-check accept it. Lower two type baseline entries. Correct
comments and docs that named removed tests or test commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove the empty test patterns from the knip configuration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Add E2E checks for Signal secrets, IPC input decoding and analytics redaction

- scripts/signal-security-e2e.ts starts the real Signal service with
  throwaway secrets. It checks the Telegram secret header, the Slack
  signature, signed account events, remote and route tickets, webhook
  headers, and that no frame or log line holds the bot token. CI runs
  it in the new Signal E2E job.
- scripts/ipc-input-e2e.ts sends malformed requests from a running dev
  app and checks that the main process decoders refuse them.
- scripts/analytics-redaction-e2e.ts checks that no captured analytics
  or failure report request holds a seeded secret. For this,
  OPENBOT_ANALYTICS_CAPTURE_URL sends analytics to a loopback capture
  server. Only an unpackaged build reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Check the renderer analytics path and path traversal in the E2E scripts

The analytics E2E now loads the window again and waits for the renderer event, so the renderer send path cannot pass with no request. The IPC input E2E now sends an attachment id and a shared file path that try to leave their folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove an unused optional parameter from the read-state migration test

The parameter gave one exactOptionalPropertyTypes error, which the type ratchet refuses for a new file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 15:25:48 +02:00
NB f3f2ed9abf Fix browser identity and keep Google sign-in compatibility (#1711) 2026-10-09 21:59:32 +02:00
NB ab4a6484fd Let Framer sign-in pass in the embedded browser (#1493)
* Let Framer sign-in pass in the embedded browser

Framer refused every sign-in with "Access denied by policy" when the user
agent had the `OpenBot/` product token. The session and the service-worker
fallback now remove only this token. They keep `Electron/`, which Google
sign-in needs.

dev:automation used the token to identify the app. It now uses the preload
bridge of the app window.

Add a `--framer-live` browser smoke probe.

Fixes #1484

* Fix the findings of the local review

- dev:automation also requires `Electron/` in the CDP user agent before it
  accepts an app window as proof. A page in another Chromium can define
  `window.openbot`.
- The Framer probe restores the panel size that the smoke script used
  before the probe.
- Correct the reason for the Canva row in the site table.
- Rename the release note to the branch name.
2026-10-07 12:44:38 +02:00
NBandClaude Opus 5.5 d1538f6738 Use less CPU and memory while channel agents stream (#1445)
* Use less CPU and memory while channel agents stream

- Channel streaming updates use the thread in memory and read only the
  messages of the streaming turn. Before, each update read the whole
  conversation and the whole channel history.
- Read only the active turn id where only that value is necessary.
- Close the Computer Use highlight windows after one minute of idle.
  The rim window skips the process type change, so the Dock icon does
  not flash when the windows open again.
- Chats that are not open convert only their latest messages.
- Chat images load and decode lazily.
- The usage report and its chart library load on demand.
- Fix the dev:bench sign-in call, which sent the code without its
  challenge id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Close idle overlays after failed reads, and keep search windows

- A failed driver read now also closes the Computer Use overlays after
  one minute hidden. Before, only an empty target closed them, so a
  driver that stopped answering kept them open.
- A chat that is not open uses only the latest snapshot messages in the
  latest window mode only. A window around an older message from a
  search is not in that tail, so it keeps the whole snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 15:58:35 +02:00
NBandClaude Opus 5.5 c9d57e3f75 Keep dev registries out of TMPDIR and open a worktree profile by default (#1441)
* Make dev scripts reject unknown options

Add one strict parser (`node:util` `parseArgs`, `strict: true`) in
`scripts/script-arguments.ts`. `dev:seed`, `dev:reset`, `dev:verify`,
`dev:bench`, and `dev:automation` use it. `--help` prints the usage and
exits 0 before any side effect. An unknown option prints the usage and
exits 2. Before this change, `dev:reset --help` deleted the dev profiles.

`dev:reset` now refuses while a profile has a live `SingletonLock`. It
checks all profiles before it deletes one, and prints each target before
it deletes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep dev registries out of TMPDIR and open a worktree profile by default

The instance and stack registries, the port lock and the remote handoff
file now live in devRuntimeDirectory(): OPENBOT_DEV_REGISTRY_DIR, else
~/Library/Caches/OpenBot/dev on macOS, $XDG_RUNTIME_DIR/openbot-dev or
~/.cache/openbot/dev on Linux, and the same %LOCALAPPDATA% path as
before on Windows. dev:status prints the directory it read. The handoff
file is named after the stack supervisor pid, and the stack deletes it
when it stops.

bun run dev now opens the worktree profile. --shared opens the shared
OpenBot Dev profile; --isolated is accepted and does nothing. No
existing profile is deleted or changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep the port profile when --force starts beside this worktree's stack

The running stack holds the worktree profile. A second Electron with the
same profile fails requestSingleInstanceLock and quits. Choose the
instance id after the conflict check: beside a stack of this worktree,
set no worktree id, so the port allocation names a profile after the
renderer port, as before.

Move the choice into developmentInstanceIdForStart and test it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 15:55:54 +02:00
NBandClaude Opus 5.5 04643172f3 Make dev scripts reject unknown options (#1427)
* Make dev scripts reject unknown options

Add one strict parser (`node:util` `parseArgs`, `strict: true`) in
`scripts/script-arguments.ts`. `dev:seed`, `dev:reset`, `dev:verify`,
`dev:bench`, and `dev:automation` use it. `--help` prints the usage and
exits 0 before any side effect. An unknown option prints the usage and
exits 2. Before this change, `dev:reset --help` deleted the dev profiles.

`dev:reset` now refuses while a profile has a live `SingletonLock`. It
checks all profiles before it deletes one, and prints each target before
it deletes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Redact rejected arguments and detect a Windows dev profile lock

The error for an unknown argument repeats the typed value. Pass it
through redactText, because the value can be a token.

Chromium on Windows holds <profile>/lockfile, not SingletonLock. On
win32, treat lockfile as a live profile, so seed and reset do not
delete an open profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Exit 2 when dev:automation gets an extra positional

cli.ts threw for an extra positional, and its catch set exit code 1.
readScriptArguments now takes maxPositionals and rejects the extra
positional with the usage and exit code 2, as for an unknown option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 15:44:10 +02:00
NBandClaude Opus 5.5 7545212da5 Do less work for each streamed part of a reply (#1418)
* Do less work for each streamed part of a reply

While a reply streams, the markdown view now lexes again only the tail
after the last complete block. A code block tokenizes only the new
complete lines and keeps the line arrays that did not change, so the
list does not make their elements again. The message is split into
content blocks one time for each step, not two.

A new budget test streams one fixed reply through the app and counts
the lexed, split and highlighted characters and the added elements.
For this reply the counts went from 201697 / 2377221 / 174567 / 74669
to 10091 / 792407 / 15073 / 3361. The test fails when a change goes
above the caps.

dev:bench now records layout and style counts, long tasks, optional
frame gaps and V8 call counts, and the startup marks of the main
process and the app window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep streamed blocks and colors equal to a full pass

The streaming lexer kept a block when text with no blank line came
after it. That text can join the block, such as "#1234" after a
paragraph line, so the reply showed two paragraphs until it settled.
Now a block is kept only when a blank line and another block come
after it.

A code block can restart its highlight at a false point inside an
embedded language, such as `${` in a template literal. When the new
tail ends in an open token, the code is now highlighted whole. HTML
and Markdown embed whole languages, so they always highlight whole.

The budget test now loads the settings view before it starts. That
import ended after the test environment closed and failed the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Lex an unfinished display math block again while it streams

Display math can span blank lines, and until its closing delimiter
arrives it lexes as paragraphs. The streaming lexer kept those
paragraphs, so the complete formula showed as plain text until the
reply settled. Now no block is kept from the first one that has a math
opener but is not a math block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 14:12:21 +02:00
NBandClaude Opus 5.5 7fa7f7a91f Keep the sign-in code in the field for mobile autofill (#1336)
* Keep the sign-in code in the field for mobile autofill (#1321)

The OtpInput native input now keeps the code as its value. It was
cleared after each keystroke, and maxlength cut a hyphenated code.
Android keyboards send no key name, so each typed character now goes
into the active slot, not into the first slot. Autocorrect is off.

The dev:automation redaction now removes the value of a named control
inside a sensitive group. The browser secret card names its input only
for the digit count, and that input now holds the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Redact a disabled OTP group and keep empty slots in place

Playwright writes states such as [disabled] after the accessible name,
so the redaction did not find the OTP group while the code was
verified. The node pattern now accepts these states.

Text that adds no code character, such as a hyphen, no longer moves
the characters after an empty slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Submit an IME-composed sign-in code at compositionend

An IME can still change composed text. A code that composition
completes was submitted before the IME finished. The slots still
update while the IME composes, and onComplete now waits for
compositionend, which applies the final field value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep a masked OTP field empty

The browser secret card uses a masked OtpInput, and its field must not
hold the secret. A masked field is again cleared after each input. Only
the unmasked sign-in code stays in the field for autofill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 13:54:22 +02:00
4bd31ab663 fix(scripts): support Windows binaries and directory modes in dev runner (#1215)
* fix(scripts): support Windows binaries and directory modes in dev runner

* fix(scripts): resolve effective owner without getuid on win32

* fix(scripts): address review feedback on Windows dev runner

* Make the Windows dev registry checks fail closed

- Stop when the registry owner cannot be read. Compare SIDs in one
  PowerShell call, so localized account names do not cause a refusal.
- Ignore children of a process that reused a dead leader pid.
- Show netstat on Windows in place of lsof.
- Import cliSpawnTarget directly and remove the dead APPDATA copy.
- Restore the comments that the earlier change cut or moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Check write access on Windows and quote batch arguments

- Reject a Windows registry directory that grants write rights to an
  account other than this user, Administrators or SYSTEM, as the POSIX
  mode check does. Read the owner and the ACL in one PowerShell call.
- Quote each argument that cliSpawnTarget passes through cmd.exe to a
  .cmd or .bat wrapper, so a space, a quote, & or % stays in its
  argument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Count inherit-only write entries in the Windows registry check

A registry record gets its permissions from the inherit-only entries of
its directory, so an account with write access to new files only could
still replace a record. Count these entries too. Trust CREATOR OWNER,
because this user creates every record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Sniezka1927 <dygons14@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:06:29 +02:00
NBandClaude Opus 5.5 7a15e6325f Fix the Dynamic Island count limit and cut renderer and main memory (#1191)
* Fix the Dynamic Island count limit and load App only in the main window

- Clamp the unread and remaining counts of a presentation to
  DYNAMIC_ISLAND_MAX_COUNT. Main rejected a presentation with more than
  10,000 unread replies, so the island stopped updating.
- Load App with a dynamic import only in the main window. Each Dynamic
  Island window loaded the full app: 23 MB heap, now 11.9 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep at most 16 idle chats in the main process memory

The main process kept each chat that it read, and marking a chat read
reads it. A chat of 2,000 messages takes about 1 MB. Now the cache drops
the least recently used idle chat when it holds more than 16. A chat
with a running turn always stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Give the helper windows their own entry, and drop only chats that were read

Main sends the first runtime snapshot on did-finish-load, and that event
does not wait for a dynamic import. The async App could miss it, and then
a pending approval did not show after a reload. Now the main window
imports App statically again, and the helper windows load helper.html,
which does not import App.

The chat cache now drops only chats that setSnapshot stored and that no
turn code took since. ensureSnapshot gives its object to code that can
change it across an await, so a copy read again could lose that change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Correct the release note for the chat cache limit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Load a dropped chat again when a queued message is edited

A chat opened with unread messages is cached by markRead, and the cache
can drop it later. A queue edit then did not publish the chat, so an
open chat kept the old text. Now the edit loads the chat again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Send updates to chats that the cache limit dropped

Main reads a dropped chat again when a queue, delivery or result change
must reach it, as when it was in memory. A chat that main never loaded
stays unloaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 08:39:38 +02:00
NB 75109e74c0 Bridge the computerUse, browser and servers IPC groups (#850)
* Bridge the computerUse, browser and servers IPC groups

- Move the one untyped endpoint to its own group, `browserInput`, so `browser` can be bridged.
- Rename the browser picture-in-picture and display-state endpoint keys to the renderer names.
  The wire channels do not change.
- Move the Computer Use methods from the top level to `window.openbot.computerUse`.
- Bridge `servers` into a const. Keep the server-list wrappers and the three events narrowed to
  one server next to the spread.
- Make the member and invite calls scoped requests that take the server last.
- Remove the `invokeRequest` and `subscribe` helpers, which nothing calls now.

Only `attachmentImports` stays written by hand.

* Update the benchmark caller and the docs for the removed preload helpers

The s11-computer-use benchmark still called window.openbot.getComputerUseState() in a string,
which the type check cannot see. Three docs still named invokeRequest and subscribe.
2026-09-25 22:38:12 +02:00
NB 3bc01acf2f Remove low-signal tests and Storybook play functions, prefer E2E tests (#826)
* Remove low-signal unit tests and prefer E2E tests

Delete test cases that cannot catch a real bug the CI E2E suite misses:
copies of a stronger test, checks of constants or markup, checks of a
mock's own return value, and implementation details. 65 cases in 43
files, including two whole files.

Replace the mandatory-test list in AGENTS.md with E2E-first rules:
no unit tests after the code, E2E tests with a repeatable artifact, and
a failure-mode list in the PR body before an isolated test.

* Keep tests minimal and add tests only for irreversible bugs

* Remove Storybook play functions and unused test IDs

CI only builds Storybook, so the 324 play functions never ran. Remove
them, the helpers only they used, and 113 stories that looked the same
as another story without their play function.

Nothing reads the five renderer data-testid hooks now. Remove them and
set the check:ui budget to zero.

* Restore safety tests and remove stories that show only General

Restore five deleted tests that guard data loss, agent isolation, a
secret header, and the disabled updater. Delete stories that open on
the General pane after their play functions were removed. Update the
review rubric and the UI foundation doc to the new test rules.

* Enforce the story and failure-mode test rules

Add a Biome rule that rejects a story play function, with fixtures and
a test. Add a "Failure modes" section to the PR template. Tell the
reviewer to report a unit test that the section does not name.

* Require tests for every database migration

State in AGENTS.md and the test review rubric that a migration always
needs tests, as src/backend/AGENTS.md already requires.
2026-09-24 22:29:31 +02:00
NB 7941c0e3aa Reduce RAM and CPU use, and add a bench to measure it (#800)
* Reduce RAM and CPU use, and add a bench to measure it

Add `bun run dev:bench`: repeatable RAM and CPU scenarios on the built app,
with a scaled seed, a per-second process sampler, main and page heaps, and
before/after reports.

Fixes that the bench measured:
- Release a provider CLI that no agent uses after 60 s.
- Keep at most 2 idle claude CLIs. Run model-list and usage probes without
  the user's MCP servers.
- Limit idle ACP sessions for opencode and grok.
- Settle only orphaned deliveries at provider readiness, so a live turn is
  not marked finished.
- Patch @solidjs/signals to dispose list rows that a memo run removes.
- Keep unchanged blocks of a streaming reply, so only the growing block
  renders again.
- Stream attachment files instead of reading each whole file into main.

* Fix code review findings in the RAM and CPU changes

- Count an ACP session that a read loaded toward the idle-session limit.
  Boot recovery reads every stored session, and each loaded session held
  its own set of the user's MCP servers for 10 minutes.
- Keep the content props of kept Markdown blocks stable while a reply
  streams, so their reads do not run again on each word.
- Answer 404 for an attachment path that is a directory, as before.
- Remove orphaned-delivery marks for deliveries that settled by another path.

* Accept a confirmed turn when stop ends a queue drain

Boot reconcile no longer marks a live delivery interrupted, so a turn
that the provider confirms during stop stays running until the next
boot reconciles it.

* Send the file length with a streamed protocol response

A buffer body gave Content-Length. The audio and video previews need it
to show a duration.
2026-09-24 10:40:01 +02:00
NB 23c9aa25f8 Turn on noUncheckedIndexedAccess in the base tsconfig (#794)
* Turn on noUncheckedIndexedAccess in the base tsconfig

Set the flag once in tsconfig.base.json and remove the copies from the
packages, apps and tsconfig.web.json that extend it. site-router,
remote/api and mobile do not extend the base, so they keep their own flag.

This turns the flag on for tsconfig.node.json: src/main, src/backend,
src/preload and scripts. Product code checks each indexed read. Where a
missing item is impossible, the code throws, as it did before the flag.
Dispatch callbacks use sequences[0] ?? 0, as the other ones already do.
Tests narrow with assert.

* Keep the old routine time result when the time has no minute
2026-09-23 22:38:11 +02:00
NB 688e79e4df Measure RAM use and release idle memory (#728)
- Add `bun run dev:memory`. It shows RSS for each process type, the JS
  heap and DOM counts of each page, and can write a heap snapshot. Dev
  tooling is counted apart from the app. The diagnostics export gets a
  memory section.
- Close the `claude` CLI of a thread that has no turn for 10 minutes.
  The next turn resumes the same session, so the agent keeps its thread.
- Restore only the active browser tab at startup. The other saved tabs
  show a blank page and their host name until they are shown or used.
- Keep only the latest 50 messages of agents that are not open. Each
  snapshot from main holds the whole thread, and opening an agent reads
  its latest page again.
2026-09-23 14:01:23 +02:00
NB 158fd72fb2 Add shared-component OpenBot web MVP (#684)
* feat: add shared-component web MVP

* fix: resolve web MVP CI failures

* fix: release disconnected browser views and validate snapshots

* fix: clear web approvals when their turn ends

* refactor(ui): share conversation components and preserve styles

* style: format the shared UI preload rule

* fix: release a web live view detached while its stream opens

stopLiveView during the open handshake detached the view before its
handle existed. The handle's close then did nothing, so the host kept
the stream and the browser view session open.

The handle now closes its own stream and session, once, whether or not
it is still the current view.

* fix: keep the web host status and approval answer correct

The status and model read that starts when a host goes online went
through workspace.run, which drops a task while another runs. A connect
started by the user is still running at that moment, so the header kept
the connecting status with no models.

The approval answer matched only the agent. It now uses the same
agent and thread match as the displayed approval, so a decision cannot
go to a pending request from another thread.

* docs: record why the web client has no remote desktop

* fix: show one sign-in error with its wait time in the web client

A refused email code request set the login issue and also threw, so
the form added a second generic alert. The Retry-After wait was also
dropped, so the send button stayed active during the wait.
2026-09-23 14:00:22 +02:00
NB 82a7cd2cb5 Let Google sign-in pass with the native browser identity (#559)
* Let Google sign-in pass with the native browser identity

* Serve WhatsApp its allowlisted identity per site

* Read per-site browser identity from a policy table

* Remove dead identity exports after the policy table

* Drop the Google block banner now that login passes

* Let the site table own header rewrites

* Verify debug port ownership against the recorded process tree
2026-09-17 00:02:14 +02:00
NB 943060937a feat(opencode): Go key support, key dialog refresh, row badge (#523)
* fix(dev): strip Electron runtime flags from spawned children

* feat(opencode): support Go subscription key instead of Zen

* refactor(settings): minimalist OpenCode Go key dialog

* feat(settings): key tier badge and Reconnect opens key dialog

* feat(dev): exact role matching in dev-automation

* refactor(contracts): free-tier ids as explicit product rule

* fix(settings): keep keyless Connect/Restart, reconnect from key dialog

* fix(settings): keep Sign in beside Connect/Restart on OpenCode row
2026-09-15 17:12:01 +02:00
NBandClaude Opus 5 dc51a978c2 Stop the two animations that burn idle CPU, and add dev:cpu to measure it (#513)
* Stop the two animations that burn idle CPU, and add dev:cpu to measure it

Users reported high CPU usage when the app does nothing. A profile of an idle
window found 17.4% of one core, and it did not fall when the window lost focus
or was minimized.

Two causes, both animations that nobody can see:

- Every sidebar row shows an `idle` avatar, and the sidebar is not virtualized,
  so each row morphed an SVG for as long as the list was on screen. `idle` now
  rests with `hover` and plays on pointer or focus. `working` and `connecting`
  still play, because motion is the only sidebar signal that an agent runs.
- A finished image generation leaves its canvas mounted at `opacity: 0`, and the
  glow inside it kept two infinite keyframes on `mask-size` and `mask-position`,
  which the compositor cannot take. One old image repainted every frame for as
  long as the conversation stayed open.

`bun run dev:cpu` is the read-only command that found them. It reads cumulative
CPU time from CDP and from `ps` and reports the difference over a known
interval, because `ps -o %cpu` is an average over process lifetime and would
give a confident wrong answer. It adds no IPC channel and ships nothing into
the product.

Measured on one machine, idle, with 4 agents in the sidebar:

  focused    17.4% -> 0.1%   (renderer 11.3 -> 0, gpu 5.9 -> 0.1)
  blurred    18.5%
  minimized  16.3%

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Keep a dev:cpu report inside the report directory

`--out` resolved against the report root but did not stay there: an absolute
path or a `../` escaped it and the report was written wherever it landed. The
README already said the flag writes under `.openbot-build/dev-automation/cpu/`,
so this makes the code agree with it.

This is not a privilege boundary. The only caller is the developer typing the
flag, who has a shell already. It stops a mistyped path from leaving a report
where nobody looks.

The test is for a `..` path segment rather than a `..` prefix, so `..foo.json`
stays a legal file name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Share the screenshot path containment with the CPU report, drop a dead export

Two findings from the code review of 56401c10.

P1. The first containment fix was lexical only, and it duplicated half of a
check this directory already had. `resolveScreenshotPath` guards the same
read-only contract and also walks the path for symbolic links, which a lexical
test cannot see: a link inside the report directory still sends the write
outside it. The shared part is now `resolveWritablePath`, and both the
screenshot and the CPU report go through it. `--out` is resolved before
sampling starts, so a rejected path costs no run.

`--compare` still resolves against the working directory. It only reads, it
validates the shape of what it parses, and the usual call passes the path an
earlier run printed.

P3. `cpuPercentBetween` and `ProcessCpuUsage` had no caller but their own
tests: `summarize` uses `cpuSecondsBetween` directly. Both are removed, and
the process arrival, departure and counter-reset cases move onto `summarize`,
which is the path that builds a report.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 12:34:16 +02:00
NBandClaude Opus 5 a5579047f8 feat(dev): make worktree dev stacks and ports conflict-free (#297)
* feat(dev): make worktree dev stacks and ports conflict-free

Several worktrees run dev on this machine at once. Port selection was a
probe followed by a bind seconds later, and nothing was written down in
between, so two `bun run dev` calls started together both won 5173 and
the unsuffixed `OpenBot Dev` profile with it - two Electron clients
writing one SQLite file.

- `scripts/dev-automation/port-allocation.ts` puts read, choose and
  publish behind one machine-wide lock (`wx` create, stale break,
  holder-matched release).
- `scripts/dev-automation/stack-registry.ts` records every port and pid
  a stack holds. `findAvailablePort` skips a published port without
  probing it, because a stack that won a port has not bound it yet.
- `scripts/dev-stack.ts` adds `dev:status` and `dev:stop`, which read
  pids from the registry instead of matching a process name. This
  worktree is the default scope; `--pid=` and `--all` are explicit.
- `scripts/dev-storybook.ts` allocates Storybook through the same
  registry with `--exact-port`, so the announced port is the real one.
- A second stack in one worktree is refused unless `--force`, and
  `--isolated` keys the profile to the worktree path.
- `registry-files.ts` holds the owner-only directory checks, the atomic
  write and the recycled-pid liveness both registries need.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): prove a pid is ours before the stop command signals it

Four review findings on the worktree dev-stack work, and what each cost.

The port allocation lock created the file and then wrote it, so a waiter
could read it in the moment it held nothing, take it for abandoned and
break it - two allocators in the critical section, which is the collision
the lock exists to stop. The holder now goes into a staging file that is
published with `link`, atomic and EEXIST when taken. An unreadable lock
is no longer breakable on sight either: it must also have sat there past
the stale window. And a waiter that runs out its wait beside a live
holder now fails with that holder's pid instead of helping itself.

`dev:stop` signalled anything `kill(pid, 0)` said was taken. Pids get
recycled, so that is how a stop command sends SIGTERM to a stranger's
program. `verifyRecordedProcess` answers live, gone or unverified - and
unverified, a pid this machine cannot date, is not permission to signal.
What it refuses to touch it reports, leaves running, keeps in the
registry and exits non-zero for; `bun run dev:forget` drops such a record
once the developer has dealt with the process. Same reasoning one level
down: a process group that outlived its recorded leader is named in the
report rather than signalled, because the pgid belongs to nobody now.

A record was pruned as soon as its recorded pids were gone, which freed
a port that a surviving group still held - electron-vite exits and the
Electron it started keeps the renderer port. Liveness now includes the
group.

`dev:status` reports every stack, since the one holding the port this
worktree wanted is a sibling's. `stop` and `forget` stay on this
worktree.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): serialize recovery of a stale port allocation lock

Breaking a lock is an unlink, and unlink cannot be made conditional on
what the path holds. Two waiters that read one dead holder both deleted:
the first published a lock of its own and started allocating, and the
second deleted that replacement and started beside it - the same two
allocators on one set of ports that the lock exists to prevent.

Recovery now happens behind a second file. Whoever takes it reads the
lock again before deleting anything, so a waiter that arrives late finds
the replacement instead of the dead holder it saw a moment ago. Nothing
ever breaks that second file: it is held across a few syscalls with no
await between them, and a leak costs recovery rather than correctness -
allocators wait, then fail with a message naming the file.

Age no longer breaks a live holder's lock either. An allocation is
milliseconds of work, so a lock held for a minute means something is
wrong, but wrong is not finished: the holder may be stopped in a debugger
and about to step into the critical section. The developer gets an error
naming the pid instead. What replaces the age arm is evidence rather than
patience - `verifyRecordedProcess` dates the holder, so a pid recycled
since the lock was taken reads as gone and one recycled pid can no longer
wedge every dev start on this machine.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): make port lock ownership a generation, not a path

Recovering a lock whose holder had died still had to delete the path, and
`unlink` cannot be made conditional on what the path holds. A recoverer
that read a missing or dead lock could therefore remove a lock another
allocator had published in the meantime, and both would allocate ports at
once - the collision the lock exists to stop.

Taking the lock now means creating the next numbered lock file with an
exclusive create, so ownership is only ever decided by a step the kernel
makes atomic. A dead holder's lock is superseded rather than removed, and
the judgement about it decides when to move on, never who won. The break
lock this replaces is gone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): never remove a port lock another allocator may still take

The generation an allocator asks for is the highest lock file it saw plus
one, and the scan and the exclusive create are separate steps. Sweeping the
superseded lock files away therefore let the numbering run backwards over a
plan already made against them: recover the lock a dead holder left at 1,
take 2, release 2, and an allocator arriving now finds an empty directory
and takes 1, while one that read the directory earlier still holds a plan
for 2 and no longer collides with anybody. Both then allocate ports.

A lock file is now removed by nothing but its own live holder, releasing it.
An allocator that read our lock as the highest generation read it as live,
so it waited instead of planning a generation above it - nothing holds a
plan our removal could let back down. The lock a crashed holder left behind
stays where it is; nothing reads it, and it is what keeps the numbering from
coming back down to it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): release a port lock by renaming it, never by deleting it

Deleting our own lock on release still let a generation be handed out
twice. The file need not be gone when another allocator *lists* it, only
when it reads its contents: an allocator that listed our live lock and then
found nothing there reads a null holder and a null age, judges it
abandoned, and plans the generation above it - while the number it left
behind goes to the next arrival, which no longer collides with that plan.
Both then allocate.

So no lock file is ever deleted now. Releasing renames it to `.released`,
which gives up the claim in one step while the generation stays spoken for,
and both suffixes count towards the numbering. A lock a crashed holder left
behind is superseded where it lies. The files are tens of bytes in the
per-user temporary directory, and the two registry readers beside them
filter `.json`, so nothing else sees them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): mark a released port lock in place, keeping its path occupied

Renaming the lock aside kept its generation spoken for but freed the path,
and the path is what `link` arbitrates over. An allocator that planned a
generation and was descheduled before creating it could therefore create it
after its previous holder had released, and enter beside whoever had since
taken the generation above.

The rule is now that once a lock path exists it stays, and nothing ever
frees it. A lock's state lives in its contents: releasing writes a released
marker to a staging file and renames that onto our own lock path, which
replaces the contents in one step and leaves the path occupied on both
sides of it. Reading a lock is a tri-state - claimed by a holder, released,
or unreadable - and an unreadable one is left alone for the stale window to
recover, because that path has to stay occupied too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): never delete a stack record from the read that judged it

`readDevStackRecords` and `readDevInstanceRecords` read a record, decided
it was dead, and then removed its path. The file can change in between: a
supervisor publishes a detached child and is killed a moment later, and a
reader holding the older view deletes the version *with* the child. The
child keeps the ports and nothing records them, which is the collision the
port lock exists to stop. A record this checkout cannot parse is the same
hazard without a race - a sibling worktree on a newer branch writes a
schema this one has not learned yet, and its stack is live.

So reading only filters. A dead record's ports are free from the first
read that finds it dead, and `bun run dev:forget` is what removes the
file, reading past the liveness filter to reach records no other command
reports.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): date an instance record before dev:forget deletes it

`forgetDevStack` matched instance records by pid alone. That was survivable
while a dead stack record was pruned by the next read; now the record waits
on disk for `bun run dev:forget`, the pids it names have had every chance
to be recycled, and an instance record lives at `<service>-<pid>.json`, so
the app that takes a pid writes over the record of the app that had it.
`dev:forget` on the old stack deleted a running app's record, and it left
`dev:automation instances` until its next start.

`claimOnDevInstance` answers whose the record is. Each instance record
dates itself - its `startedAt` is when that instance published - so
`verifyRecordedProcess` holds it against the start time the kernel reports
and a live instance is never a dead stack's, whatever pid it holds. The
worktree is checked too: it is the cheaper half of the same question and it
still answers where a pid cannot be dated. A record of this worktree that
cannot be dated is kept and reported rather than guessed at.

No timestamp is carried from the supervisor through electron-vite into the
Electron main process to do this: the spawn and the publish are two events
and would date differently.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): prevent isolated worktree profile collisions

Use prefixed full SHA-256 identifiers while preserving numeric profile ids. Cover the reproduced five-digit collision and remove repeated lock and cleanup commentary.

Validation: regression test failed before the fix; 31 focused tests pass. Lint passes with eight existing mobile warnings; typecheck and isolated runner dry-run pass.

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 19:07:25 +02:00
NBandClaude Opus 5 799de8791a feat(dev): AI automation bridge over CDP plus ts-log logging package (#220)
* feat(dev): AI automation bridge over CDP plus ts-log logging package

- packages/logging: ts-log Logger with secret redaction, covered by tests
- scripts/dev-automation: snapshot/screenshot/click/type against the running dev app
- migrate console.* in main/backend/scripts to the redacting logger

* fix(dev-automation): drive the main window, not helper popups

CDP lists Dynamic Island surfaces in arbitrary order; prefer the bare
app URL so snapshot/screenshot/act always target the main window.

* docs(agents): point e2e smoke checks at dev:automation

* fix(review): bundle logging, stderr JSON, UA guard, cycle-safe logs, injectable test loggers

- main build bundles @openbot/logging like contracts (packaged startup)
- dev-automation CLI logs to stderr, stdout keeps pure JSON
- CDP refuses non-OpenBot targets; main-window pick covered by tests
- logging handles bigint/circular values without throwing
- team-api-server and dynamic-island accept an optional logger;
  console spies replaced with injected or observed loggers

* fix(review): recipe bump, catalog literals, explicit port for mutations

- bump remoteDesktop.recipeVersion for the touched runtime scripts
- ts-log/playwright-core as literals: single-workspace deps per catalog rule
- click/type refuse a defaulted port; name the instance with --port=

* fix(review): redact serialized payloads, gate log levels, enforce noConsole

- redaction covers a payload that arrives as one string: quoted values are
  consumed whole, `{"apiKey":"…"}` and `set-cookie:` shapes match, and a
  scheme-prefixed `Authorization: Basic …` no longer leaks its base64
- redaction is idempotent, so a value passed through `toLogValue` and then
  formatted no longer grows a stray `]`
- error message and stack are redacted at conversion, not only at format time
- logger honours a level threshold (`info` by default, `OPENBOT_LOG_LEVEL`
  lowers it); dev-automation asks for `debug` to keep renderer console output
- Biome `noConsole` enabled for src, scripts and packages so the migration
  cannot regress
- dev-automation: mutation gate extracted and tested, `ForeignBrowserError`
  sentinel instead of message matching, one role list with the type derived
  from Playwright, unused `waitForRole` dropped, `--text=` can clear a field
- remote-debugging port validated through `readDevelopmentRemoteDebuggingPort`
  so main and automation agree on the range
- docs: restore rule 7 indentation, document the level and the lint rule

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev): tighten automation target selection and screenshot paths

Addresses the review findings on the CDP bridge and unbreaks CI.

- Diagnostics no longer print page titles or full URLs. `describeTarget`
  reduces a target to origin + path for loopback pages and to
  `scheme//host (external)` for anything else, so a visited page's query
  string never reaches the log.
- `pickMainPage` could latch onto an embedded browser page. `isMainAppUrl`
  now requires a loopback http(s) origin, no `surface` query and the bare
  app route, and `findMainPages` refuses to guess when two candidates
  match.
- `screenshot --out` accepted any path with no mutation flag.
  `resolveScreenshotPath` keeps the destination inside the build directory
  and requires a `.png` name.
- Revert the cosmetic logging edits to the three recipe-guarded runtime
  scripts and `recipeVersion` back to 8: the bump guard fired on them,
  and a bumped recipe with a stale `artifactRelease.inputDigest` fails
  `parseNativeRuntimeLock` and 10 tests. Those files are exempted from
  `noConsole` via an enabling override instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(dev): make automation pick the right dev instance per worktree

Several worktrees run `bun run dev` on one machine, and only the first
gets 9333: `dev-services` walks the port upwards, so the second instance
answered on a port nobody wrote down and `dev:automation` drove the
wrong app.

- Each dev app and test client now publishes its worktree, profile,
  renderer port, debugging port and pid to a registry in the per-user
  temporary directory, and removes the record on shutdown. Reading prunes
  records whose process is gone, so a killed instance never keeps
  offering a port another one has taken.
- `dev:automation instances` lists what is live. Resolution prefers the
  record of the worktree the command runs in, refuses to guess between
  two, and accepts `--instance=<id>`, `--port=` or `--service=`.
- The mutation gate now asks whether the instance was *named* rather than
  whether a port was typed. Another worktree's app stays readable and
  is never clickable.
- Two review findings on target selection: the snapshot document carried
  a raw `page.url()`, which on the app route can hold an OAuth code, so
  it goes through the extracted `describeTarget`; and a visited local
  site in an embedded browser view wore the same loopback origin and
  bare path as the app, so a page is only driven when it carries the
  `window.openbot` preload bridge and, when the registry named one, the
  expected renderer port.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(dev): let automation drive any dev window on purpose

The main-window restriction was a safe default that had turned into a
limit. Dev is where every flow has to be testable, embedded browser
views and Dynamic Island surfaces included.

- `dev:automation pages` lists every CDP target with an index and a
  sanitized description.
- `--page=<index|url-substring>` drives any of them, overriding both the
  bare-route filter and the preload-bridge probe. An empty selector is
  refused rather than matching everything.
- Aiming at nothing still resolves the app window, and an ambiguous
  selector prints the target list instead of guessing.

The guards that stay are the ones about hitting the wrong process, not
the wrong page: `--allow-mutations` and an instance that was named
rather than inferred.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(logging): bound the redaction patterns and redact snapshot text

Four review findings, and one the third one uncovered.

- `sk-` and friends matched inside ordinary words, so `risk-register`
  logged as `ri[redacted]` and erased the part naming what failed. The
  provider prefixes now need a token boundary.
- A quoted JSON `"key"` is redacted in the text fallback too, for a
  payload too malformed to reparse structurally.
- The 100 KB reparse cap is gone: a long body is exactly where a secret
  hides, and truncation keeps the first characters, which were the
  unredacted ones.
- Removing that cap surfaced why it was there. `SECRET_LABEL` and `EMAIL`
  both had unbounded affix runs, so every position in a long payload
  consumed the rest of it and backtracked: 200 KB took 9.6s. Bounded, the
  same payload takes 150ms and 2 MB takes 1.4s.
- The snapshot document carried the page title and the accessibility tree
  verbatim, so a screen showing an API token exported it on stdout. Both
  go through `redactText` before truncation, so a secret cannot survive
  in the part that is kept.
- The registry record is written to a sibling and renamed into place. A
  plain write truncates first, and a reader hitting that window deleted
  the file as corrupt, leaving a freshly started instance undiscoverable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(logging): stop treating prose as a credential assignment and bound conversion depth

- CREDENTIAL_ASSIGNMENT required an explicit = or : separator; bare whitespace
  turned `SKILLS_ADMIN_TOKEN is missing` into `SKILLS_ADMIN_TOKEN [redacted] missing`.
- convertValue now stops at depth 32, so a deeply nested external payload cannot
  overflow the stack and replace the failure the caller was reporting.
- dev:automation instances redacts profile and projectRoot on its stdout JSON,
  the one registry field that did not pass through the logger.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(dev-automation): add --wait-for, warn on cross-worktree ports, tighten redaction

- --wait-for=<role>,<name> settles on an accessible target before a capture and
  after a click or a keystroke, so a flow no longer needs a snapshot loop.
- An explicit --port= stays authoritative, but says whose worktree it resolved
  to when that is not this one; a mistyped digit was silent before.
- Registry directory 0700 and records 0600, created exclusively so a planted
  staging path cannot redirect the write.
- Basic/Digest/Token only redact inside an Authorization context, so
  'Token validation failed' survives; Bearer still matches anywhere.
- Error names, object keys and the String() fallback pass through redactText;
  conversion is exception-safe and emits [unserializable] instead of throwing
  from inside the logger.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev-automation): contain screenshots against symlinks and fail closed on an unsafe registry

- resolveScreenshotPath refuses a symlink anywhere between the build root and
  the destination; the containment check was lexical and page.screenshot
  follows links, so a read-only command could write outside the directory.
- The screenshot response reports a workspace-relative path, dropping the home
  directory prefix, and refuses a name whose redacted form differs rather than
  returning one the caller cannot reopen.
- Publishing a dev instance verifies the registry directory is owned by this
  user and unreachable by other accounts, instead of swallowing a failed chmod.
  A registry someone else can write lets them choose which CDP port a mutation
  command trusts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev-automation): validate the registry directory on read as well as on write

Only the writer failed closed on a directory other accounts can reach, so a
reader that never publishes trusted whatever it found there. A planted record
naming this worktree, a live pid and an attacker's CDP endpoint would have been
classified as the local instance a mutation may drive.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev-automation): hide non-app loopback paths and aim by CDP target id

A loopback origin does not make a page the app: an embedded view can serve a
callback on 127.0.0.1 whose path carries the code as a plain segment, which no
redaction rule recognizes. `describeTarget` now prints a path only for the
app's own routes and collapses anything else to its origin.

Aiming moves from an array index to CDP's target id. Each command opens its own
connection, so a window closing in between shifted every later position and
`--page=1` could drive a target nobody printed. Verified against a live dev
instance: a stale id now refuses instead of drifting to another window.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev-automation): redact renderer console before truncating, and verify instance process identity

Two review findings on the dev automation layer.

The renderer console handler sliced the message to 500 characters before
handing it to the logger, which redacts and only then truncates at 2000. A
cut could hand the log a prefix of a token short enough that no redaction
rule recognizes its shape - so the full text now goes to the logger.

`process.kill(pid, 0)` proves only that something holds that pid. A dev
instance killed with SIGKILL leaves its record behind, and a recycled pid
made that record - with its debugging port - look like this worktree's live
app, which is the one match `click` and `type` accept. Liveness now also
compares the process start time from `ps -o lstart=` against the record's
`startedAt`, and two live records claiming one debugging port keep only the
newest, which is what still fails closed where `ps` is unavailable.

Watched both new guards fail: removing the start-time comparison reds
"rejects a pid that was recycled after the record was published", and
returning the records unfiltered reds the port-collision test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(dev-automation): keep a one-time code out of the snapshot document

`ariaSnapshot` prints what a control holds, and `redactText` cannot recognize
a login code: it is a handful of characters with no label and no secret shape.
The snapshot goes to stdout and lands in an agent transcript, so a code typed
by `type` without `--submit` left the machine.

`redactSensitiveSnapshotValues` now blanks what was entered into any node
whose accessible name reads as a one-time code, password, token or
credential - the inline value, and the unnamed text anywhere in its subtree.
Named nodes inside that subtree survive, because a developer still has to see
the control to aim `type` at it.

The subtree half is the part that matters for `OtpInput`: it clears the native
input on every keystroke and rebuilds the code as visible characters, so the
code never is the textbox value - it is loose text under the fieldset. That
fieldset was unnamed, leaving nothing for either consumer to recognize, so it
now carries `aria-label="One-time code entry"`: assistive tech announces the
context those characters belong to, and the redactor knows the subtree.

Watched all three guards fail: neutering the sensitive-name pattern reds both
snapshot tests, dropping the subtree rule reds the loose-character one, and
removing the fieldset name reds the OtpInput contract. Verified against the
live dev app that an ordinary textbox value still prints.

Surfaces touched: desktop renderer (OtpInput), dev automation scripts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 18:38:52 +02:00