Skip to content

List workflow stage threads - #380

Draft
almirsarajcic wants to merge 1 commit into
basecamp:mainfrom
almirsarajcic:feature/workflow-stage-view
Draft

List workflow stage threads#380
almirsarajcic wants to merge 1 commit into
basecamp:mainfrom
almirsarajcic:feature/workflow-stage-view

Conversation

@almirsarajcic

@almirsarajcic almirsarajcic commented Sep 1, 2026

Copy link
Copy Markdown

Adds hey workflow stage view <workflow-id> <stage-id> for listing every thread in a stage.\n\nDepends on basecamp/hey-sdk#141.


Summary by cubic

Adds hey workflow stage view <workflow-id> <stage-id> for listing every thread currently in a workflow stage. Previously the CLI had no way to see a stage's contents.

New Features

  • Returns each thread's topic_id, subject, and email count for use with hey thread read.
  • Table output shows thread ID, subject, and email count; JSON output includes the stage ID and name.

Dependencies

  • Pins github.com/almirsarajcic/hey-sdk/go via a replace directive until the upstream SDK exposes stage topics.

Written for commit 42c0366. Summary will update on new commits.

Review in cubic

@almirsarajcic
almirsarajcic force-pushed the feature/workflow-stage-view branch from 49ad1a5 to 42c0366 Compare September 1, 2026 12:45

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/cmd/workflow.go">

<violation number="1" location="internal/cmd/workflow.go:505">
P2: When users request `--ids-only` or `--count`, this command passes the wrapper object to `writeOK`, so the generic writer rejects it because it is not a list. Handle these formats using `view.Topics` (and emit each `TopicID` for `--ids-only`) before writing the normal stage object.</violation>
</file>

<file name="internal/cmd/workflow_test.go">

<violation number="1" location="internal/cmd/workflow_test.go:173">
P3: The new `workflow stage view` command has a separate `writer.IsStyled()` output path in `workflow.go` that renders a table ("Thread / Subject / Emails") and returns before `writeOK`, but this test only exercises the JSON path. The sibling tests (`TestWorkflowCommandOutputFormats`, `TestWorkflowStyledOutputSanitizesNames`) use `runStyledCommand` to cover styled output for exactly this reason. Add a styled-output assertion so the table branch of the new command isn't left untested.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/cmd/workflow.go
table.print()
return nil
}
return writeOK(view, output.WithSummary(fmt.Sprintf("%d %s in workflow stage %s", len(view.Topics), threadNoun(len(view.Topics)), terminal.SanitizeLine(view.Name))), output.WithBreadcrumbs(output.Breadcrumb{Action: "read", Command: "hey thread read <thread-id>", Description: "Read an email thread"}))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When users request --ids-only or --count, this command passes the wrapper object to writeOK, so the generic writer rejects it because it is not a list. Handle these formats using view.Topics (and emit each TopicID for --ids-only) before writing the normal stage object.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/cmd/workflow.go, line 507:

<comment>When users request `--ids-only` or `--count`, this command passes the wrapper object to `writeOK`, so the generic writer rejects it because it is not a list. Handle these formats using `view.Topics` (and emit each `TopicID` for `--ids-only`) before writing the normal stage object.</comment>

