fix(report): dynamically scale box width and wrap text properly - #17
Open
tejasprasad2008-afk wants to merge 5 commits into
Open
fix(report): dynamically scale box width and wrap text properly#17tejasprasad2008-afk wants to merge 5 commits into
tejasprasad2008-afk wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the text report renderer to adapt box/border widths to the current terminal size and attempts to wrap long report content so it stays within borders.
Changes:
- Added
getBoxWidth()with default/max width caps to scale boxes to the terminal width. - Introduced
stripAnsi()andwrap()helpers and applied wrapping to identity rationale, summary, and finding content. - Reworked finding rendering to print each finding inside a bordered, color-coded box with a severity badge in the top border.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
+25
| function getBoxWidth(): number { | ||
| const cols = process.stdout.columns; | ||
| if (!cols || cols < 40) return DEFAULT_WIDTH; | ||
| return Math.min(cols - 4, MAX_WIDTH); | ||
| } |
Comment on lines
+34
to
+55
| /** ANSI-aware word wrap. */ | ||
| function wrap(text: string, width: number): string[] { | ||
| const lines: string[] = []; | ||
| const words = text.split(" "); | ||
| let current = ""; | ||
| let currentVisibleLen = 0; | ||
|
|
||
| for (const word of words) { | ||
| const wordVisibleLen = stripAnsi(word).length; | ||
| // +1 for the space | ||
| if (currentVisibleLen + wordVisibleLen + 1 > width) { | ||
| if (current) lines.push(current); | ||
| current = word; | ||
| currentVisibleLen = wordVisibleLen; | ||
| } else { | ||
| current = current ? current + " " + word : word; | ||
| currentVisibleLen += (current === word ? 0 : 1) + wordVisibleLen; | ||
| } | ||
| } | ||
| if (current) lines.push(current); | ||
| return lines; | ||
| } |
Comment on lines
+36
to
+38
| const lines: string[] = []; | ||
| const words = text.split(" "); | ||
| let current = ""; |
Comment on lines
+77
to
+80
| function findingBox( | ||
| f: Finding, | ||
| index: number, | ||
| contentLines: string[], |
Comment on lines
+41
to
+52
| for (const word of words) { | ||
| const wordVisibleLen = stripAnsi(word).length; | ||
| // +1 for the space | ||
| if (currentVisibleLen + wordVisibleLen + 1 > width) { | ||
| if (current) lines.push(current); | ||
| current = word; | ||
| currentVisibleLen = wordVisibleLen; | ||
| } else { | ||
| current = current ? current + " " + word : word; | ||
| currentVisibleLen += (current === word ? 0 : 1) + wordVisibleLen; | ||
| } | ||
| } |
tejasprasad2008-afk
force-pushed
the
split/1-report-ui
branch
from
June 5, 2026 15:58
8c14554 to
85895c9
Compare
Author
|
YEPPP POLISHED THIS ONE A LIL BIT TOO |
Author
|
btw all the changes recommended by copilot earlier were mostly to polish the code and its hygiene thats it |
Author
|
@ni5arga this ones left |
Owner
|
gotchu |
Comment on lines
+35
to
+49
| function wrap(text: string, width: number): string[] { | ||
| const lines: string[] = []; | ||
| const words = text.trim().split(/\s+/); | ||
| let current = ""; | ||
| let currentVisibleLen = 0; | ||
|
|
||
| for (const word of words) { | ||
| const wordVisibleLen = stripAnsi(word).length; | ||
|
|
||
| // Hard-wrap long unstyled tokens (e.g., URLs) to avoid overflowing the box. | ||
| if (stripAnsi(word) === word && wordVisibleLen > width) { | ||
| if (current) lines.push(current); | ||
| for (let i = 0; i < word.length; i += width) { | ||
| lines.push(word.slice(i, i + width)); | ||
| } |
Comment on lines
+201
to
+204
| const lines: string[] = []; | ||
| const headerText = `${pc.dim(`#${i + 1}`)} ${pc.cyan(f.category)} — ${pc.bold(f.claim)}`; | ||
| wrap(headerText, innerW).forEach((l) => lines.push(l)); | ||
|
|
Comment on lines
+211
to
+217
| for (const e of f.evidence ?? []) { | ||
| const quoteLines = wrap(`"${e.quote}"`, innerW - 6); | ||
| quoteLines.forEach((l, idx) => { | ||
| const prefix = idx === 0 ? ` ${pc.dim("┊")} ` : ` `; | ||
| lines.push(prefix + l); | ||
| }); | ||
| lines.push(` ${pc.blue(pc.underline(e.permalink))}`); |
Comment on lines
+165
to
166
| out.push(pc.dim("── direct identifiers extracted ".padEnd(w, "─"))); | ||
| out.push(""); |
Owner
|
all workflows are failing and copilot has some suggestions, please check them - thanks. |
Author
|
yeah fixed those |
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: