Skip to content

feat(workflow): add replay, approve, templates, and task-definitions subcommands - #107

Merged
blue4209211 merged 12 commits into
mainfrom
feat/workflow-subcommands-extension
Aug 9, 2026
Merged

feat(workflow): add replay, approve, templates, and task-definitions subcommands#107
blue4209211 merged 12 commits into
mainfrom
feat/workflow-subcommands-extension

Conversation

@blue4209211

Copy link
Copy Markdown
Contributor

Description

Extends nbctl workflow with subcommands for execution replay, human approvals, pre-built template browsing, and task definition listing:

New Subcommands

  1. nbctl workflow replay <execution-id>:

    • Uses mutation workflow_replay_execution.
    • Replays a previous or failed workflow execution and returns the retriggered execution status.
  2. nbctl workflow approve <execution-id> --task <task-id> [--reject]:

    • Uses mutation workflow_complete_approval.
    • Completes human-in-the-loop approval or rejection gates for pending workflow executions.
  3. nbctl workflow templates (Command Group):

    • nbctl workflow templates list [--type system|custom] [--category <name>] (Query: workflow_list_template).
    • nbctl workflow templates get <template-id> (Query: workflow_get_template).
  4. nbctl workflow task-definitions:

    • Uses query workflow_list_taskdefinitions.
    • Lists supported workflow task definitions, action schemas, and aliases.

Testing & Verification

  • Ran make lint — 0 issues.
  • Ran go test ./... — 100% PASS.
  • Verified all subcommands against live dev environment with structured output.

@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new workflow-related CLI commands: approve for completing human approval gates, replay for retriggering executions, task-definitions for listing task definitions, and templates for browsing pre-built templates. The feedback suggests validating the type flag in the template commands to prevent invalid API requests, and pre-allocating the rows slice in the task definitions command to optimize performance.

Comment thread cmd/workflow_templates.go
Comment thread cmd/workflow_templates.go
Comment thread cmd/workflow_task_definitions.go Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new subcommands to manage workflows, including approve, replay, task-definitions, and templates (with list and get subcommands). The feedback recommends utilizing the package-level client.Run helper instead of instantiating a new client with client.NewClient() in each command to reduce boilerplate and ensure consistent initialization. Additionally, for the templates get subcommand, the reviewer suggests making the --type flag optional (defaulting to an empty string) so that templates can be resolved by ID alone without requiring an explicit type parameter.

Comment thread cmd/workflow_approve.go Outdated
Comment thread cmd/workflow_replay.go Outdated
Comment thread cmd/workflow_task_definitions.go Outdated
Comment thread cmd/workflow_templates.go Outdated
Comment thread cmd/workflow_templates.go
Comment thread cmd/workflow_templates.go Outdated
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new subcommands under the workflow command: approve for completing human approval gates, replay for retriggering workflow executions, task-definitions for listing supported tasks, and templates (with list and get subcommands) for browsing pre-built workflow templates. The review feedback focuses on refining the template commands, specifically recommending to omit the type filter in the GraphQL request when listing "all" templates, restricting the template "get" command to only "system" or "custom" types, and updating the help text for the list command to accurately reflect that "all" is a supported type.

Comment thread cmd/workflow_templates.go
Comment thread cmd/workflow_templates.go Outdated
Comment thread cmd/workflow_templates.go Outdated
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new subcommands under the workflow command: approve for completing human approval gates, replay for retriggering workflow executions, task-definitions for listing supported task definitions, and templates (with list and get subcommands) for browsing pre-built workflow templates. The review feedback suggests improving the robustness of the GraphQL response handling in workflow_templates.go by using a pointer for the nullable workflow_get_template field to correctly distinguish missing templates. Additionally, it recommends updating the CLI flag descriptions for template types to explicitly mention 'all' as a valid option alongside 'system' and 'custom' to match the validation logic.

