[Cleanup] Remove dead client variable, use Buffer.indexOf for newline counting, document source maps - #170
Merged
Merged
Conversation
- Remove dead `displayedLines` variable from the SSE log-line handler in main.ts; it was never assigned and always null. - Use Buffer.indexOf for newline counting in readLastLines instead of a byte-by-byte JS loop, avoiding up to ~8M JS iterations on worst-case bootstrap/reattach/skip-ahead scans. - Document in README.md that client source maps are built and served intentionally, to ease in-browser debugging.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



📖 Description
Bundles three independent, minor housekeeping items from the 2026-07 security & performance review:
src/client/main.ts— removed the deaddisplayedLinesvariable in the SSElog-linehandler. It was declared but never assigned, alwaysnull, and passed intocompleteSseTiming's perf-timing details. The real displayed-line count is already recorded separately by the render-siderender:log-linestiming, since the actual render is deferred to arequestAnimationFramebatch.src/server/logTailer.ts— replaced the byte-by-bytefor…ofloop counting\nbytes inreadLastLineswithBuffer.prototype.indexOf, which performs the same scan natively instead of one JS iteration per byte. This path can scan up toMAX_TAIL_SCAN_BYTES(8 MB) on bootstrap, reattach, and skip-ahead. Semantics are unchanged (0x0anever appears as a UTF-8 continuation byte, per the existing comment, which is preserved).README.md— added a short note documenting that client source maps are built and served intentionally (to ease in-browser debugging; the source is public anyway), and that the server-side map is not exposed sinceexpress.staticonly servesdist/client.None of these changes alter user-visible behavior.
🎫 Issues
Closes #139
👩💻 Reviewer Notes
The
readLastLineschange is the one with the most surface area — worth a close look atsrc/server/logTailer.ts. The new regression tests exercise CRLF input, a file without a trailing newline, and a file spanning multiple 64 KB read chunks with zero newlines, to confirm theindexOf-based scan behaves identically to the removed byte loop.📑 Test Plan
src/server/logTailer.test.tscases:normalizes CRLF line endings the same way as LF on bootstrapreturns the trailing line even when the file does not end with a newlinecounts newlines correctly across multiple 64 KB read chunks (regression for #139)npm test(all 155 tests pass) andnpm run typecheck.npm run buildto confirm both bundles build cleanly.✅ Checklist
General
npm testandnpm run typechecklocally and they pass.Server-specific (
src/server)src/server(tailer, parser, buffer, routes, SSE hub, config, etc.).src/server/types.tsin sync withsrc/client/state.tsfor any shared payload change (no shared payload change in this PR).Client-specific (
src/client)render.ts,main.ts,derivedLogView.ts,filters.ts,preferences.ts, etc.).createInitialState()insrc/client/state.ts(no new state introduced).⏭ Next Steps
None.