Skip to content

Commit

Permalink
Show event ID in history view (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
bergundy authored Nov 9, 2023
1 parent 918ec1a commit b786f3b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion webview/src/utilities/label-text-for-history-event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("labelTextForHistoryEvent", () => {
it("should format the event type name with the workflow type name for a WorkflowExecutionStarted event", () => {
const workflowExecutionStartedEvent = workflowTasks[0].events[0]
expect(labelTextForHistoryEvent(workflowExecutionStartedEvent)).toBe(
"WorkflowExecutionStarted (workflow.completion)",
"[1] WorkflowExecutionStarted (workflow.completion)",
)
})
})
8 changes: 4 additions & 4 deletions webview/src/utilities/label-text-for-history-event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import humanizeDuration from "humanize-duration"
import { temporal } from "@temporalio/proto"
import { tsToDate } from "@temporalio/common"
import { optionalTsToMs } from "@temporalio/common/lib/time"
import type { CategorizedEvent } from "../lib"

function labelDetailsForHistoryEvent(event: CategorizedEvent) {
Expand All @@ -12,7 +12,7 @@ function labelDetailsForHistoryEvent(event: CategorizedEvent) {
case temporal.api.enums.v1.EventType.EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED:
return `(${event.workflowExecutionSignaledEventAttributes?.signalName})`
case temporal.api.enums.v1.EventType.EVENT_TYPE_TIMER_STARTED:
return `⏱ (${humanizeDuration(tsToDate(event.timerStartedEventAttributes?.startToFireTimeout!).getTime())})`
return `⏱ (${humanizeDuration(optionalTsToMs(event.timerStartedEventAttributes?.startToFireTimeout) ?? 0)})`
case temporal.api.enums.v1.EventType.EVENT_TYPE_TIMER_FIRED:
return `⏱🔥`
case temporal.api.enums.v1.EventType.EVENT_TYPE_TIMER_CANCELED:
Expand All @@ -21,7 +21,7 @@ function labelDetailsForHistoryEvent(event: CategorizedEvent) {
}

export function labelTextForHistoryEvent(event: CategorizedEvent): string {
const { eventType } = event
const { eventId, eventType } = event

if (eventType === undefined || eventType === null) {
throw new TypeError("Expected history event `eventType` to be defined")
Expand All @@ -34,5 +34,5 @@ export function labelTextForHistoryEvent(event: CategorizedEvent): string {
.join("")
const details = labelDetailsForHistoryEvent(event)

return `${eventTypeName} ${details ?? ""}`
return `[${eventId}] ${eventTypeName} ${details ?? ""}`
}
2 changes: 1 addition & 1 deletion webview/src/views/history.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<p>Workflow Task ({workflowTask.status})</p>
</div>
{#each workflowTask.events as event}
<li>
<li title={`Event ID: ${event.eventId}`}>
{#if event?.category === "COMMAND"}
<Icon name="arrow-left" />
{:else}
Expand Down

0 comments on commit b786f3b

Please sign in to comment.