feat: TUI polish (truncation, expanded/collapsed, in-flight paths, render cache)#7
Merged
Conversation
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/index.ts">
<violation number="1" location="src/index.ts:101">
P2: Render-state caching is unbounded and retains full patch strings per tool call, which can cause memory growth during long sessions.</violation>
<violation number="2" location="src/index.ts:331">
P2: `truncatePreview` can duplicate lines for short-but-very-long diffs because head/tail slices overlap. This produces confusing previews and inaccurate truncation output.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Comment on lines
+331
to
+332
| const head = lines.slice(0, PATCH_PREVIEW_HEAD_LINES); | ||
| const tail = lines.slice(-PATCH_PREVIEW_TAIL_LINES); |
There was a problem hiding this comment.
P2: truncatePreview can duplicate lines for short-but-very-long diffs because head/tail slices overlap. This produces confusing previews and inaccurate truncation output.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index.ts, line 331:
<comment>`truncatePreview` can duplicate lines for short-but-very-long diffs because head/tail slices overlap. This produces confusing previews and inaccurate truncation output.</comment>
<file context>
@@ -275,16 +309,48 @@ function formatPatchOperation(operation: ApplyPatchOperation): string {
+ }
+
+ const lines = text.split("\n");
+ const head = lines.slice(0, PATCH_PREVIEW_HEAD_LINES);
+ const tail = lines.slice(-PATCH_PREVIEW_TAIL_LINES);
+ let preview = [...head, "…", ...tail].join("\n");
</file context>
Suggested change
| const head = lines.slice(0, PATCH_PREVIEW_HEAD_LINES); | |
| const tail = lines.slice(-PATCH_PREVIEW_TAIL_LINES); | |
| const headCount = Math.min(PATCH_PREVIEW_HEAD_LINES, Math.ceil(lines.length / 2)); | |
| const tailStart = Math.max(headCount, lines.length - PATCH_PREVIEW_TAIL_LINES); | |
| const head = lines.slice(0, headCount); | |
| const tail = lines.slice(tailStart); |
| export const PATCH_PREVIEW_MAX_CHARS = 4000; | ||
| const PATCH_PREVIEW_HEAD_LINES = 8; | ||
| const PATCH_PREVIEW_TAIL_LINES = 8; | ||
| const applyPatchRenderStates = new Map<string, ApplyPatchRenderState>(); |
There was a problem hiding this comment.
P2: Render-state caching is unbounded and retains full patch strings per tool call, which can cause memory growth during long sessions.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index.ts, line 101:
<comment>Render-state caching is unbounded and retains full patch strings per tool call, which can cause memory growth during long sessions.</comment>
<file context>
@@ -86,6 +94,11 @@ type ApplyPatchTheme = {
+export const PATCH_PREVIEW_MAX_CHARS = 4000;
+const PATCH_PREVIEW_HEAD_LINES = 8;
+const PATCH_PREVIEW_TAIL_LINES = 8;
+const applyPatchRenderStates = new Map<string, ApplyPatchRenderState>();
function normalizeApplyPatchArguments(args: unknown): ApplyPatchParams {
</file context>
8c71148 to
3333dc0
Compare
3333dc0 to
99e48e2
Compare
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.
Summary
Atomic TDD commits implementing 7 TUI improvements:
Backward compatibility
Tests
test/render.test.ts(13 tests) covering: truncatePreview, displayPath, formatPatchPreview collapsed/expanded, formatInFlightCallText, render state cache, renderResult collapsed/multi-file/truncation, renderCall argsComplete/pathsVerification
npm run check: cleannpm test: 31/31 greenCommits (atomic TDD)
(list will be auto-shown in PR)