Skip to content

Commit 1ea509b

Browse files
authored
Use links attached to callbacks and support requestId links (#2742)
* Update packages and EventLink type. Add support for links in callback * Add support for requestId to find the event by requestId * Better link logic, fix visibleItems * Make optional
1 parent d831ccc commit 1ea509b

14 files changed

Lines changed: 277 additions & 113 deletions

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@
136136
"@sveltejs/adapter-vercel": "^4.0.0",
137137
"@sveltejs/kit": "^2.20.2",
138138
"@sveltejs/vite-plugin-svelte": "^5.0.3",
139-
"@temporalio/activity": "1.11.6",
140-
"@temporalio/client": "1.11.6",
141-
"@temporalio/common": "1.11.6",
142-
"@temporalio/proto": "1.11.6",
143-
"@temporalio/testing": "1.11.6",
144-
"@temporalio/worker": "1.11.6",
145-
"@temporalio/workflow": "1.11.6",
139+
"@temporalio/activity": "1.11.8",
140+
"@temporalio/client": "1.11.8",
141+
"@temporalio/common": "1.11.8",
142+
"@temporalio/proto": "1.11.8",
143+
"@temporalio/testing": "1.11.8",
144+
"@temporalio/worker": "1.11.8",
145+
"@temporalio/workflow": "1.11.8",
146146
"@types/base-64": "^1.0.0",
147147
"@types/cors": "^2.8.13",
148148
"@types/express": "^4.17.17",

pnpm-lock.yaml

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/labstack/echo/v4 v4.9.1
1212
github.com/stretchr/testify v1.10.0
1313
github.com/urfave/cli/v2 v2.3.0
14-
go.temporal.io/api v1.47.0
14+
go.temporal.io/api v1.49.1
1515
golang.org/x/net v0.38.0
1616
golang.org/x/oauth2 v0.30.0
1717
google.golang.org/grpc v1.66.0

server/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
7575
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
7676
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
7777
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
78-
go.temporal.io/api v1.47.0 h1:0pg8wZC9Jv79iMpe6jXMPQzADQJ5OiPuklYfC51bXGM=
79-
go.temporal.io/api v1.47.0/go.mod h1:iaxoP/9OXMJcQkETTECfwYq4cw/bj4nwov8b3ZLVnXM=
78+
go.temporal.io/api v1.49.1 h1:CdiIohibamF4YP9k261DjrzPVnuomRoh1iC//gZ1puA=
79+
go.temporal.io/api v1.49.1/go.mod h1:iaxoP/9OXMJcQkETTECfwYq4cw/bj4nwov8b3ZLVnXM=
8080
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
8181
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
8282
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=

src/lib/components/event/event-link.svelte

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,16 @@
22
import Link from '$lib/holocene/link.svelte';
33
import { translate } from '$lib/i18n/translate';
44
import type { EventLink } from '$lib/types/events';
5-
import {
6-
routeForEventHistory,
7-
routeForEventHistoryEvent,
8-
} from '$lib/utilities/route-for';
5+
import { getEventLinkHref } from '$lib/utilities/event-link-href';
96
107
export let link: EventLink;
118
export let value = link.workflowEvent.workflowId;
129
export let label = translate('nexus.link');
1310
export let href: string | undefined = undefined;
1411
1512
$: if (!href) {
16-
if (link.workflowEvent?.eventRef?.eventId) {
17-
href = routeForEventHistoryEvent({
18-
namespace: link.workflowEvent.namespace,
19-
workflow: link.workflowEvent.workflowId,
20-
run: link.workflowEvent.runId,
21-
eventId: link.workflowEvent.eventRef.eventId,
22-
});
23-
value = `${link.workflowEvent.workflowId}/history/events/${link.workflowEvent.eventRef.eventId}`;
24-
} else if (
25-
link.workflowEvent?.eventRef?.eventType ===
26-
'EVENT_TYPE_WORKFLOW_EXECUTION_STARTED'
27-
) {
28-
href = routeForEventHistoryEvent({
29-
namespace: link.workflowEvent.namespace,
30-
workflow: link.workflowEvent.workflowId,
31-
run: link.workflowEvent.runId,
32-
eventId: '1',
33-
});
34-
value = `${link.workflowEvent.workflowId}/history/events/1`;
35-
} else {
36-
href = routeForEventHistory({
37-
namespace: link.workflowEvent.namespace,
38-
workflow: link.workflowEvent.workflowId,
39-
run: link.workflowEvent.runId,
40-
});
41-
value = `${link.workflowEvent.workflowId}/history`;
42-
}
13+
href = getEventLinkHref(link);
14+
value = href.split('workflows/')?.[1] || href;
4315
}
4416
</script>
4517

src/lib/components/workflow/workflow-callback.svelte

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
24
import Alert from '$lib/holocene/alert.svelte';
35
import Badge from '$lib/holocene/badge.svelte';
46
import CodeBlock from '$lib/holocene/code-block.svelte';
@@ -12,14 +14,21 @@
1214
1315
import EventLink from '../event/event-link.svelte';
1416
15-
export let callback: Callback;
16-
export let link: Link | undefined = undefined;
17+
let {
18+
callback,
19+
link,
20+
children,
21+
}: { callback: Callback; link?: Link; children?: Snippet } = $props();
1722
18-
$: completedTime = formatDate(callback.lastAttemptCompleteTime, $timeFormat);
19-
$: nextTime = formatDate(callback.nextAttemptScheduleTime, $timeFormat);
20-
$: failure = callback?.lastAttemptFailure?.message;
21-
$: blockedReason = callback?.blockedReason;
22-
$: callbackUrl = callback?.callback?.nexus?.url;
23+
const completedTime = $derived(
24+
formatDate(callback.lastAttemptCompleteTime, $timeFormat),
25+
);
26+
const nextTime = $derived(
27+
formatDate(callback.nextAttemptScheduleTime, $timeFormat),
28+
);
29+
const failure = $derived(callback?.lastAttemptFailure?.message);
30+
const blockedReason = $derived(callback?.blockedReason);
31+
const callbackUrl = $derived(callback?.callback?.nexus?.url);
2332
2433
const titles = {
2534
Standby: translate('nexus.callback.standby'),
@@ -30,13 +39,26 @@
3039
};
3140
3241
const failedState = 'Failed' as unknown as CallbackState;
33-
$: failed = callback.state === failedState;
34-
$: title = titles[callback.state] || translate('nexus.nexus-callback');
42+
const failed = $derived(callback.state === failedState);
43+
const title = $derived(
44+
titles[callback.state] || translate('nexus.nexus-callback'),
45+
);
46+
const links = $derived(callback?.callback?.links || []);
3547
</script>
3648

3749
<Alert icon="nexus" intent={failed ? 'error' : 'info'} {title}>
3850
<div class="flex flex-col gap-2 pt-2">
39-
{#if link}
51+
{#if links.length}
52+
{#each links as link (link.workflowEvent?.eventRef?.eventId || link.workflowEvent?.requestIdRef.requestId)}
53+
<EventLink {link} />
54+
<EventLink
55+
{link}
56+
label={translate('nexus.link-namespace')}
57+
value={link.workflowEvent.namespace}
58+
href={routeForNamespace({ namespace: link.workflowEvent.namespace })}
59+
/>
60+
{/each}
61+
{:else if link}
4062
<EventLink {link} />
4163
<EventLink
4264
{link}
@@ -92,5 +114,5 @@
92114
</div>
93115
{/if}
94116
</div>
95-
<slot />
117+
{@render children?.()}
96118
</Alert>

src/lib/components/workflow/workflow-callbacks.svelte

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
66
import WorkflowCallback from './workflow-callback.svelte';
77
8-
export let callbacks: Callback[];
8+
let { callbacks }: { callbacks: Callback[] } = $props();
99
10-
$: initialEvent = $fullEventHistory[0];
11-
$: link = initialEvent?.links?.[0];
12-
13-
$: firstCallback = callbacks[0];
10+
const initialEvent = $derived($fullEventHistory[0]);
11+
const link = $derived(initialEvent?.links?.[0]);
12+
const firstCallback = $derived(callbacks[0]);
1413
</script>
1514

1615
<WorkflowCallback callback={firstCallback} {link}>

src/lib/pages/workflow-history-event.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { eventFilterSort } from '$lib/stores/event-view';
1010
import { fullEventHistory } from '$lib/stores/events';
1111
import { workflowRun } from '$lib/stores/workflow-run';
12+
import { isNexusOperationScheduledEvent } from '$lib/utilities/is-event-type';
1213
1314
$: ({
1415
id: eventId,
@@ -55,7 +56,15 @@
5556
? ascendingGroups
5657
: [...ascendingGroups].reverse();
5758
58-
$: visibleItems = $fullEventHistory.filter((e) => ids.includes(e.id));
59+
$: initialEvent = $fullEventHistory.find(
60+
(e) =>
61+
eventId === e.id ||
62+
(isNexusOperationScheduledEvent(e) &&
63+
eventId === e.attributes?.requestId),
64+
);
65+
$: visibleItems = $fullEventHistory.filter(
66+
(e) => ids.includes(e.id) || e.id === initialEvent?.id,
67+
);
5968
$: loading = !visibleItems.length;
6069
6170
const loadPrevious = () => {
@@ -108,7 +117,7 @@
108117
<EventSummaryRow
109118
{event}
110119
{index}
111-
expanded={event.id === eventId}
120+
expanded={event.id === initialEvent?.id}
112121
group={groups.find((g) => isEvent(event) && g.eventIds.has(event.id))}
113122
initialItem={$fullEventHistory[0]}
114123
/>

0 commit comments

Comments
 (0)