Comment thread cmd/workflow_templates.go Outdated
Comment thread cmd/workflow_templates.go Outdated
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new workflow-related commands to the CLI, including approve to complete human approval gates, replay to retrigger workflow executions, task-definitions to list supported tasks, and templates (with list and get subcommands) to browse pre-built templates. The review feedback suggests changing the WorkflowGetTemplate response field in the templates get command from a pointer to a non-pointer struct. This avoids formatting issues where raw pointers are printed instead of structured data, and consequently allows simplifying the error handling by removing the redundant nil check.

Comment thread cmd/workflow_templates.go
Comment thread cmd/workflow_templates.go
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

1 similar comment
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new CLI commands for managing workflows, including commands to approve or reject pending executions, replay previous executions, list task definitions, and browse or inspect workflow templates. The review feedback suggests improving the user experience by making the template type flag validation case-insensitive. Additionally, it recommends using a pointer to a struct instead of checking for an empty string when handling nullable GraphQL response fields to align with idiomatic Go practices.

Comment thread cmd/workflow_templates.go
Comment thread cmd/workflow_templates.go
Comment thread cmd/workflow_templates.go
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

1 similar comment
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new workflow-related CLI commands, including approve, replay, task-definitions, and templates (with list and get subcommands). The feedback recommends validating that the required task flag is not empty in the approve command. Additionally, it is highly recommended to replace manual client instantiations (client.NewClient()) with the package-level client.Run() helper across all new commands to properly leverage the singleton client, automatic configuration initialization, and authenticated transport reuse.

Comment thread cmd/workflow_approve.go
Comment thread cmd/workflow_approve.go Outdated
Comment thread cmd/workflow_replay.go Outdated
Comment thread cmd/workflow_task_definitions.go Outdated
Comment thread cmd/workflow_templates.go Outdated
Comment thread cmd/workflow_templates.go
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new subcommands to the workflow command group, including 'approve' for completing human approval gates, 'replay' for re-triggering executions, 'task-definitions' for listing task schemas, and 'templates' (with 'list' and 'get' subcommands) for browsing pre-built templates. The feedback suggests improving the payload construction in the 'approve' command by omitting empty optional fields, and refactoring the 'templates' command to extract duplicate struct definitions into a shared package-level struct.

I am having trouble creating individual review comments. Click here to see my feedback.

cmd/workflow_approve.go (24-39)

medium

To maintain consistency with other subcommands (like workflow_templates and workflow_task_definitions), optional fields like comments should only be included in the request payload if they are non-empty. This prevents sending empty strings to the backend, which might otherwise be interpreted as actual empty comments.

graphqlClient := client.NewClient()

		req := client.NewRequest("mutation CompleteWorkflowApproval($request: WorkflowCompleteApprovalRequest!) {\n\t\t\tworkflow_complete_approval(request: $request) {\n\t\t\t\tstatus\n\t\t\t\tmessage\n\t\t\t}\n\t\t}")
		input := map[string]any{
			"execution_id": executionID,
			"task_id":      taskID,
			"status":       status,
		}
		if comments != "" {
			input["comments"] = comments
		}
		req.Var("request", input)

cmd/workflow_templates.go (57-69)

medium

The template struct definition is duplicated between workflowTemplatesListCmd and workflowTemplatesGetCmd. Extracting this into a shared package-level struct workflowTemplate improves maintainability and ensures consistency if the template schema changes in the future.

		var respData struct {
			WorkflowListTemplate struct {
				TotalCount int                "json:\"total_count\""
				Templates  []workflowTemplate "json:\"templates\""
			} "json:\"workflow_list_template\""
		}

cmd/workflow_templates.go (128-137)

medium

Reuse the shared workflowTemplate struct here to eliminate duplication.

		var respData struct {
			WorkflowGetTemplate workflowTemplate "json:\"workflow_get_template\""
		}

cmd/workflow_templates.go (152-162)

medium

Define the shared workflowTemplate struct at the package level.

