Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/server/src/preview/ServerBrowser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,9 +941,11 @@ it.live("reports a pending dialog without evaluating the page and resolves it ex
Effect.sync(() => resolvedEvaluation.resolve({ result: { value: true } })),
);
yield* Effect.promise(() => started.promise);
// The 4,000-character cap falls between the halves of the emoji.
const message = `Delete row?${" ".repeat(3_988)}😀`;
const dialog = {
type: () => "confirm",
message: () => "Delete row?",
message: () => message,
defaultValue: () => "",
accept: vi.fn(async () => {
resolvedEvaluation.resolve({ result: { value: true } });
Expand All @@ -958,7 +960,7 @@ it.live("reports a pending dialog without evaluating the page and resolves it ex
operation: "status",
input: {},
});
expect(status.dialog).toMatchObject({ type: "confirm", message: "Delete row?" });
expect(status.dialog).toMatchObject({ type: "confirm", message: message.slice(0, 3_999) });
expect(page.title).not.toHaveBeenCalled();
expect(dialog.dismiss).not.toHaveBeenCalled();
const reuse = yield* broker
Expand Down
7 changes: 5 additions & 2 deletions apps/server/src/preview/ServerBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ const DOWNLOAD_LIMIT = 20;
const ABORTED_NAVIGATION_DOWNLOAD_WAIT_MS = 5_000;
const DOWNLOAD_MAX_BYTES = 1024 * 1024 * 1024;

// Half an emoji serializes to a lone surrogate escape, which provider JSON parsers reject.
const cutDialogText = (text: string) => text.slice(0, 4_000).replace(/[\uD800-\uDBFF]$/, "");

const tabKey = (threadId: string, tabId: string) => `${threadId}\u0000${tabId}`;

const pushBounded = <A>(
Expand Down Expand Up @@ -537,8 +540,8 @@ const make = Effect.gen(function* () {
tab.dialog
? {
type: tab.dialog.type(),
message: tab.dialog.message().slice(0, 4000),
defaultValue: tab.dialog.defaultValue().slice(0, 4000),
message: cutDialogText(tab.dialog.message()),
defaultValue: cutDialogText(tab.dialog.defaultValue()),
}
: null;

Expand Down
Loading