GeezerVison is showing github.com — fix(server): long worktree setup details no longer end in half an emo… · pingdotgg/t3code@221bc8a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: apps/server/src/project/WorktreeSetupTracker.test.ts +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -140,4 +140,24 @@ describe("WorktreeSetupTracker", () => { |
140 | 140 | yield* Fiber.interrupt(fiber); |
141 | 141 | }), |
142 | 142 | ); |
| 143 | + |
| 144 | + it.effect("clamps stage detail and finish error without splitting surrogate pairs", () => |
| 145 | + Effect.gen(function* () { |
| 146 | + const tracker = yield* WorktreeSetupTracker.make; |
| 147 | + yield* tracker.begin({ |
| 148 | + threadId, |
| 149 | + branch: null, |
| 150 | + baseRef: null, |
| 151 | + stages: ["agent"], |
| 152 | + fiber: null, |
| 153 | + }); |
| 154 | + |
| 155 | + yield* tracker.stageStatus(threadId, "agent", "running", `${"a".repeat(198)}\u{1F680}tail`); |
| 156 | + yield* tracker.finish(threadId, "failed", `${"e".repeat(998)}\u{1F680}tail`); |
| 157 | + |
| 158 | + const final = yield* tracker.get(threadId); |
| 159 | + expect(final?.stages[0]?.detail).toBe(`${"a".repeat(198)}\u2026`); |
| 160 | + expect(final?.error).toBe(`${"e".repeat(998)}\u2026`); |
| 161 | + }), |
| 162 | + ); |
143 | 163 | }); |
Collapse file
Copy file name to clipboardExpand all lines: apps/server/src/project/WorktreeSetupTracker.ts +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import { |
11 | 11 | WORKTREE_SETUP_STAGE_ORDER, |
12 | 12 | WORKTREE_SETUP_TAIL_LINE_MAX_LENGTH, |
13 | 13 | } from "@t3tools/contracts"; |
| 14 | +import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations"; |
14 | 15 | import * as Context from "effect/Context"; |
15 | 16 | import * as DateTime from "effect/DateTime"; |
16 | 17 | import * as Effect from "effect/Effect"; |
@@ -67,7 +68,9 @@ export class WorktreeSetupTracker extends Context.Service< |
67 | 68 | const TAIL_LINE_LIMIT = 4; |
68 | 69 |
|
69 | 70 | function clampText(text: string, maxLength: number): string { |
70 | | - return text.length <= maxLength ? text : `${text.slice(0, maxLength - 1)}\u2026`; |
| 71 | + if (text.length <= maxLength) return text; |
| 72 | + const end = splitsSurrogatePair(text, maxLength - 1) ? maxLength - 2 : maxLength - 1; |
| 73 | + return `${text.slice(0, end)}\u2026`; |
71 | 74 | } |
72 | 75 |
|
73 | 76 | const clampDetail = (detail: string | null): string | null => |
|