Repository navigation
feat: run omp-web on Bun instead of Next.js - #344
Conversation
|
Important Review skippedToo many files! This PR contains 354 files, which is 254 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files.
|
Code Review Roast 🔥Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. The incremental change just bumps the channel buffer to fit image-prompt echoes and teaches RpcProcess to recover cleanly if a resync cuts a chunk sequence mid-frame. The tests prove both cases. Sensible, minimal, and correctly handled. 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. Files Reviewed (6 files)
Previous Review Summaries (8 snapshots, latest commit ebabe2c)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit ebabe2c)Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. The incremental change is a one-line security fix: Traefik sends 📊 Overall: Like a seatbelt that actually clicks — small, unglamorous, and exactly what stops you from flying through the windshield. Files Reviewed (2 files)
Previous review (commit c3fdac2)Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. The incremental change is a documentation-only addition to README.md about macOS 15 local network permission — nothing to roast here. 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. Files Reviewed (1 file)
Previous review (commit 51e40f4)Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. The incremental changes fix the provider usage header scrolling behavior and simplify self-update path resolution without introducing new issues. 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. Files Reviewed (4 files)
Previous review (commit e4452c2)Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. The incremental changes fix the provider usage header scrolling behavior and simplify self-update path resolution without introducing new issues. 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. Files Reviewed (4 files)
Previous review (commit 1325c4c)Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. The incremental changes add binary support, tighten port validation, refactor launcher security checks, and harden the static file serving without introducing new issues. 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. Files Reviewed (45 files)
Previous review (commit e31e085)Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. All three previous findings — the 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. Files Reviewed (10 files)
Previous review (commit bbfd70e)Verdict: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)
🏆 Best part: The test suite passes — 1985 pass, 0 fail. I'm almost disappointed; I had my flamethrower warmed up and everything. 💀 Worst part: 📊 Overall: Like a first pancake — the shape is mostly right, but it needs one more pass on the griddle. Fix these issues in Kilo Cloud Files Reviewed (3 files)
Previous review (commit 260ffda)Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. Files Reviewed (1 files)
Reviewed by free · Input: 29.9K · Output: 2.2K · Cached: 263.4K |
| let stat: Stats; | ||
| try { | ||
| // statSync and Bun.file follow symlinks: serve a link only when its target stays inside the (real) base. | ||
| if (!realpathSync(file).startsWith(realpathSync(base) + path.sep)) continue; |
There was a problem hiding this comment.
🔥 The Roast: realpathSync(base) inside the serveFile loop is like asking for directions to the same restaurant every time you pass a landmark. base never changes during the loop, so you're hitting the filesystem for the same resolved path on every iteration. Not going to melt the server, but it's unnecessary syscalls on every file request.
🩹 The Fix: Hoist const realBase = realpathSync(base) out of the for loop, then compare against realBase + path.sep inside.
📏 Severity: nitpick
| db.exec("PRAGMA journal_mode = WAL;"); | ||
| db.exec("PRAGMA busy_timeout = 5000;"); | ||
| db.exec("PRAGMA synchronous = NORMAL;"); | ||
| try { | ||
| migrateUsageDatabase(db); | ||
| } catch (err) { | ||
| db.close(); | ||
| db.close(true); |
There was a problem hiding this comment.
🔥 The Roast: db.close(true) in the migration catch block with no try/catch is like burning down the restaurant to kill a cockroach, then forgetting why you're homeless. If closing the database throws, you've just masked the original migration error — the very thing you were trying to report.
🩹 The Fix: Wrap db.close(true) in its own try/catch so the migration error propagates regardless.
📏 Severity: suggestion
| // below or beside them skips the gate. /api/hosts/link and its blob/ subpath | ||
| // authenticate the host's bearer token themselves before they read any body | ||
| // (lib/hosts/hub.ts). | ||
| export const UNGATED = /^\/(?:assets\/|(?:favicon\.ico|icon\.svg|icon\.png|icon-192\.png|badge-96\.png|sw\.js)$|api\/hosts\/link(?:\/|$))/; |
There was a problem hiding this comment.
🔥 The Roast: The comment says "The file names are exact (anchored), so no path below or beside them skips the gate" — but assets/ is conspicuously unanchored. /assets/anything still walks right through. You locked every window but left the front door open with a "please rob me" sign.
🩹 The Fix: Either anchor assets/ in the regex or update the comment to admit assets/ is intentionally a prefix match.
📏 Severity: nitpick
Multi-model review (8 models) and follow-up fixesEight independent reviewers ran the same adversarial review on What held up
Findings and fixesBehaviour vs Next
Security
Packaging and licences
Dev
Visual parity (audited separately against the Next build: screenshots, layout shift and first paint)
Tests
Not verified
|
e4452c2 to
51e40f4
Compare
ebabe2c to
b62ed31
Compare
`npm test` is now `bun test --parallel --timeout 30000`. Tests load TS and tsconfig paths natively, so jiti, the strip-types flags and syncBuiltinESMExports are gone from the suite. Baseline before the switch (node --test, 8691e96): 1974 tests, 1962 pass, 0 fail, 12 skip. After: 1962 reported tests across the same 206 files, 1950 pass, 0 fail, 12 skip. Bun reports the 12 nested t.test() subtests inside their parent test, so the count is 12 lower; a failing subtest still fails its parent. - jiti codemod: createJiti and jiti.import become dynamic imports; moduleCache:false becomes ?fresh=N imports. - Builtin mocks go through tests/mock-builtin.mjs (mock.module); Bun's mock.restore() does not undo mock.module, so the helper re-registers the real exports in t.after. - tests/setup-dom.mjs drops its teardown and adds the DOM globals the tests name; Testing Library is imported dynamically after it. - bin/*.js tests spawn node; TS child scripts run on Bun. - isExecutableFile (omp-web-systemd) and isExecutable (linux-tray) call accessSync in try/catch: Bun's accessSync returns null, not undefined.
Bun's fs.watch drops an event that arrives within ~2 ms of the previous one, so a rapid second save never reached the file viewer. Re-stat once 50 ms after the last event (cleared on unsubscribe) and report a deletion once.
…ted dev pages Bun's router matches the raw request path while proxy() and the handlers read the normalized request.url, so /api/files/../../assets/x/<path> reached the files handler with no cookie and no origin check. Each route now re-matches the normalized path (URLPattern) after the gate and takes its params from it, else 404. Also: login redirects use a relative Location (Bun's request.url is always http://); Bun's default 128 MiB maxRequestBodySize replaces MAX_SAFE_INTEGER; the SPA fallback gets the index no-cache rule; /api is a 404, not the SPA; dev pages fetch the HTML import from /__omp_dev_index so they pass the gate and renderIndex, with blob: scripts allowed for HMR; dev.ts re-runs itself once with the OMP_WEB_PUBLIC_* values Bun inlines from its startup environment.
…ct-hooks register() installs the SIGINT/SIGTERM exits before its first await. The launcher logs and retries every second when Bun cannot be resolved for an update restart instead of spinning. eslint-plugin-react-hooks is pinned to 7.0.1: 7.1 reports 19 new errors in existing components.
hooks/useDictation.ts imports isSttAfter from lib/stt.ts, which also held
readSttConfig. Bun's dev bundle does not tree-shake, so it shipped
process.env.OMP_WEB_STT_{ENDPOINT,KEY,MODEL} to the browser. readSttConfig
and SttConfig move to the server-only lib/stt-jobs.ts; lib/stt.ts keeps
only what the browser shares.
npm run smoke [-- --package <dir>] starts the launcher on a free port with a throwaway HOME and checks: no process.env in the shipped dist/ JS, the SPA (200, id="root", no-cache), a hashed asset (immutable, gzip), /api/hosts JSON, /api/events open past Bun's 10 s idle default, and a clean stop. verify-pr runs it on the repo and on a packed global install (ubuntu and windows); publish runs it after the build; release:check ends with it. package.json files ship app/api, server, dist, proxy.ts, instrumentation.node.ts and tsconfig.json instead of .next. Windows CI parses omp-web-service.ps1 and omp-web-tray.ps1 with the PowerShell parser, replacing the source-text regex test in lib/windows-service.test.mjs. Nix: the fonts patch is gone; the build and the launcher use the npm @oven/bun-<os>-<arch> binary (pinned 1.4.4; nixpkgs has at most 1.4.2), patched with autoPatchelf on Linux, with bun's postinstall skipped. The devShell gains bun. Unverified: nix is not installed here, so npmDepsHash still needs refreshing with `nix build .#default` on a machine with nix.
Next server-rendered the sign-in form on /login; the Bun SPA showed an empty page there until its bundle ran (about 3.1 s on Slow 4G). app/index.html now carries LoginForm's first render in a <template>, and the /login inline script swaps it in for the skeleton, so the form paints with the HTML and CSS (about 0.6 s). createRoot replaces it on mount. A test keeps the static copy identical to what LoginForm renders first. Until the bundle runs, the script stops Enter from submitting the static form (a native submit would reload /login and drop ?next=), and client.tsx hands a password typed into it to LoginForm, so nothing typed is lost.
bin/omp-web-host.js now only loads it through jiti, so a compiled binary can import the same CLI without jiti.
…tion start checkLaunchSecurity (bin/omp-web-options.js), openInBrowser (bin/network-addresses.js) and startProduction (server/app.ts) move out of bin/omp-web.js and server/main.ts unchanged, so a second entry can run them. The bind refusal test now runs the launcher instead of reading its source.
npm run build:binary [-- --target bun-<os>-<arch>] compiles server/binary.ts with the NODE_ENV=production define into release/ompweb-<os>-<arch>/, next to dist/, public/, the KaTeX CSS and fonts, the session-edit extension and the licenses, and archives it (.tar.gz; .zip for Windows). The binary runs the web server in-process with the launcher's flags, password and bind checks, plus ompweb host and ompweb hash-password, and serves from its own directory unless OMP_WEB_PACKAGE_DIR names another. npm run smoke now also starts ompweb host and checks that /api/sessions lists a fixture session through it; --binary <path> runs the same steps against a compiled binary.
In a compiled run (Bun.isStandaloneExecutable) /api/app-update reports installMethod "binary", selfUpdateSupported false and the release page as the update target, which Settings shows under a download message instead of "run this command". Preparing an app or omp in-app update answers 409 there: the update worker needs Node and an npm install, and started on the binary it would be a second ompweb. The binary smoke checks both.
…4 binary on PRs publish.yml cross-compiles linux-x64/arm64, darwin-x64/arm64 and windows-x64, smokes the linux-x64 binary with its own daemon, and uploads the archives to the draft release before the npm publish. verify-pr.yml builds the linux-x64 binary and runs npm run smoke -- --binary on it.
… CHANGELOG) The binary's tray and service-installer refusals now point at the README section by URL, since the release does not ship the README.
The cached real path went stale when a static directory was swapped while the server ran (a link moved to a new release), and every file under the new target answered 404. realpathSync per request costs about a microsecond.
`ompweb -p abc` (or PORT=abc) printed a Node error naming NaN from the npm launcher and a minified stack trace from the binary. parseLaunchOptions now reports the bad port, and both entries print one line and exit 2.
Imports app/client.tsx on /login with a typed static field and checks the
rendered LoginForm's value; removing initialPassword={typedPassword} fails
it.
The omp update check now answers selfUpdateSupported (false in the compiled binary, whose in-app updates answer 409), and Settings → System shows the Update now button only when it is true. The omp update command and its Copy button stay.
The ompweb update toast and Settings → System showed the release URL as a
command, with Copy ("Command copied") and, in the toast, "Update and
restart". For installMethod "binary" both now show it as a link that
opens in a new tab, with neither button. The toast body moved into
components/UpdateToast.tsx, shared with the omp update toast, whose Update
now button now also needs selfUpdateSupported.
They moved there from AppShell.tsx in f94afd1, which left this source-text check failing.
…ributes The archives carried only ompweb's, the fonts' and KaTeX's licenses, while the binary embeds Bun (JavaScriptCore and WebKit are LGPL-2) and ~40 npm packages (web-push is MPL-2.0, jszip MIT or GPL-3.0), and dist/ bundles ~160 more. Both builds now take Bun.build's metafile: build-client.ts records the client's packages in build/client-packages.json, and build-binary.ts copies every bundled package's LICENSE/NOTICE/COPYING files into licenses/<name>@<version>/, adds Bun's license (vendored as scripts/bun-LICENSE-1.4.4.md, required for the running Bun's version) and writes licenses/README.md listing each package's declared license.
…indows binary Bun's default x64 runtime needs AVX2, so the linux, darwin and windows x64 binaries crashed on older CPUs (and darwin-x64 under Rosetta 2). publish.yml now builds the -baseline targets, which build-binary.ts names without the suffix, so the archive names stay ompweb-<os>-x64. Both workflows run scripts/build-binary.ts after their npm run build instead of npm run build:binary, which rebuilt the client per target. verify-pr.yml smokes the binary on Windows too (ompweb.exe). On Windows build-binary.ts archives with System32's bsdtar, since a Git Bash GNU tar on PATH makes no zip and reads D:\ as a remote host.
A stand-in omp now answers the version and update checks and records the arguments of every run. The smoke opens the fixture session and asserts that omp got --extension with this install's own lib/omp/session-edit-extension.mjs, which in the binary only resolves through local-host.ts's fallback: without it omp gets /$bunfs/omp/session-edit-extension.mjs, and the step fails. The host now links as online, and the binary step also checks that the omp update check answers selfUpdateSupported false.
… and archive notes CHANGELOG: browsers older than Safari 16.2 or Chrome 111 lose the color-mix() colours, which Next's targets left out too. server/app.ts says that no test reaches handle()'s throw path (dispatch already turns a throw into a 500). The README and publish.yml no longer claim the x64 binaries run under Rosetta 2, which nobody checked. The plan's Bun built-ins table gains the metafile row and the Windows bsdtar note.
2e66a50 said Bun's default x64 runtime needs AVX2. For Bun 1.4.4 it does not: @oven/bun-{linux,darwin,windows}-x64 and their -baseline packages are the same bytes, and the compiled binaries match. Naming -baseline keeps a later Bun from shipping its -modern runtime instead.
Its plugin writes Tailwind's CSS (preflight included) into dist/, but the metafile never names tailwindcss, so licenses/ left it out.
lib/api-contract.test.mjs no longer greps components/UpdateToast.tsx for four string keys; components/UpdateToast.test.mjs renders the versions and the Copy label, and now clicks Copy and checks the clipboard and the "Command copied" toast (dropping that toast fails it).
… never the module URL
… on WebSocket upgrades)
b62ed31 to
a51025b
Compare
…isolate RPC ids (#363) Three Codex findings in the code from #339, #342 and #344. npm start now sets OMP_WEB_PORT/OMP_WEB_HOSTNAME from the bound address, so the local daemon links. Archiving a remote session is refused (501 remote_unavailable; the menu item is disabled), because the archive browser could not restore it. Each RpcProcess uses its own request id prefix, so an adopted child's late answer to the previous server cannot settle a new command; regression test included.
Summary
omp-web now runs on Bun instead of Next.js. Users see no change: URLs, ports, environment variables, the password gate, the event stream, file access rules, the notification store and the update commands all behave as before.
Why: Next blocks the next step for remote hosts, moving the host link onto a WebSocket, because a Next route cannot accept the upgrade. It also truncates proxied bodies over 10 MB, loads the startup code and the routes as separate module copies, and carries build traps. omp itself is a Bun program, and Bun covers most of what we installed separately.
server/serves the API, the static client and the SPA fallback from oneBun.serve. Route handlers stay atapp/api/**/route.tsand use plain WebRequest/Response;server/routes.tsmounts them, and a test fails when a route file and the table disagree.proxy.tsruns as the gate in front of every route, checked against the path the route actually matched.app/index.htmlandapp/client.tsxare built by Bun's bundler (scripts/build-client.ts, Tailwind 4 viabun-plugin-tailwind, self-hosted fonts).next/dynamicandnext/navigationare replaced bylib/dynamic.tsxandlib/navigation.ts.bun:sqlitereplacesnode:sqlite(existing stores open unchanged),Bun.Imagereplacessharpfor thumbnails, and Bun'sfetchhandlesHTTP(S)_PROXY/NO_PROXY, soundiciandlib/http-dispatcher.tsare gone.bun(pinned to 1.4.4) is a dependency, sonpm i -gandnpxbring Bun along. The Node launcherbin/omp-web.jsresolves that binary, including the@oven/bun-<os>-<arch>fallback when install scripts are disabled, and runs the server under it.ompweb host, the tray, the service helpers and the in-app update worker stay on Node; on Windows that keepsbun.exefree while npm replaces it.ompweb-<os>-<arch>archives (linux-x64/arm64, darwin-x64/arm64.tar.gz, windows-x64.zip): one program compiled withbun build --compile(npm run build:binary,scripts/build-binary.ts,NODE_ENVdefined as production) and the static files beside it. The x64 builds use Bun's baseline runtime, so CPUs without AVX2 run them.server/binary.tsruns the web server in its own process with the launcher's flags, password and bind checks (now shared incheckLaunchSecurity), plusompweb host(the daemon CLI moved tolib/hosts/host-cli.tsso both entries share it) andompweb hash-password. It serves from its own directory (OMP_WEB_PACKAGE_DIRoverrides), includingnode_modules/katexand the session-edit extension omp loads. Each archive carrieslicenses/: the license files of every npm package bundled into the program ordist/(from Bun.build's metafiles) and Bun's own license. It has no tray, service installers or in-app update: Settings and the update toast link the release page, omp's "Update now" is hidden, and in-app update requests answer 409. The README lists the systemd units to write by hand.npm run devis one command with hot reload; the "never runnext buildduring dev" trap is gone.bun test --parallelwithout jiti. CI adds a smoke test of the built server and of a packed install (with and without install scripts), and parses the Windows PowerShell scripts. The smoke now also startsompweb host, checks that a session lists through it and that omp gets the install's session-edit extension (a stand-in omp records its arguments); on Linux and Windows it also runs against the compiled binary (npm run smoke -- --binary), which proves the production define.Behaviour notes
ompweb(ornpx @kahme247/ompweb) again once; later updates restart normally. systemd, launchd and the tray start the new launcher and are not affected.Locationheaders, and the origin check and the session cookie'sSecureflag honourX-Forwarded-Proto, so a TLS-terminating proxy keeps working./does-not-existnow gets the app (sidebar plus the new-session view) with status 200, where Next answered 404 with its bare "This page could not be found." page. Unknown file paths (/foo/bar.txt) still get a 404.color-mix()as written, without Tailwind's solid-colour fallback (Bun's CSS bundler dropped some of the@supportsoverrides, which left solid accent squares and focus rings). Every browser Next targeted (Chrome 111, Safari 16.4) supportscolor-mix(); an older browser now gets no colour for those declarations instead of a full-strength one.OMP_WEB_DEV_ORIGINis removed; the client version variables are renamed toOMP_WEB_PUBLIC_*(build-time only).skills findCLI, instead of waiting on a stalled skills.sh.Not verified here
nix/package.nixuses the npm@oven/bunbinary withautoPatchelfHookon Linux, andnpmDepsHashmust be refreshed on a machine with Nix.Testing
npm run typecheck && npm run lint && npm test: 2003 pass, 12 skip, 0 fail.npm run build && npm run smoke, against the repo and against a packed global install, with and without install scripts.ompweb hostdaemon links to the Bun server and stays linked through an idle gap.npm run build:binaryfor all five targets, andnpm run smoke -- --binary release/ompweb-linux-x64/ompweb: the binary serves the SPA,/api/hosts, the KaTeX files and the manifest from its own directory with any cwd, itsompweb hostlinks,/api/sessionslists a fixture session through it, and omp is started with the extension from the release directory. A binary compiled without the define fails the session step.?session=deep links, styled math, fonts and all Settings tabs render; the theme color is set before first paint.Design:
docs/specs/2026-10-30-bun-runtime-design.md. Plan:docs/plans/2026-10-30-bun-runtime.md.Closes #346.