Skip to content

[web-shared] Consolidate copy-to-clipboard into one CopyButton - #5530

Closed
mitul-s wants to merge 4 commits into
mainfrom
web-shared/copy-button
Closed

mitul-s wants to merge 4 commits into
mainfrom
web-shared/copy-button

Conversation

@mitul-s

@mitul-s mitul-s commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Consolidate the observability UI's five copy-to-clipboard implementations into one CopyButton (plus TextWithCopyButton) in @workflow/web-shared.

Why

Copying worked five different ways:

  • web-shared's trace-viewer/components/copy-button.tsx reset after 1 s and dropped clipboard failures (void navigator.clipboard.writeText(...).then(...)). Sidebar, ui and event-list code imported it from under trace-viewer.
  • The web app's CopyableText, HookTokenCell and the copy part of ErrorCodeBadge each reset after 2 s and handled their own errors. CopyableText and HookTokenCell hid the button with opacity-0 group-hover, so a keyboard user tabbed onto a control they couldn't see.
  • Callers restyled the shared button with long className overrides or child selectors (copyable-data-block, error-stack-block, stream-viewer, event-details-panel). Appearance should come through props, not className overrides.

Approach

packages/web-shared/src/components/ui/copy-button.tsx follows the design system's CopyButton pattern and is built on our Button:

  • text (a string, or a function that resolves it on click; the hook token uses this to fetch the secret only when you copy it, and the button shows a spinner meanwhile), label (accessible name, default Copy to clipboard), variant (tertiary by default, secondary, or default for inverted surfaces), size (tiny | small), onCopy, onCopyError.
  • One reset duration: 1 s.
  • If the copy fails, the icon changes to an ✕ and an error toast appears through the existing useToast adapter, so host apps keep their own toast system. onCopyError replaces the toast.
  • A polite live region (<output aria-live="polite">) announces "Copied" or the failure.
  • Click propagation is stopped, because the button sits in clickable rows and headers.

TextWithCopyButton wraps text and shows the button on hover, on focus-within (so keyboard focus reveals it), and always on hover: none devices. overlay puts a secondary button over the end of the text for table cells, which is what CopyableText overlay did.

Call sites now set appearance through props. Any className left on a call site only positions the button:

Call site Before After
sidebar/copyable-data-block bordered button via className variant="secondary" + position
ui/error-stack-block red bordered button via className tertiary (default) + position
event-list/event-details-panel hover-bg override tertiary (default)
stream-viewer [&>div]/[&_svg] resize tertiary (default)
sidebar/attributes-block shrink-0 -mr-1 -my-0.5 -mr-1 so the 24px button keeps the 24px row
web CopyableText (5 uses) own component TextWithCopyButton with specific labels ("Copy run ID", "Copy hook ID", "Copy workflow name")
web HookTokenCell own copy + fetch logic TextWithCopyButton with lazy text
web ErrorCodeBadge Button + own state CopyButton variant="default" (inverted, matches the tooltip pill)

Deleted: trace-viewer/components/copy-button.tsx (never exported; the package's exports map blocks deep imports, and no external consumer was found) and the web app's copyable-text.tsx. New public exports: CopyButton, CopyButtonProps, TextWithCopyButton, TextWithCopyButtonProps.

Visual changes to expect (visuals were not rendered; please check in a preview)

  • The error block's copy button is a borderless tertiary button (gray icon) instead of a red-tinted bordered one.
  • Stream chunk copy icons are 12px (the tiny size) instead of the 16px override.
  • The web app's copy buttons no longer show a "Copy to clipboard"/"Copied!" tooltip. Instead they have a specific accessible name and a live announcement.
  • Copy buttons in the web app are 24px design-system buttons rather than 20px ad-hoc ones.

Validation

Run on current main (8e2e3cf, which includes #5518's shared cn and #5524's design tokens) with this change applied:

  • pnpm turbo typecheck test build --filter=@workflow/web-shared --filter=@workflow/web: 12/12 tasks pass. web-shared has 286 tests and web has 165, all passing.
  • biome check packages/web-shared packages/web: no errors. The warnings that remain were already there.
  • @workflow/web has no typecheck script. tsc --noEmit -p packages/web reports no errors in the touched files.

New packages/web/app/components/display-utils/copy-button.test.tsx (jsdom) covers: copy plus the polite "Copied" announcement and the 1 s reset, the failure toast and announcement, lazy text, no click propagation, and the reveal classes for hover and focus. packages/web-shared/test/error-stack-block.test.ts asserted bg-red-100, which came only from the old copy button's className override. It now asserts the block's own var(--ds-red-100) background.

Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>

Add CopyButton and TextWithCopyButton to @workflow/web-shared and replace the five separate copy implementations in web-shared and the web app.

Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
example-nextjs-workflow-turbopack Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
example-nextjs-workflow-webpack Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
example-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-astro-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-express-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-fastify-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-hono-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-nestjs-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-nitro-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-nuxt-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-python-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-sveltekit-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-tanstack-start-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workbench-vite-workflow Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workflow-docs Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workflow-swc-playground Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workflow-tarballs Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC
workflow-web Ready Ready Preview, v0 Nov 17, 2026 9:06pm UTC

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d9fe8da

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@workflow/web-shared Minor
@workflow/web Minor
@workflow/cli Patch
@workflow/nitro Patch
workflow Patch
@workflow/world-testing Patch
@workflow/nuxt Patch
@workflow/world-cloudflare Patch
@workflow/core Patch
@workflow/world-vercel Patch
@workflow/builders Patch
@workflow/next Patch
@workflow/vitest Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Sim World

Simulated world deterministic testing for races. Traces

🟢 world-sim scenario book — 0 fail of 45 total
scenario outcome events virt replay violations
✅ smoke-no-steps completed 3 0ms ok 0
✅ smoke-one-step completed 5 0ms ok 0
✅ hook-at-step-started completed 9 0ms ok 0
✅ hook-at-step-completed completed 9 0ms ok 0
✅ hook-at-hook-created completed 9 0ms ok 0
✅ claim-hook-at-registration completed 9 0ms ok 0
✅ claim-hook-at-step-started completed 9 0ms ok 0
✅ deadline-hook-wins completed 6 1.0h ok 0
✅ deadline-expires completed 6 1.0h ok 0
✅ step-vs-timer-early-settlement completed 6 1.0h ok 0
✅ long-sleep completed 9 30.0d ok 0
✅ hook-never-arrives stalled 3 0ms skipped 0
✅ step-retries-twice completed 9 2.0s ok 0
✅ parallel-steps completed 7 0ms ok 0
✅ hook-on-execution-state completed 9 0ms ok 0
✅ peek-hook-before-branch completed 9 0ms ok 0
✅ peek-hook-after-branch completed 9 0ms ok 0
✅ peek-hook-at-registration completed 9 0ms ok 0
✅ race-hook-before-probe completed 9 0ms ok 0
✅ race-hook-after-probe completed 9 0ms ok 0
✅ race-duplicate-delivery completed 10 0ms ok 0
✅ attr-hook-before-step completed 9 0ms ok 0
✅ attr-hook-after-step completed 9 0ms ok 0
✅ attr-from-step-body completed 10 0ms ok 0
✅ fork-hook-after-timeout completed 11 1.0m ok 0
✅ fork-hook-before-timeout completed 11 1.0m ok 0
✅ count-hook-after-timeout completed 13 1.0m ok 0
✅ count-hook-before-timeout completed 15 1.0m ok 0
✅ stale-read-step-count-fork completed 15 1.0m ok 0
✅ stale-read-equal-step-counts completed 11 1.0m ok 0
✅ step-vs-step-fork completed 9 0ms ok 0
✅ step-vs-step-fork-fenced completed 9 1.0s ok 0
✅ fence-catches-benign-direction completed 9 1.0s ok 0
✅ run-ahead-fenced-overlap completed 10 1.0s ok 0
✅ in-flight-before-decision completed 15 1.0m ok 0
✅ in-flight-before-decision-counted completed 13 1.0m ok 0
✅ in-flight-after-decision completed 15 2.0m ok 0
✅ stale-read-step-count-fork-fenced completed 15 1.0m ok 0
✅ fork-hook-wins completed 10 1.0m ok 0
✅ fork-timeout-wins completed 10 1.0m ok 0
✅ unclaimed-payload-under-fork completed 14 1.0m ok 0
✅ claimed-payload-under-fork completed 14 1.0m ok 0
✅ writers-independent-step-bodies completed 9 0ms ok 0
✅ writers-scripted-tempo completed 9 0ms ok 0
✅ cancel-mid-step cancelled 6 0ms skipped 0

Full trace: world-sim.txt

mitul-s and others added 3 commits November 17, 2026 16:02
Signed-off-by: Mitul Shah <[email protected]>

Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
Delete copyable-text.tsx again and switch ErrorCodeBadge to CopyButton while keeping main's shared cn import from @workflow/web-shared. Describe CopyButton neutrally in its doc comment.

Signed-off-by: Mitul Shah <[email protected]>
Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
@mitul-s mitul-s mentioned this pull request Nov 17, 2026
2 of 3 tasks
mitul-s added a commit that referenced this pull request Nov 17, 2026
### What

Deletes dead code in `@workflow/web-shared`, and removes every public
export that neither `@workflow/web` nor the Vercel dashboard
(`vercel/front`) imports, including the unused
`@workflow/web-shared/components` entry point. This is the web-shared
half of #5529. The `@workflow/web` half is in #5543, and the two PRs
don't depend on each other.

### Why

Code that nothing runs still has to be maintained and reviewed, and
every export is API we have to keep working. Consumers are expected to
update with this change rather than hold the cleanup back. The dashboard
only needs one change, listed below.

### Preview

[workflow-web
preview](https://workflow-web-git-web-shared-delete-dead-code.labs.vercel.dev/?tab=runs)

1. Open a run whose input or output contains a stream, a run reference,
a class instance or encrypted data, and go to `?tab=trace`.
2. Select the step and check that the inspector still renders stream and
run refs as links, class instances with their class name, and encrypted
fields as `Encrypted` with a Decrypt button that decrypts them.

#### Change needed in `vercel/front`

`hydrateResourceIOWithKey` is removed. Swap it for
`hydrateResourceIOAsync`, which takes the same arguments:

- `observability/(tabs)/workflows/lib/use-events-list-data.ts` (lines 8,
73, 107, 141)
- `observability/(tabs)/workflows/components/run-details-view.tsx`
(lines 9, 192)

Nothing else the dashboard imports changes (checked against front's
`main` on 2026-11-17), and front never imports the `/components`
subpath.

#### Removed exports

| Export | What happened to the code |
| --- | --- |
| `hydrateResourceIOWithKey` | Deleted. It only forwarded to
`hydrateResourceIOAsync`. |
| `MenuDropdown`, `MenuDropdownOption` | Deleted. Unused here, in front,
and anywhere else in the org (`gh search code --owner vercel`). |
| `materializeSteps`, `materializeHooks`, `materializeWaits`,
`materializeAll` and the `Materialized*` types | Deleted
`lib/event-materialization.ts` and its tests. Only `index.ts` and tests
imported it. |
| `shouldShowReenqueueButton`, `hasPendingStepsFromEvents`,
`hasPendingHooksFromEvents`, `isTerminalStatus` | Deleted.
`analyzeEvents` stays. |
| `identifyStreamSteps`, `StreamStep` | Deleted. |
| `looksLikeWorkflowIdSearchInput` | Deleted, along with its tests. |
| `CLASS_INSTANCE_REF_TYPE`, `ClassInstanceRef`, `extractStreamIds`,
`isClassInstanceRef`, `isStreamId`, `isStreamRef`, `STREAM_REF_TYPE`,
`truncateId`, `StreamRef` | Re-exports from
`@workflow/core/serialization-format`. Import them from there. |
| `hookEventsToHookEntity`, `isEncryptedMarker`,
`DUPLICATE_EVENT_MESSAGE`, `findDuplicateEventIds`, `isSealedNoopEvent`,
`SEALED_EVENT_MESSAGE`, `parseExactWorkflowSearchId`,
`ExactWorkflowSearchId`, `isQuickJSSnapshotRun`, `extractConversation`,
`isDoStreamStep`, `formatDurationPrecise`, `DecodedStreamChunkSource`,
`useToast` | Still used inside the package. Only the export from the
entry point goes. |
| `ResolveHookModal`, `ConversationView`, `SidebarDataProvider`,
`SelectedSpanInfo`, `DecryptClickContext`, `DecryptClickContextValue`,
`IconButton`, `Kbd`, `LoadMoreButton` | Same: used internally, no longer
exported. |

#### Kept on purpose

- Types that are part of an API that stays public, so callers can
annotate what they pass in or get back: `ButtonProps`,
`DataInspectorProps`, the
`useHookActions`/`HookResolveModalWrapper`/`ResolveHookDropdownItem`
prop and option types, `EventAnalysis`,
`RunLimitGuidance`/`RunLimitGuidanceKind`,
`RunStateHydratorOptions`/`StateHistoryPage` (the docs describe
`createRunStateHydrator` for custom inspectors), and
`SpanSelectionInfo`/`DetailResource` (the arguments and result of
`FetchSpanDetail`).
- `SpanEvent`, which is part of `Span`, and which the v5 What's New page
says is still exported.
- `collapseRefs` and `isDeepEqual` stay exported from their modules for
their tests.

#### Other cleanup

- Deleted `ui/card.tsx` and `ui/alert.tsx` (unused copies of web's
shadcn components), `hooks/use-dark-mode.ts`, `DuplicateEventTooltip`,
and the unused `getPaginationDisplay` in `lib/utils.ts`.
- Deleted `src/index.d.ts` and `src/components/index.d.ts`: tsc ignores
a `.d.ts` next to a `.ts` of the same name, and the published types come
from `dist/`.
- `ui/data-inspector.tsx` drops its private copies of the ref type
guards and imports them from `lib/hydration.ts`.
- Dropped `export` from symbols that only their own file uses
(`AttributeBlock`, `DetailKeyValueRow`, `sortAttributeKeys`,
`TimelineBar`, `kbdVariants`,
`MIN_START`/`MIN_END`/`MeasureFn`/`TruncateResult`,
`EXPIRED_DISPLAY_NAME`, `summarizeArrayBufferView`, `isRunLevelEvent`,
`convertEventsToSpanEvents`).
- Comments that still mentioned `ObjectInspector` now say
`DataInspector`.
- Removed the unused `shiki` dependency. The lockfile diff is three
deleted lines.

#### Overlap with other open PRs

- #5557 rebuilds `MenuDropdown` on Radix, but this PR deletes it because
nothing uses it. Only one of the two should land.
- #5528 edits `lib/event-materialization.ts` and `start-hook.test.ts`,
which this PR deletes and trims. Whichever lands second resolves the
conflict by keeping the deletion.
- #5522, #5523, #5528 and #5530 edit the same entry-point barrels
(`src/index.ts`, `src/components/index.ts`), so expect small conflicts
there.

#### Differences from #5529

- #5529's sync with `main` restored `ui/alert.tsx` and `shiki` by taking
`main`'s copies of conflicting files. This PR deletes them again because
they are still unused on `main`.
- #5529 kept `hydrateResourceIOWithKey` as a deprecated alias for the
dashboard. This PR removes it.

### How did you test your changes?

- `pnpm turbo typecheck test build --filter=@workflow/web-shared` on the
first commit: 10/10 tasks passed.
- `pnpm typecheck` in `packages/web-shared`: no errors.
- `pnpm vitest run` in `packages/web-shared`: 34 files, 276 tests
passed. Ten fewer than `main`: the seven `event-materialization` tests,
the start Hook materialization test, and the two
`looksLikeWorkflowIdSearchInput` tests, all of which covered deleted
code.
- `pnpm turbo build test --filter=@workflow/web` against this branch:
10/10 passed, so `web` builds on the smaller API. `react-router typegen
&& tsc --noEmit` in `packages/web` reports the same 19 errors as `main`.
- `pnpm biome check packages/web-shared`: no errors.
- Export audit: every remaining export from `src/index.ts` is imported
by `packages/web` or front, apart from the types kept on purpose above.
- Visuals were not rendered. The only runtime change is
`DataInspector`'s ref detection, which now uses the `@workflow/core`
guards. They check `__type` with `in`, so they also match the
non-enumerable opaque refs that `collapseRefs` builds, and the existing
`DataInspector`/`collapseRefs` tests pass.

### PR Checklist - Required to merge

- [x] 📦 `pnpm changeset` was run to create a changelog for this PR
- Use the correct semver bump type: `patch` for bug fixes, `minor` for
new features, `major` for breaking changes.
- Use `pnpm changeset --empty` if you are changing documentation or
workbench apps
- [x] 🔒 DCO sign-off passes (run `git commit --signoff` on your commits)
- [ ] 📝 Ping `@vercel/workflow` in a comment once the PR is ready, and
the above checklist is complete

_Written by fx_

---------

Signed-off-by: mitul-s <[email protected]>
@mitul-s mitul-s closed this Nov 18, 2026

This branch was successfully deployed

1 active deployment
Preview – workflow-docs — d9fe8daf Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant