Repository navigation
Description
Hi all, hope you're doing well! Thanks for the BigInt work in #5328, and for the clipboard tests in #2584, both made this really easy to track down.
Summary
In the web UI, copying a step input, output or event payload that contains a BigInt anywhere below the top level gives you [object Object] (or 1,2 for an array) instead of JSON.
What the copy button is for
The copy button next to each data block in the run sidebar is how I grab a step's input or output to paste into a test, a bug report or a replay. The sidebar itself shows BigInt values fine; only the copied text is wrong.
Current behavior
- Call a workflow step with
{ id: 1n }as its argument. - Open the run in the web UI and select that step.
- Click copy on the input block.
- The clipboard holds
[object Object].
serializeForClipboard calls JSON.stringify(value, null, 2) with no replacer, so any nested BigInt throws, and the catch falls back to String(value):
workflow/packages/web-shared/src/components/sidebar/copyable-data-block.tsx
Lines 54 to 68 in ad36891
| export const serializeForClipboard = (value: unknown): string => { | |
| if (typeof value === 'string') return value; | |
| if ( | |
| typeof value === 'number' || | |
| typeof value === 'boolean' || | |
| value === null | |
| ) { | |
| return String(value); | |
| } | |
| try { | |
| return JSON.stringify(value, null, 2); | |
| } catch { | |
| return String(value); | |
| } | |
| }; |
The values really do reach it as BigInts: core writes a BigInt tag (packages/core/src/serialization/reducers/common.ts L236), and the web hydration revives it with BigInt: (value) => BigInt(value):
| BigInt: (value: string) => BigInt(value), |
From there it goes to <CopyableDataBlock data={value} /> (attribute-panel.tsx, attributes-block.tsx, events-list.tsx), and serializeForClipboard is also called directly from event-details-panel.tsx L139 and stream-viewer.tsx L58.
serializeForClipboard with the CopyableDataBlock and PayloadView components that call it, Functions view in Architect
Expected behavior
Valid JSON with each BigInt written as a string, the same way the CLI prints it after #5328.
Minimal repro
I copied the function verbatim into node on ad36891:
| Input | Copied text |
|---|---|
10n |
10 (right, but only because String(10n) happens to match) |
{ amount: 10n, name: 'x' } |
[object Object] |
[1n, 2n] |
1,2 |
[{ id: 1n }] |
[object Object] |
{ input: [{ a: { b: 5n } }] } |
[object Object] |
The tests in packages/web-shared/test/copyable-data-block.test.ts (L52 to L62) only cover the top level 10n case, which is probably why this slipped by. #2584 mentions the String fallback covering "circular refs and BigInt", so I think the nested case just wasn't in view.
Questions
- Would you be open to reusing the replacer from [cli] Fix BigInt crashes in inspect and stream output #5328 (
packages/cli/src/lib/inspect/json.tsL8) inserializeForClipboard? I'd be happy to open a small PR with a test for the nested cases. - For circular objects, should they keep the current
[object Object]fallback? The same test block expects that today, so I'd leave it alone unless you'd prefer something else. formatMetadataValueinattributes-block.tsx(L200 to L213) looks like the same pattern. I also wonder whether a hydratedMaporSetcopies as{}, but I haven't checked that yet.
Thanks so much for taking a look, and any tips are very welcome!

Activity
[web-shared] Copy BigInt values as decimal strings instead of [object…
[web-shared] Copy BigInt values as decimal strings instead of [object…