GeezerVison is showing github.com — fix(server): keep emoji intact in review guide comment summaries · pingdotgg/t3code@7593596
File treeExpand file treeCollapse file tree Open diff view settings apps/server/src/pullRequest
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/pullRequest/PullRequestReviewGuideService.test.ts +34Lines changed: 34 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,7 @@ import * as ServerSettings from "../serverSettings.ts"; | 29 | 29 | import * as TextGeneration from "../textGeneration/TextGeneration.ts"; | 30 | 30 | import * as GitVcsDriver from "../vcs/GitVcsDriver.ts"; | 31 | 31 | import * as VcsProcess from "../vcs/VcsProcess.ts"; | | 32 | +import { reviewGuideInputFromPullRequest } from "./pullRequestReviewGuideInput.ts"; | 32 | 33 | import * as PullRequestReviewGuideService from "./PullRequestReviewGuideService.ts"; | 33 | 34 | import * as PullRequestService from "./PullRequestService.ts"; | 34 | 35 |
| @@ -364,6 +365,39 @@ const startSingleBranchRun = (input: { | 364 | 365 | }; | 365 | 366 | }); | 366 | 367 |
| | 368 | +it.each([ | | 369 | + { prefixLength: 198, ending: "🚀…" }, | | 370 | + { prefixLength: 199, ending: "…" }, | | 371 | +])( | | 372 | + "truncates a resolved remark with an emoji after $prefixLength characters", | | 373 | + ({ prefixLength, ending }) => { | | 374 | + const prefix = "a".repeat(prefixLength); | | 375 | + const thread: PullRequestActivity["reviewThreads"][number] = { | | 376 | + id: "thread-1", | | 377 | + path: "file.ts", | | 378 | + line: 1, | | 379 | + side: "right", | | 380 | + isResolved: true, | | 381 | + isOutdated: false, | | 382 | + comments: [ | | 383 | + { | | 384 | + id: "comment-1", | | 385 | + author: null, | | 386 | + body: `${prefix}🚀 more`, | | 387 | + createdAt: "2026-01-01T00:00:00Z", | | 388 | + url: null, | | 389 | + }, | | 390 | + ], | | 391 | + }; | | 392 | + const input = reviewGuideInputFromPullRequest( | | 393 | + detail("/work/app", "abc123"), | | 394 | + { ...activity, reviewThreads: [thread] }, | | 395 | + "abc123", | | 396 | + ); | | 397 | + assert.strictEqual(input.settledReview, `- file.ts (resolved, ghost): ${prefix}${ending}`); | | 398 | + }, | | 399 | +); | | 400 | + | 367 | 401 | it.layer(layerBase, { excludeTestServices: true })("PullRequestReviewGuideService", (it) => { | 368 | 402 | it.effect.each([ | 369 | 403 | { | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/pullRequest/pullRequestReviewGuideInput.ts +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { PullRequestActivity, PullRequestDetail } from "@t3tools/contracts"; | 2 | 2 | import type { ReviewGuideGenerationInput } from "@t3tools/provider-core/server/textGeneration"; | | 3 | +import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations"; | 3 | 4 |
| 4 | 5 | const SETTLED_REMARK_CHARS = 200; | 5 | 6 |
| @@ -8,7 +9,11 @@ function oneLine(text: string): string { | 8 | 9 | .replace(/<!--[\s\S]*?-->/g, "") | 9 | 10 | .replace(/\s+/g, " ") | 10 | 11 | .trim(); | 11 | | - return flat.length > SETTLED_REMARK_CHARS ? `${flat.slice(0, SETTLED_REMARK_CHARS)}…` : flat; | | 12 | + if (flat.length <= SETTLED_REMARK_CHARS) return flat; | | 13 | + const end = splitsSurrogatePair(flat, SETTLED_REMARK_CHARS) | | 14 | + ? SETTLED_REMARK_CHARS - 1 | | 15 | + : SETTLED_REMARK_CHARS; | | 16 | + return `${flat.slice(0, end)}…`; | 12 | 17 | } | 13 | 18 |
| 14 | 19 | function settledReviewSummary(activity: PullRequestActivity): string { | |
|