6 Commits
Author SHA1 Message Date
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
Aleksander DygońandClaude Opus 5.5 f6c76703bf Stop the whole Windows process tree of a dev service (#9692)
On Windows, the dev runner and `dev:stop` stopped a service with
`process.kill(pid)`. That stops only the launcher (`bun run ...`), so Vite,
workerd and Electron continued to run and kept the dev ports.

- `signalOwnedProcess` with `scope: "group"` now runs `taskkill /pid <pid> /T /F`
  on Windows while the launcher still holds the tree, and once more when the
  first run fails part-way, as `src/backend/windows-process-tree.ts` does.
- A pid's liveness on Windows uses signal 0. Before, a recorded pid was always
  "running" until the time limit.
- On Windows, `dev:stop` stops the service trees before the supervisor. A
  signal ends the supervisor without its cleanup, and its launchers could then
  leave their trees with no parent. macOS and Linux keep the old order.

Fixes #9421

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 00:09:51 +01:00
NBandClaude Opus 5.5 c3c9c6f5cd Connect to a remote server faster and sync the rest later (#4360)
* Connect to a remote server faster and sync the rest later

Measure the remote connect and sync with `bun run perf:remote`, then
remove the serial waits that it found:

- Desktop reads the host compatibility once after a WebRTC connect.
- The first workspace reads go beside the compatibility read when the
  host protocol of the last visit is known.
- Desktop and web show a saved workspace view (agents, models, sidebar
  layout and channel names, no message text) while the host connects.
- Queue reads and panels load after the workspace is ready.
- The agent list waits only until the host loads its agents.
- Web: a server switch uses the online status connection of the target
  server, and the old session ends in the background.
- Fewer effects run again while a workspace loads.

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

* Do not export the web connect types that no other file uses

knip reported WebHostHandover, WebEarlyReads and WebConnectOptions as
unused exports.

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

* Keep only the latest remote sync mark of each name

The browser keeps User Timing marks until code clears them. A web tab
that reconnects its status connections for days added more marks on
each connect.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 15:46:43 +01: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
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 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