From 6a56c1e2b4c6c5872c208bd569aed9fcb7875888 Mon Sep 17 00:00:00 2001 From: Quang Nguyen <39874396+QuangNg14@users.noreply.github.com> Date: Fri, 27 Nov 2026 15:15:15 -0800 Subject: [PATCH 1/2] Show event names and timer durations in compact workflow history Populate the text table from the current history event, without fetching or retaining other events. The detailed and protobuf JSON paths are unchanged. Assisted-by: GitHub Copilot --- .../temporalcli/commands.workflow_exec.go | 34 ++++++++++++++++--- .../commands.workflow_show_test.go | 19 +++++++++++ .../commands.workflow_view_test.go | 2 +- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/internal/temporalcli/commands.workflow_exec.go b/internal/temporalcli/commands.workflow_exec.go index cef46fdf2..badfee8ba 100644 --- a/internal/temporalcli/commands.workflow_exec.go +++ b/internal/temporalcli/commands.workflow_exec.go @@ -849,11 +849,36 @@ type structuredHistoryEvent struct { Time string `cli:",width=20"` // We're going to set width to a semi-reasonable number for good header // placement, but we expect it to extend past for larger - Type string `cli:",width=26"` + Type string `cli:",width=26"` + Details string } var structuredHistoryEventType = reflect.TypeOf(structuredHistoryEvent{}) +func compactHistoryDetails(event *history.HistoryEvent) string { + switch a := event.Attributes.(type) { + case *history.HistoryEvent_WorkflowExecutionStartedEventAttributes: + return a.WorkflowExecutionStartedEventAttributes.GetWorkflowType().GetName() + case *history.HistoryEvent_WorkflowTaskScheduledEventAttributes: + return a.WorkflowTaskScheduledEventAttributes.GetTaskQueue().GetName() + case *history.HistoryEvent_ActivityTaskScheduledEventAttributes: + return a.ActivityTaskScheduledEventAttributes.GetActivityType().GetName() + case *history.HistoryEvent_StartChildWorkflowExecutionInitiatedEventAttributes: + return a.StartChildWorkflowExecutionInitiatedEventAttributes.GetWorkflowType().GetName() + case *history.HistoryEvent_WorkflowExecutionSignaledEventAttributes: + return a.WorkflowExecutionSignaledEventAttributes.GetSignalName() + case *history.HistoryEvent_WorkflowExecutionUpdateAdmittedEventAttributes: + return a.WorkflowExecutionUpdateAdmittedEventAttributes.GetRequest().GetInput().GetName() + case *history.HistoryEvent_WorkflowExecutionUpdateAcceptedEventAttributes: + return a.WorkflowExecutionUpdateAcceptedEventAttributes.GetAcceptedRequest().GetInput().GetName() + case *history.HistoryEvent_TimerStartedEventAttributes: + if timeout := a.TimerStartedEventAttributes.GetStartToFireTimeout(); timeout != nil { + return timeout.AsDuration().String() + } + } + return "" +} + func (s *structuredHistoryIter) Next() (any, error) { event, err := s.NextRawEvent() if err != nil { @@ -868,9 +893,10 @@ func (s *structuredHistoryIter) Next() (any, error) { typeName = coloredEventType(event.EventType) } data := structuredHistoryEvent{ - ID: event.EventId, - Time: event.EventTime.AsTime().Format(time.RFC3339), - Type: typeName, + ID: event.EventId, + Time: event.EventTime.AsTime().Format(time.RFC3339), + Type: typeName, + Details: compactHistoryDetails(event), } // Follow continue as new (forward only; reverse traversal stays within the requested run) diff --git a/internal/temporalcli/commands.workflow_show_test.go b/internal/temporalcli/commands.workflow_show_test.go index 0f70449a5..030ab2ef3 100644 --- a/internal/temporalcli/commands.workflow_show_test.go +++ b/internal/temporalcli/commands.workflow_show_test.go @@ -2,12 +2,31 @@ package temporalcli import ( "testing" + "time" "github.com/stretchr/testify/require" "go.temporal.io/api/enums/v1" historypb "go.temporal.io/api/history/v1" + "google.golang.org/protobuf/types/known/durationpb" ) +func TestCompactHistoryDetails(t *testing.T) { + timer := &historypb.TimerStartedEventAttributes{StartToFireTimeout: durationpb.New(90 * time.Second)} + event := &historypb.HistoryEvent{Attributes: &historypb.HistoryEvent_TimerStartedEventAttributes{ + TimerStartedEventAttributes: timer, + }} + require.Equal(t, "1m30s", compactHistoryDetails(event)) + timer.StartToFireTimeout = nil + require.Empty(t, compactHistoryDetails(event)) + + // Accepted updates need not carry the original request. + require.Empty(t, compactHistoryDetails(&historypb.HistoryEvent{ + Attributes: &historypb.HistoryEvent_WorkflowExecutionUpdateAcceptedEventAttributes{ + WorkflowExecutionUpdateAcceptedEventAttributes: &historypb.WorkflowExecutionUpdateAcceptedEventAttributes{}, + }, + })) +} + func TestSystemNexusOpDisplayName(t *testing.T) { const op = "SignalWithStartWorkflowExecution" // present in the global systemNexusOps registry const futureOp = "FutureUnregisteredOperation" // intentionally NOT in the global registry diff --git a/internal/temporalcli/commands.workflow_view_test.go b/internal/temporalcli/commands.workflow_view_test.go index 0d9c22313..f4bd34551 100644 --- a/internal/temporalcli/commands.workflow_view_test.go +++ b/internal/temporalcli/commands.workflow_view_test.go @@ -329,7 +329,7 @@ func (s *SharedServerSuite) testWorkflowShowFollow(detailed bool) { s.Contains(output, "input[0]: ignored") s.Contains(output, "signalName: my-signal") } else { - s.Contains(output, "WorkflowExecutionSignaled") + s.ContainsOnSameLine(output, "WorkflowExecutionSignaled", "my-signal") } } From 0c38b32b61f420c832f2be1f221521048d720127 Mon Sep 17 00:00:00 2001 From: Quang Nguyen <39874396+QuangNg14@users.noreply.github.com> Date: Fri, 27 Nov 2026 17:51:04 -0800 Subject: [PATCH 2/2] Test the name of an accepted workflow update in compact history Assisted-by: GitHub Copilot --- internal/temporalcli/commands.workflow_show_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/temporalcli/commands.workflow_show_test.go b/internal/temporalcli/commands.workflow_show_test.go index 030ab2ef3..d61cf938e 100644 --- a/internal/temporalcli/commands.workflow_show_test.go +++ b/internal/temporalcli/commands.workflow_show_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "go.temporal.io/api/enums/v1" historypb "go.temporal.io/api/history/v1" + updatepb "go.temporal.io/api/update/v1" "google.golang.org/protobuf/types/known/durationpb" ) @@ -20,11 +21,15 @@ func TestCompactHistoryDetails(t *testing.T) { require.Empty(t, compactHistoryDetails(event)) // Accepted updates need not carry the original request. - require.Empty(t, compactHistoryDetails(&historypb.HistoryEvent{ + accepted := &historypb.WorkflowExecutionUpdateAcceptedEventAttributes{} + updateEvent := &historypb.HistoryEvent{ Attributes: &historypb.HistoryEvent_WorkflowExecutionUpdateAcceptedEventAttributes{ - WorkflowExecutionUpdateAcceptedEventAttributes: &historypb.WorkflowExecutionUpdateAcceptedEventAttributes{}, + WorkflowExecutionUpdateAcceptedEventAttributes: accepted, }, - })) + } + require.Empty(t, compactHistoryDetails(updateEvent)) + accepted.AcceptedRequest = &updatepb.Request{Input: &updatepb.Input{Name: "change-address"}} + require.Equal(t, "change-address", compactHistoryDetails(updateEvent)) } func TestSystemNexusOpDisplayName(t *testing.T) {