GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): workflow run titles no longer end in a broken character … · mediavee/t3code@8aff2f9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/workflows
    • WorkflowStore.test.ts
    • WorkflowStore.ts
  • scripts/scenarios
    • workflow-run-title-keeps-whole-characters.e2e.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/workflows/WorkflowStore.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/workflows/WorkflowStore.test.ts
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,25 @@ it.effect("a long failure detail is cut without leaving half an emoji", () =>
273273
),
274274
);
275275

276+
it.effect("a long run title is cut without leaving half an emoji", () =>
277+
withStore(
278+
Effect.gen(function* () {
279+
const store = yield* WorkflowStore.WorkflowStore;
280+
yield* store.runStarted({
281+
runId: "r1",
282+
workflow: "titled",
283+
version: 1,
284+
engineTag: "titled@1",
285+
idempotencyKey: "k",
286+
input: {},
287+
});
288+
yield* store.runTitle("r1", `${"a".repeat(199)}\u{1F680}tail`);
289+
const run = yield* store.run("r1");
290+
assert.equal(run?.title, "a".repeat(199));
291+
}),
292+
),
293+
);
294+
276295
it.effect("one buffered signal goes to one wait, and a claimed wait keeps what woke it", () =>
277296
withStore(
278297
Effect.gen(function* () {
Collapse file

‎apps/server/src/workflows/WorkflowStore.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/workflows/WorkflowStore.ts
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,8 @@ export const make = Effect.gen(function* () {
573573
return true;
574574
}),
575575
runTitle: Effect.fn("WorkflowStore.runTitle")(function* (runId, title) {
576-
yield* write(
577-
runId,
578-
sql`UPDATE workflow_runs SET title = ${title.slice(0, 200)} WHERE run_id = ${runId}`,
579-
);
576+
const kept = title.slice(0, splitsSurrogatePair(title, 200) ? 199 : 200);
577+
yield* write(runId, sql`UPDATE workflow_runs SET title = ${kept} WHERE run_id = ${runId}`);
580578
}),
581579
stepStarted: Effect.fn("WorkflowStore.stepStarted")(function* (runId, name, kind) {
582580
const at = yield* now;
Collapse file

‎scripts/scenarios/workflow-run-title-keeps-whole-characters.e2e.ts‎

Copy file name to clipboard
+60Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { expect } from "e2e";
2+
import * as Effect from "effect/Effect";
3+
import * as FileSystem from "effect/FileSystem";
4+
import * as Path from "effect/Path";
5+
6+
import { T3_HOME } from "../e2e.config.ts";
7+
import { makeState, rpcClient, runPromise, test, WEB } from "./t3.ts";
8+
9+
const KEPT = "a".repeat(199);
10+
// The emoji's two UTF-16 units straddle unit 200, where the server cuts a run's title.
11+
const DEFINITION = `export default T3.workflow("titled", { version: 1, payload: Schema.Struct({}) },
12+
Effect.fn(function* () {
13+
yield* T3.title("${KEPT}😀 and the rest of the title");
14+
}));
15+
`;
16+
17+
test(
18+
"A long workflow run title ends without a broken character",
19+
WEB,
20+
async ({ t3, app, screen }) => {
21+
const definition = await runPromise(
22+
Effect.map(Path.Path, (path) => path.join(T3_HOME, "workflows/titled.ts")),
23+
);
24+
const workflowsOn = (on: boolean) =>
25+
runPromise(
26+
Effect.gen(function* () {
27+
const client = yield* rpcClient(T3_HOME, app.baseUrl ?? "");
28+
yield* client["server.updateSettings"]({ patch: { workflowsEnabled: on } });
29+
}).pipe(Effect.scoped),
30+
);
31+
try {
32+
await runPromise(
33+
Effect.gen(function* () {
34+
const fs = yield* FileSystem.FileSystem;
35+
const path = yield* Path.Path;
36+
yield* fs.makeDirectory(path.dirname(definition), { recursive: true });
37+
yield* fs.writeFileString(definition, DEFINITION);
38+
}),
39+
);
40+
await t3.project("demo");
41+
await workflowsOn(true);
42+
const started = await runPromise(
43+
makeState(T3_HOME).cli(["workflow", "start", "titled", "--key", "one", "--json"]),
44+
);
45+
const { run } = JSON.parse(started.stdout);
46+
await t3.open(`/workflows?run=${run.runId}`);
47+
48+
// Until the title activity commits, the heading is the workflow's name and key.
49+
const heading = screen.getByRole("heading", KEPT, { exact: false });
50+
await heading.waitFor({ timeout: 30_000 });
51+
await app.screenshot("run-heading");
52+
await expect(heading).toHaveText(KEPT);
53+
} finally {
54+
await workflowsOn(false);
55+
await runPromise(
56+
Effect.flatMap(FileSystem.FileSystem, (fs) => fs.remove(definition, { force: true })),
57+
);
58+
}
59+
},
60+
);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.