func init() {
	workflowCmd.AddCommand(workflowTemplatesCmd)
	workflowTemplatesCmd.AddCommand(workflowTemplatesListCmd)
	workflowTemplatesCmd.AddCommand(workflowTemplatesGetCmd)

	workflowTemplatesListCmd.Flags().String("type", "system", "Template type (system, custom, or all)")
	workflowTemplatesListCmd.Flags().String("category", "", "Filter templates by category")
	workflowTemplatesListCmd.Flags().Int("limit", 50, "Maximum number of templates to return")

	workflowTemplatesGetCmd.Flags().String("type", "", "Optional template type filter (system, custom, or all)")
}

type workflowTemplate struct {
	ID          string "json:\"id\""
	Name        string "json:\"name\""
	Description string "json:\"description\""
	Category    string "json:\"category\""
	IsSystem    bool   "json:\"is_system\""
	Status      string "json:\"status\""
}

@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new subcommands under the workflow command to manage workflow executions and templates. Specifically, it adds approve to complete human approval gates, replay to re-trigger executions, task-definitions to list supported tasks, and templates (with list and get subcommands) to browse pre-built templates. The review feedback suggests adding input validation to ensure that required positional arguments, such as execution-id and template-id, are not empty or whitespace-only before executing API requests.

Comment thread cmd/workflow_approve.go Outdated
Comment thread cmd/workflow_replay.go Outdated
Comment thread cmd/workflow_templates.go
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new workflow-related CLI commands, including approve, replay, task-definitions, and templates (with list and get subcommands). The feedback recommends using a pointer struct for WorkflowGetTemplate in the get template command to properly handle and distinguish null API responses from empty structs.

Comment thread cmd/workflow_templates.go
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new subcommands to the workflow CLI tool: approve for completing human approval gates, replay for retriggering previous or failed workflow executions, task-definitions for listing supported task definitions, and templates (with list and get subcommands) for browsing pre-built workflow templates. Feedback on these changes includes using a pointer type for GraphQL query responses to properly handle null values, enforcing zero positional arguments on subcommands that do not accept them, and trimming whitespace from input flags.

Comment thread cmd/workflow_templates.go Outdated
Comment thread cmd/workflow_templates.go
Comment thread cmd/workflow_task_definitions.go
Comment thread cmd/workflow_approve.go
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new subcommands to the workflow CLI tool, including commands to approve pending executions, replay previous or failed executions, list task definitions, and browse/get workflow templates. The feedback recommends dereferencing the template pointer in the get subcommand before passing it to the formatter to ensure the output is rendered as a structured table rather than falling back to default text formatting.

Comment thread cmd/workflow_templates.go
@blue4209211

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new workflow-related CLI commands: 'approve' to complete human approval gates, 'replay' to re-trigger workflow executions, 'task-definitions' to list task schemas, and 'templates' (with 'list' and 'get' subcommands) to browse pre-built workflow templates. The feedback highlights an issue in 'cmd/workflow_templates.go' where passing a pointer to the formatter causes it to print a raw pointer representation instead of formatted key-value pairs; dereferencing the template pointer before printing resolves this.

Comment thread cmd/workflow_templates.go

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new workflow-related CLI commands, including approve for completing human approval gates, replay for re-triggering workflow executions, task-definitions for listing task definitions, and templates (with list and get subcommands) for managing pre-built workflow templates. The review feedback recommends adding input validation to ensure the limit parameter is a positive integer in both the task-definitions and templates list commands, which also requires importing the fmt package in workflow_task_definitions.go.

Comment thread cmd/workflow_task_definitions.go
Comment thread cmd/workflow_task_definitions.go
Comment thread cmd/workflow_templates.go

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request adds several new workflow-related CLI commands: 'approve' for completing human approval gates, 'replay' for re-triggering workflow executions, 'task-definitions' for listing supported task definitions, and 'templates' (with 'list' and 'get' subcommands) for browsing pre-built workflow templates. There are no review comments, and I have no feedback to provide.

@blue4209211
blue4209211 merged commit eaef87c into main Aug 9, 2026
2 checks passed
@blue4209211
blue4209211 deleted the feat/workflow-subcommands-extension branch August 9, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants