Skip to content

Commit 9c03330

Browse files
Merge pull request #318 from corbitsdev/cl-5345-fix-intermittent-grey-block-render-artifact-in-transcript
Stop painting full-width grey spacer rows on user messages
2 parents 2b77cbe + bc3a3b9 commit 9c03330

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/tui/components/event-log-assembly.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,17 @@ function blockToLines(
611611
];
612612
}
613613
case "user": {
614-
// A subtle box with a blank padded row above and below so the text has
615-
// breathing room. Text starts at column 1 to line up with the assistant's
616-
// "●" marker; a 1-col right margin keeps the fill off the edge.
614+
// Subtle box: paint background only on content rows. Blank spacer rows
615+
// used to be full-width bg fills and could flash as solid grey blocks
616+
// during scroll/repaint when content was empty or mid-frame.
617+
// plainLines/wrapRanges always yield ≥1 row (even for ""), so gate on
618+
// real emptiness rather than userLines.length.
619+
if (!block.content.trim()) return [];
617620
const bg = color("userMessageBg");
618621
const LEFT = 1;
619622
const RIGHT = 1;
620623
const innerWidth = Math.max(1, width - LEFT - RIGHT);
621-
const blankRow = [{ text: " ".repeat(width), backgroundColor: bg }];
624+
const blankRow: StyledLine = [{ text: "" }];
622625
const userLines = plainLines(
623626
compactUserCodeBlocks(block.content),
624627
{ color: color("text"), backgroundColor: bg },

src/tui/components/event-log.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from "./event-log.js";
1616
import { formatElapsed } from "./in-flight-indicator.js";
1717
import type { ContentBlock, ContentBlockData } from "../use-stream.js";
18+
import { color } from "../theme.js";
1819

1920
function asBlock(data: ContentBlockData & { id: string }): ContentBlock {
2021
return data as ContentBlock;
@@ -706,6 +707,25 @@ describe("flat line buffer", () => {
706707
}
707708
});
708709

710+
test("user banner spacer rows have no background while body keeps userMessageBg", () => {
711+
const block: ContentBlock = { type: "user", id: "user-bg", content: "hello" };
712+
const lines = buildLines([block], COLUMNS, false, isExpanded);
713+
// blank spacer, body, blank spacer
714+
expect(lines.length).toBe(3);
715+
const bg = color("userMessageBg");
716+
expect(lines[0]!.every((seg) => seg.backgroundColor === undefined)).toBe(true);
717+
expect(lines[2]!.every((seg) => seg.backgroundColor === undefined)).toBe(true);
718+
expect(lines[1]!.some((seg) => seg.backgroundColor === bg)).toBe(true);
719+
expect(lines[1]!.every((seg) => seg.backgroundColor === bg)).toBe(true);
720+
});
721+
722+
test("empty or whitespace user content yields no grey box", () => {
723+
for (const content of ["", " ", "\n\t"]) {
724+
const block: ContentBlock = { type: "user", id: "empty-user", content };
725+
expect(buildLines([block], COLUMNS, false, isExpanded)).toEqual([]);
726+
}
727+
});
728+
709729
test("buildResourceBanner shows brand, workspace path, and optional skills/plugins", () => {
710730
const workspace = "/home/user/project";
711731
const banner = buildResourceBanner([{ name: "scribe" }, { name: "tdd" }], ["exa"], 80, workspace);

0 commit comments

Comments
 (0)