The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 01:45 UTC
fix(web): render powerline separators at cell edges (#5607)
Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
SadriG91 committed
Oct 19, 2026 at 20:24 UTC
3982f20ce48629a215f3c3d7d7e5c0df800a5fbd
2 files changed
+119
-3
apps/web/src/terminal/ghostty/renderer.test.ts
+72
@@ -71,6 +71,78 @@ describe("ghosttyTextRunEnd", () => {
71
});
72
73
describe("renderGhosttySnapshot", () => {
74
+ it("draws solid Powerline separators to their cell edges instead of as text", () => {
75
+ const paths: number[][][] = [];
76
+ let path: number[][] = [];
77
+ const fillTextCalls: unknown[][] = [];
78
+ const context = {
79
+ canvas: { width: 200, height: 40 },
80
+ beginPath: () => {
81
+ path = [];
82
+ },
83
+ clip: () => {},
84
+ closePath: () => {},
85
+ fill: () => paths.push(path),
86
+ fillRect: () => {},
87
+ fillText: (...args: unknown[]) => fillTextCalls.push(args),
88
+ lineTo: (x: number, y: number) => path.push([x, y]),
89
+ moveTo: (x: number, y: number) => path.push([x, y]),
90
+ rect: () => {},
91
+ resetTransform: () => {},
92
+ restore: () => {},
93
+ save: () => {},
94
+ set fillStyle(_value: string) {},
95
+ set font(_value: string) {},
96
+ set textBaseline(_value: string) {},
97
+ } as unknown as CanvasRenderingContext2D;
98
+ const snapshot: GhosttySnapshot = {
99
+ cols: 3,
100
+ rows: 1,
101
+ foreground: { r: 255, g: 255, b: 255 },
102
+ background: { r: 0, g: 0, b: 0 },
103
+ cursor: { r: 255, g: 255, b: 255 },
104
+ cursorX: -1,
105
+ cursorY: -1,
106
+ cursorVisible: false,
107
+ cursorBlinking: false,
108
+ cursorStyle: 1,
109
+ dirtyRows: new Set([0]),
110
+ rowData: [
111
+ {
112
+ cells: [cell("a"), cell("\ue0b0"), cell("\ue0b2")],
113
+ text: "a\ue0b0\ue0b2",
114
+ isWrapContinuation: false,
115
+ wrapsToNext: false,
116
+ },
117
+ ],
118
+ };
119
+
120
+ renderGhosttySnapshot({
121
+ context,
122
+ snapshot,
123
+ metrics: { width: 10, height: 20, baseline: 15 },
124
+ fontSize: 12,
125
+ fontFamily: "monospace",
126
+ padding: 4,
127
+ forceFull: false,
128
+ cursorOn: false,
129
+ });
130
+
131
+ expect(fillTextCalls).toEqual([["a", 4, 19, 10]]);
132
+ expect(paths).toEqual([
133
+ [
134
+ [14, 4],
135
+ [24, 14],
136
+ [14, 24],
137
+ ],
138
+ [
139
+ [34, 4],
140
+ [24, 14],
141
+ [34, 24],
142
+ ],
143
+ ]);
144
+ });
145
+
146
it("underlines every cell in a hovered wrapped link", () => {
147
const fillRectCalls: number[][] = [];
148
const context = {
apps/web/src/terminal/ghostty/renderer.ts
+47
-3
@@ -18,6 +18,8 @@ export interface GhosttyCellRange {
18
}
19
20
const DEFAULT_SELECTION_BACKGROUND = "rgba(72, 122, 191, 0.35)";
21
+const POWERLINE_SOLID_RIGHT = "\ue0b0";
22
+const POWERLINE_SOLID_LEFT = "\ue0b2";
23
24
function cssColor(color: GhosttyColor): string {
25
return `rgb(${color.r}, ${color.g}, ${color.b})`;
@@ -35,6 +37,30 @@ function sameTextStyle(left: GhosttyCell, right: GhosttyCell): boolean {
37
);
38
}
39
40
+function isSolidPowerlineSeparator(text: string): boolean {
41
+ return text === POWERLINE_SOLID_RIGHT || text === POWERLINE_SOLID_LEFT;
42
+}
43
+
44
+// Fallback fonts inset or scale these private-use glyphs, leaving a gap where
45
+// the separator should meet the next cell. Fill the triangle from the cell's
46
+// own edges instead, as native terminals do.
47
+function fillSolidPowerlineSeparator(
48
+ context: CanvasRenderingContext2D,
49
+ text: string,
50
+ left: number,
51
+ top: number,
52
+ metrics: GhosttyCellMetrics,
53
+): void {
54
+ const right = left + metrics.width;
55
+ const [base, point] = text === POWERLINE_SOLID_RIGHT ? [left, right] : [right, left];
56
+ context.beginPath();
57
+ context.moveTo(base, top);
58
+ context.lineTo(point, top + metrics.height / 2);
59
+ context.lineTo(base, top + metrics.height);
60
+ context.closePath();
61
+ context.fill();
62
+}
63
+
64
export function ghosttyTextRunEnd(
65
cells: readonly GhosttyCell[],
66
start: number,
@@ -48,7 +74,7 @@ export function ghosttyTextRunEnd(
74
end += 1;
75
continue;
76
}
51
- if (next.text.length === 0 || !sameStyle(next)) break;
77
+ if (next.text.length === 0 || isSolidPowerlineSeparator(next.text) || !sameStyle(next)) break;
78
end += 1;
79
}
80
return end;
@@ -192,6 +218,20 @@ export function renderGhosttySnapshot(options: {
218
runStart += 1;
219
continue;
220
}
221
+ if (isSolidPowerlineSeparator(first.text)) {
222
+ if (!first.invisible) {
223
+ context.fillStyle = cssColor(first.foreground);
224
+ fillSolidPowerlineSeparator(
225
+ context,
226
+ first.text,
227
+ padding + runStart * metrics.width,
228
+ top,
229
+ metrics,
230
+ );
231
+ }
232
+ runStart += 1;
233
+ continue;
234
+ }
235
const runEnd = ghosttyTextRunEnd(row.cells, runStart, (cell) => sameTextStyle(cell, first));
236
const text = row.cells
237
.slice(runStart, runEnd)
@@ -261,9 +301,13 @@ export function renderGhosttySnapshot(options: {
301
context.fillRect(left, top, metrics.width, metrics.height);
302
const cell = snapshot.rowData[snapshot.cursorY]?.cells[snapshot.cursorX];
303
if (cell?.text) {
264
- context.font = fontForCell(cell, fontSize, fontFamily);
304
context.fillStyle = cssColor(snapshot.background);
266
- context.fillText(cell.text, left, top + metrics.baseline, metrics.width);
305
+ if (isSolidPowerlineSeparator(cell.text)) {
306
+ fillSolidPowerlineSeparator(context, cell.text, left, top, metrics);
307
+ } else {
308
+ context.font = fontForCell(cell, fontSize, fontFamily);
309
+ context.fillText(cell.text, left, top + metrics.baseline, metrics.width);
310
+ }
311
}
312
}
313
}