Skip to content

Import the row fork's modules statically, which puts main back under the startup budget - #11588

Merged
danielhanchen merged 1 commit into
mainfrom
fix/fork-row-static-imports
Sep 22, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/fork-row-static-imports

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

main fails Frontend build + bundle sanity since #11564:

eager startup JS: 5596.4 KB raw, 1665.0 KB transfer, 86 chunks
over the startup budget: raw 5596.4 KB > 5595.7 KB

Cause

forkChatRow in chat-row-menu.ts loads ../api/chat-api and ../stores/chat-runtime-store with await import(...). Both modules already ship in the eager chat chunk, so nothing is deferred. Each one did become a dynamic entry, though, and Rollup split their graphs (chat-api, apply-per-model-config, external-providers-store, model-identity, use-gpu-info, hf-token-store, settings-dialog-store, ...) out of chat and providers-api into eight new startup chunks.

I measured each startup chunk on both sides of #11564 (same machine, same build):

eager chunks raw bytes vs budget (5,730,000)
before #11564 (3b87ee8b5) 78 5,719,461 10.5 KB spare
after #11564 (2036ee0ba) 86 5,730,686 686 bytes over
this PR 78 5,720,574 (5586.5 KB) 9.2 KB spare

The fork feature itself costs about 1.1 KB. The other 10 KB was the glue those new chunks add. No module was added to or dropped from the startup set. The same code just shipped in more pieces.

So the gate was right and the product was wrong. The budget is not raised here.

Changes

  • chat-row-menu.ts: import forkChatThread and settleThreadScopedSettingsForCopy statically. Behaviour is unchanged: the visible branch is still read before settings settle, and the fork still runs after them. There is no import cycle (neither module imports chat-row-menu or the features/chat barrel), and tsc -b is clean.
  • tests/sidebar-row-actions.test.ts: the test transpiles forkChatRow alone and supplied the two modules through require, which only works for import(). They are now passed as bindings in the VM context. The ordering and messageId assertions are unchanged.
  • scripts/check-bundle-budget.ts: the over-budget hint suggested a dynamic import, which is how this overage happened. When the chunk count rose, it now says to check the opposite first.

Verification

  • npm run bundle:check: within budget (15.2 KB transfer, 9.2 KB raw to spare), 78 chunks.
  • Full frontend suite: 8473 passed, 0 failed. The budget CLI and closure tests: 41 passed.
  • Sabotage: restoring the two import() calls fails row forks retain the visible branch across settings settlement (ReferenceError: require is not defined) and fails the budget check again at raw 5596.4 KB > 5595.7 KB.

…the startup budget

forkChatRow loaded chat-api and chat-runtime-store with import(). Both
are already in the eager chat chunk, so nothing was deferred, but each
became a dynamic entry and Rollup split their graphs into eight more
startup chunks. The glue cost 10 KB and put main 686 bytes over the raw
startup budget.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T21:46:04.551947Z 46b43bd Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 46b43bdd29

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 22, 2026
@danielhanchen
danielhanchen merged commit 83c4c8c into main Sep 22, 2026
41 of 51 checks passed
@danielhanchen
danielhanchen deleted the fix/fork-row-static-imports branch September 22, 2026 22:12
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…the startup budget (unslothai#11588)

forkChatRow loaded chat-api and chat-runtime-store with import(). Both
are already in the eager chat chunk, so nothing was deferred, but each
became a dynamic entry and Rollup split their graphs into eight more
startup chunks. The glue cost 10 KB and put main 686 bytes over the raw
startup budget.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant