mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
ad5c068d7f
* Add server-backed exact ID search to the Events tab. Replace client-side substring filtering with API lookups for full correlation and event IDs so searches work beyond the first loaded page. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix exact ID search dimming and support wrun_ correlation IDs. Disable group dimming for server search results and accept run IDs in the exact ID parser so run-level correlation search works. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix dimmed row when searching by event ID for run-level events. Map selectedGroupKey to __run__ for run-level search results so the matched row is treated as related instead of dimmed. Co-authored-by: Cursor <cursoragent@cursor.com> * Remove run ID search from Events tab exact ID lookup. Workflow-server only accepts step, wait, and hook correlation IDs — not wrun_. Update the search placeholder and validation toast accordingly. Co-authored-by: Cursor <cursoragent@cursor.com> * Harden exact ID search UX and correlation fetch limits. Normalize lowercase ULIDs, scope Enter toasts to ID-like input, abort stale searches, disable search when unavailable, expand parser tests, and cap correlation pagination in workflow web. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix search clear race and surface truncated correlation results. Guard successful exact-ID search against aborted requests, invalidate in-flight work when the input clears, and return truncation metadata from correlation pagination. Co-authored-by: Cursor <cursoragent@cursor.com> * Differentiate exact ID search errors from not-found results. Return a discriminated union from onExactIdSearch and show search errors in the Events tab instead of mislabeling them as missing IDs. Co-authored-by: Cursor <cursoragent@cursor.com> * Apply suggestion from @VaguelySerious Signed-off-by: Peter Wielander <mittgfu@gmail.com> --------- Signed-off-by: Peter Wielander <mittgfu@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Peter Wielander <mittgfu@gmail.com>
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
looksLikeWorkflowIdSearchInput,
|
|
parseExactWorkflowSearchId,
|
|
} from '../src/lib/exact-event-search-id.js';
|
|
|
|
describe('parseExactWorkflowSearchId', () => {
|
|
it('accepts full step IDs', () => {
|
|
const id = 'step_01KSG94DWMWZRQBK04D3GS2CAQ';
|
|
expect(parseExactWorkflowSearchId(id)).toEqual({
|
|
kind: 'step',
|
|
id,
|
|
});
|
|
});
|
|
|
|
it('accepts full wait IDs', () => {
|
|
const id = 'wait_01KSG94DWMWZRQBK04D3GS2CAQ';
|
|
expect(parseExactWorkflowSearchId(id)).toEqual({
|
|
kind: 'wait',
|
|
id,
|
|
});
|
|
});
|
|
|
|
it('accepts full hook IDs', () => {
|
|
const id = 'hook_01KSG94DWMWZRQBK04D3GS2CAQ';
|
|
expect(parseExactWorkflowSearchId(id)).toEqual({
|
|
kind: 'hook',
|
|
id,
|
|
});
|
|
});
|
|
|
|
it('accepts full event IDs', () => {
|
|
const id = 'evnt_01KSG94CMGCPMC3PPACDCJR9AQ';
|
|
expect(parseExactWorkflowSearchId(id)).toEqual({
|
|
kind: 'event',
|
|
id,
|
|
});
|
|
});
|
|
|
|
it('normalizes lowercase ULID bodies to uppercase', () => {
|
|
expect(
|
|
parseExactWorkflowSearchId('step_01ksg94dwmwzrqbk04d3gs2caq')
|
|
).toEqual({
|
|
kind: 'step',
|
|
id: 'step_01KSG94DWMWZRQBK04D3GS2CAQ',
|
|
});
|
|
});
|
|
|
|
it('trims leading and trailing whitespace', () => {
|
|
const id = 'evnt_01KSG94CMGCPMC3PPACDCJR9AQ';
|
|
expect(parseExactWorkflowSearchId(` ${id} `)).toEqual({
|
|
kind: 'event',
|
|
id,
|
|
});
|
|
});
|
|
|
|
it('rejects partial IDs and run IDs', () => {
|
|
expect(parseExactWorkflowSearchId('step_01KSG94')).toBeNull();
|
|
expect(parseExactWorkflowSearchId('wait_01KSG94')).toBeNull();
|
|
expect(parseExactWorkflowSearchId('hook_01KSG94')).toBeNull();
|
|
expect(parseExactWorkflowSearchId('evnt_01KSG94')).toBeNull();
|
|
expect(
|
|
parseExactWorkflowSearchId('wrun_01KSG94CFWFBPBYWW3PX7SF73W')
|
|
).toBeNull();
|
|
});
|
|
|
|
it('rejects IDs with illegal Crockford characters or wrong length', () => {
|
|
expect(
|
|
parseExactWorkflowSearchId('step_01ISG94DWMWZRQBK04D3GS2CAQ')
|
|
).toBeNull();
|
|
expect(
|
|
parseExactWorkflowSearchId('step_01KSG94DWMWZRQBK04D3GS2CA')
|
|
).toBeNull();
|
|
expect(
|
|
parseExactWorkflowSearchId('step_01KSG94DWMWZRQBK04D3GS2CAQQ')
|
|
).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('looksLikeWorkflowIdSearchInput', () => {
|
|
it('matches known workflow ID prefixes', () => {
|
|
expect(looksLikeWorkflowIdSearchInput('step_01KSG94')).toBe(true);
|
|
expect(looksLikeWorkflowIdSearchInput('wrun_01KSG94')).toBe(true);
|
|
expect(looksLikeWorkflowIdSearchInput('EVNT_01KSG94')).toBe(true);
|
|
});
|
|
|
|
it('does not match free-text search input', () => {
|
|
expect(looksLikeWorkflowIdSearchInput('parseInvoice')).toBe(false);
|
|
expect(looksLikeWorkflowIdSearchInput('step_started')).toBe(false);
|
|
});
|
|
});
|