<file context>
@@ -434,11 +447,66 @@ func newWorkflowStageCommand() *workflowStageCommand {
+		table.print()
+		return nil
+	}
+	return writeOK(view, output.WithSummary(fmt.Sprintf("%d %s in workflow stage %s", len(view.Topics), threadNoun(len(view.Topics)), terminal.SanitizeLine(view.Name))), output.WithBreadcrumbs(output.Breadcrumb{Action: "read", Command: "hey thread read <thread-id>", Description: "Read an email thread"}))
+}
+
</file context>
Suggested change
return writeOK(view, output.WithSummary(fmt.Sprintf("%d %s in workflow stage %s", len(view.Topics), threadNoun(len(view.Topics)), terminal.SanitizeLine(view.Name))), output.WithBreadcrumbs(output.Breadcrumb{Action: "read", Command: "hey thread read <thread-id>", Description: "Read an email thread"}))
switch writer.EffectiveFormat() {
case output.FormatIDs:
for _, topic := range view.Topics {
fmt.Fprintln(cmd.OutOrStdout(), topic.TopicID)
}
return nil
case output.FormatCount:
fmt.Fprintln(cmd.OutOrStdout(), len(view.Topics))
return nil
default:
return writeOK(view, output.WithSummary(fmt.Sprintf("%d %s in workflow stage %s", len(view.Topics), threadNoun(len(view.Topics)), terminal.SanitizeLine(view.Name))), output.WithBreadcrumbs(output.Breadcrumb{Action: "read", Command: "hey thread read <thread-id>", Description: "Read an email thread"}))
}

}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, _ = io.WriteString(w, `<section id="container_workflow_stage_5512"><h2>Applied</h2><div id="topic_4471829" data-identifier="91"><h3>Application</h3><p class="card__detail">3 emails</p></div></section>`)
}), "workflow", "stage", "view", "8801", "5512")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new workflow stage view command has a separate writer.IsStyled() output path in workflow.go that renders a table ("Thread / Subject / Emails") and returns before writeOK, but this test only exercises the JSON path. The sibling tests (TestWorkflowCommandOutputFormats, TestWorkflowStyledOutputSanitizesNames) use runStyledCommand to cover styled output for exactly this reason. Add a styled-output assertion so the table branch of the new command isn't left untested.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/cmd/workflow_test.go, line 173:

<comment>The new `workflow stage view` command has a separate `writer.IsStyled()` output path in `workflow.go` that renders a table ("Thread / Subject / Emails") and returns before `writeOK`, but this test only exercises the JSON path. The sibling tests (`TestWorkflowCommandOutputFormats`, `TestWorkflowStyledOutputSanitizesNames`) use `runStyledCommand` to cover styled output for exactly this reason. Add a styled-output assertion so the table branch of the new command isn't left untested.</comment>

<file context>
@@ -158,6 +158,39 @@ func TestWorkflowCommandOutputFormats(t *testing.T) {
+		}
+		w.Header().Set("Content-Type", "text/html; charset=utf-8")
+		_, _ = io.WriteString(w, `<section id="container_workflow_stage_5512"><h2>Applied</h2><div id="topic_4471829" data-identifier="91"><h3>Application</h3><p class="card__detail">3 emails</p></div></section>`)
+	}), "workflow", "stage", "view", "8801", "5512")
+	if err != nil {
+		t.Fatalf("execute workflow stage view: %v", err)
</file context>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 existing issue remains and 1 new issue found across 6 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="go.mod">

<violation number="1" location="go.mod:131">
P2: Merging pins the released CLI to an individual's personal fork (`github.com/almirsarajcic/hey-sdk/go`) via `replace` in go.mod. A personal fork is outside the org's control — the pinned tag can be moved, deleted, or its contents changed, which silently changes what every build and published binary ships. Prefer depending on the upstream SDK once basecamp/hey-sdk PR 141 lands, and consider not merging the `replace` to a personal fork in the meantime.</violation>
</file>

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread go.mod
k8s.io/klog/v2 v2.140.0 // indirect
)

replace github.com/basecamp/hey-sdk/go => github.com/almirsarajcic/hey-sdk/go v0.28.2-0.20260901124435-ada48dc17209

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Merging pins the released CLI to an individual's personal fork (github.com/almirsarajcic/hey-sdk/go) via replace in go.mod. A personal fork is outside the org's control — the pinned tag can be moved, deleted, or its contents changed, which silently changes what every build and published binary ships. Prefer depending on the upstream SDK once basecamp/hey-sdk PR 141 lands, and consider not merging the replace to a personal fork in the meantime.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At go.mod, line 131:

<comment>Merging pins the released CLI to an individual's personal fork (`github.com/almirsarajcic/hey-sdk/go`) via `replace` in go.mod. A personal fork is outside the org's control — the pinned tag can be moved, deleted, or its contents changed, which silently changes what every build and published binary ships. Prefer depending on the upstream SDK once basecamp/hey-sdk PR 141 lands, and consider not merging the `replace` to a personal fork in the meantime.</comment>

<file context>
@@ -127,3 +127,5 @@ require (
 	k8s.io/klog/v2 v2.140.0 // indirect
 )
+
+replace github.com/basecamp/hey-sdk/go => github.com/almirsarajcic/hey-sdk/go v0.28.2-0.20260901124435-ada48dc17209
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant