fix(ui): offload large diff highlighting to a worker - #759
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR moves eligible large-diff syntax highlighting into a serialized Bun worker while retaining the existing HAST-to-row pipeline and plain-text request fallback.
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking reliability gap where worker construction failure can abort interactive startup rather than degrade to plain text. The request-time worker path has explicit fallback behavior and targeted tests, but the eager constructor runs before that protection and before the interactive application starts. Files Needing Attention: src/main.tsx Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Interactive diff UI
participant Cache as Highlight cache
participant Client as Worker client queue
participant Worker as Highlight worker
UI->>Cache: Request large-diff highlight
Cache->>Client: Enqueue metadata and theme
Client->>Worker: postMessage(request)
Worker->>Worker: Highlight with Pierre/Shiki
Worker-->>Client: HAST line arrays
Client-->>Cache: Resolve request
Cache-->>UI: Build highlighted rows
alt Request-time worker failure
Client-->>Cache: Reject request
Cache-->>UI: Render plain-text rows
end
Prompt To Fix All With AI### Issue 1
src/main.tsx:106
**Eager worker construction bypasses fallback**
If worker construction fails because the entrypoint cannot be resolved or the runtime cannot allocate the worker, this eager constructor rejects `main()` before the TUI starts, causing Hunk to exit instead of degrading syntax highlighting to plain text.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(ui): offload large diff highlighting" | Re-trigger Greptile |
| await runInteractiveApp(startupPlan); | ||
| // materialize its embedded native library. Bun only resolves compiled worker entrypoints from | ||
| // this executable entrypoint, so start and register the worker here instead of in a UI module. | ||
| const highlightWorker = new Worker(new URL("./highlightWorker.js", import.meta.url).href); |
There was a problem hiding this comment.
Eager worker construction bypasses fallback
If worker construction fails because the entrypoint cannot be resolved or the runtime cannot allocate the worker, this eager constructor rejects main() before the TUI starts, causing Hunk to exit instead of degrading syntax highlighting to plain text.
Knowledge Base Used: CLI Entrypoint and Startup Lifecycle
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/main.tsx
Line: 106
Comment:
**Eager worker construction bypasses fallback**
If worker construction fails because the entrypoint cannot be resolved or the runtime cannot allocate the worker, this eager constructor rejects `main()` before the TUI starts, causing Hunk to exit instead of degrading syntax highlighting to plain text.
**Knowledge Base Used:** [CLI Entrypoint and Startup Lifecycle](https://app.greptile.com/modem/-/custom-context/knowledge-base/modem-dev/hunk/-/docs/cli-entrypoint.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.3148deb to
3feeac8
Compare
Summary
Validation
bun run typecheckbun test src/ui/diff/diffRows.test.ts test/pty/highlighting.test.tsbun run build:binHUNK_TEST_EXECUTABLE=dist/hunk bun test test/pty/highlighting.test.ts test/cli/compiled-headless-native-lib.test.tsbun run test:integrationbun run test:tty-smokeThis PR description was generated by Pi using gpt-5.6-sol