Repository navigation
Conversation
Reduce cold-start JavaScript without changing DSH module registration or the client UI. Keep function and class names for readable diagnostics.
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fe2687a91
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| treeShaking: false, | ||
| // Readable for debugging in the browser: no minification, and Chinese text stays text. | ||
| minify: true, | ||
| keepNames: true, |
There was a problem hiding this comment.
Keep the serialized page reader free of bundler helpers
In the desktop app and DSH Desktop, read_browser now fails for every open page. With keepNames: true, esbuild inserts calls to its outer name-preservation helper inside readPage (for example, n(..., "collapse")). However, src/client/read-page.js serializes that function into READ_PAGE_SCRIPT, which bot-browsers.js executes in the isolated page through executeJavaScript; the helper is not present there. Evaluating the reader extracted from this commit's bundle reproduces ReferenceError: n is not defined. Build the serialized reader without name-preservation helpers, or otherwise keep it self-contained, and test the reader using the actual production build options.
Useful? React with 👍 / 👎.
Esbuild's keepNames transform adds a helper from the bundle scope to serialized page-reader code. Remove the transform and exercise the shipped function source in an isolated realm.
There was a problem hiding this comment.
Verdict: not ready for lulu. The required Leak scan fails on this head; I reproduced it locally while the same scan passed on dev. Minification renames LEGACY_PREFIXES and LEGACY_BROWSER_KEYS, so the scanner no longer recognizes three existing browser-storage migration literals in generated client.js. Keep the migration intact and make the scanner/build recognize only those known migration occurrences, without exempting the bundle or weakening the other checks. Rebuild and rerun the scan.
The fresh bundle check, isolated page-reader test, and full unit suite passed locally. Please update the PR description: this head drops keepNames; I measured 2,160,662 B raw and 663,540 B gzip. Keep #1019 open: this is a size reduction, not a verified fix for the reported physical-iPhone Safari load failure.
Merge order: land #1829 first once it is independently ready. Its merge with this PR is textually clean but produces a stale client.js; rebuilding the combined tree restored both build checks and all 28 focused tests passed. Run scripts/merge-dev.sh on whichever branch lands second. I found 35 otherwise-mergeable open PRs sharing only the generated bundle with this PR; 28 would conflict in that file, including #1841. Ready client fixes can land while this PR is blocked; rebuild from the latest dev after they land.
Preserve source identifiers and keep generated lines short so the existing leak scan recognizes the storage migration. Verify migration from the shipped client for both old prefixes and browser storage versions.
# Conflicts: # ds-bot/client.js
There was a problem hiding this comment.
The generated bundle is about 13% smaller uncompressed (about 3% with gzip), and the 2.5 MiB budget passes. The shipped reader runs outside bundle scope in the regression test, addressing the earlier helper concern; the preference migration and reading tests also passed. I found no overlapping open bundle-minification change.
There was a problem hiding this comment.
Devin Review found 1 finding. Devin automatically fixed it.
Fixed by Devin (1)
- Desktop browser page reading fails — Dropped keepNames so no bundle-scoped __name helper is injected; new test runs the shipped reader in isolation.
# Conflicts: # ds-bot/client.js
# Conflicts: # ds-bot/client.js # ds-bot/test/client-bundle.test.js
# Conflicts: # ds-bot/client.js
# Conflicts: # ds-bot/client.js
# Conflicts: # ds-bot/client.js
# Conflicts: # ds-bot/client.js
|
经评估暂不合入,先关闭。 |
Issue
Refs #1019
The esbuild step now strips whitespace and minifies syntax in
client.js, which cuts the startup bundle by 14% raw and 3% gzip. Only the build changes; the UI is untouched.What changed / 改了什么
ds-bot/scripts/build-client.mjs:minifySyntaxandminifyWhitespace(withlineLimit: 180), but no identifier renaming.LEGACY_*names, so those names must survive the build.keepNamesstays off. It would inject a bundle-scoped__namehelper intoreadPage, which is serialized and run inside the Bot browser page.charset: 'utf8'is kept. The scanner and the migration source are unchanged.client.jsis regenerated.ds-bot/test/client-bundle.test.jsadds three tests:dev.client.js, runs with no bundle scope.ds-bot/test/reading.test.jsandds-bot/test/user-bubble.test.js: they now read CSS and wiring from source, or allow for line continuations, instead of relying on generated formatting. The assertions are unchanged.Trade-off: the shipped
client.jsis denser to read in devtools. Names are kept and lines are capped at 180 characters. The source of truth issrc/client/.Measurements
devclient.js, raw / gzip (current head333873evs currentdev)How it was measured. The first row is from the current head and current
dev. The other rows were measured atc8d384feagainst thedevof that time; since then only other PRs' source has been merged in. Each timing is the median of 7 interleaved cold runs per build and engine. Every run used a fresh Playwright iPhone 13 context on macOS against the same pinned DSH0.2.2-rc.1mock bench.What this does not fix. About 11.5 MB raw of the 14.4 MB startup JavaScript is DSH's own client. DS Bot can't change that without patching DSH (hard rule 1), so a real cut needs a DSH-side change. DS Bot's own bundle already costs under 2 ms on the main thread, so the gain here is transfer and parse only. #1019 should stay open.
Changelog
The web client downloads slightly less JavaScript at startup.
How I checked it / 怎么验证的
npm test(inds-bot/) on the current head: 3421 tests, 3417 pass, 0 fail, 4 skippednode scripts/build-client.mjs --check: exit 0npm run lint: exit 0must fix: 0; CI Leak scan passesdev) and after (right) are identical apart from mock timestamps:Try it:
cd ds-bot && npm ci && node scripts/build-client.mjs --check && node --test test/client-bundle.test.jsUntested:
Other PRs: #1829 and #1841 have both landed. This branch has been merged with
devafter them, andclient.jswas rebuilt each time, as it was after #1776, #1150 and #1594. No open PR is waiting to land before this one.Checklist / 检查
src/client/changed →npm run buildran andclient.jsis committed. / 改了src/client/就已重新 build 并提交client.js。Co-authored-by. / 没有把 AI 工具写成作者或Co-authored-by。Implemented in session Slim web client bundle for mobile Safari
Review with Devin · Open in Devin Desktop