Files
vercel__workflow/packages/web/app/lib/workflow-api-client.ts
Mitul Shah 8393716687 Fix trace detail panel Input/Output flicker (selection-driven state machine) (#2637)
* Add selection-driven span-detail primitives

Extract the run/step/hook/sleep fetch+hydrate core out of useWorkflowResourceData
into a plain async fetchSpanDetailResource (no React state), and add a
selection-driven state machine in web-shared:

- deriveSpanDetailView / resourceNeedsFetchedDetail: pure view-model deriver
  whose status (idle/loading/ready/error) is a function of (selection, fetched
  detail), so it can never lag the selection.
- useSelectedSpanDetail: fetches a selected span's detail directly with a
  request-token to drop stale/out-of-order responses.

* Drive trace detail panel from the span-detail state machine

Replace the cross-package selection round-trip (EntityDetailPanel useEffect ->
onSpanSelect -> page spanSelection state -> useWorkflowResourceData -> context)
with a single injected fetchSpanDetail capability:

- EntityDetailPanel consumes useSelectedSpanDetail; its loading state now stays
  in phase with the selected span, so Input/Output no longer vanish and pop back
  in while navigating.
- SidebarDataContext drops spanDetailData/Loading/Error + onSpanSelect for a
  single fetchSpanDetail; RunDetailView injects it and drops the duplicate
  spanSelection state.
- WorkflowTraceViewer / RunTraceView take fetchSpanDetail too.

* Test span-detail view-model transitions; add changeset

Cover deriveSpanDetailView (idle/loading/ready/error, stale-detail rejection,
hooks ready inline) and resourceNeedsFetchedDetail.

* Trim redundant/narrative comments in span-detail state machine

Comment-only cleanup: drop PR-narration and cross-file duplication from the
deriveSpanDetailView / useSelectedSpanDetail / EntityDetailPanel / fetchSpanDetail
doc comments, keeping the non-obvious intent (request-token, error scoping,
decrypt closure).

* delete pointless coments

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-06-26 16:42:47 -04:00

42 lines
1.5 KiB
TypeScript

/**
* Barrel re-export for backward compatibility.
*
* All public APIs are defined in focused modules under:
* - ~/lib/client/workflow-errors.ts (error class, unwrap helpers)
* - ~/lib/client/workflow-primitives.ts (generic data-fetching utilities)
* - ~/lib/client/workflow-actions.ts (server action wrappers)
* - ~/lib/client/workflow-streams.ts (stream read/list functions)
* - ~/lib/client/hooks/use-paginated-list.ts (pagination hooks)
* - ~/lib/client/hooks/use-trace-viewer.ts (trace viewer data hook)
* - ~/lib/client/hooks/use-resource-data.ts (resource detail hook)
* - ~/lib/client/hooks/use-workflow-streams.ts (streams list hook)
*
* Consumers can import directly from those modules or from this barrel.
*/
export type { ResumeHookResult } from '~/lib/types';
export {
usePaginatedList,
useWorkflowHooks,
useWorkflowRuns,
} from './client/hooks/use-paginated-list';
export {
fetchSpanDetailResource,
useWorkflowResourceData,
} from './client/hooks/use-resource-data';
export { useWorkflowTraceViewerData } from './client/hooks/use-trace-viewer';
export { useWorkflowStreams } from './client/hooks/use-workflow-streams';
export {
cancelRun,
recreateRun,
reenqueueRun,
resumeHook,
wakeUpRun,
} from './client/workflow-actions';
export {
getErrorMessage,
unwrapServerActionResult,
WorkflowWebAPIError,
} from './client/workflow-errors';
export { listStreams, readStream } from './client/workflow-streams';