Skip to content

feat(cli): accept manual run work item metadata#1158

Merged
zbigniewsobiecki merged 2 commits intomongrel-intelligence:devfrom
maksymilian-majer:feat/manual-run-work-item-metadata
Apr 22, 2026
Merged

feat(cli): accept manual run work item metadata#1158
zbigniewsobiecki merged 2 commits intomongrel-intelligence:devfrom
maksymilian-majer:feat/manual-run-work-item-metadata

Conversation

@maksymilian-majer
Copy link
Copy Markdown
Contributor

Summary

  • Add optional --work-item-url and --work-item-title flags to cascade runs trigger.
  • Pass manual work item metadata through the dashboard API, BullMQ dashboard job payload, and worker entrypoint.
  • Persist provided manual-run metadata in pr_work_items before starting the agent so dashboard run rows and later PR links can resolve the work item instead of showing Unlinked.

Test Plan

  • Unit tests pass (npm test via npm run verify)
  • Linter passes (npm run lint via npm run verify)
  • Type check passes (npm run typecheck via npm run verify)
  • Pre-push fast test hook passed (npm run test:fast -- --changed origin/dev)

Checklist

  • My code follows the project code style
  • I have added tests for new functionality
  • I have updated documentation if needed (CLI help text updated through flag descriptions)
  • My commits follow Conventional Commits

@zbigniewsobiecki zbigniewsobiecki requested a review from aaight April 22, 2026 08:27
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

Summary

Clean, well-structured feature that threads work-item metadata through all layers (CLI → API → Queue → Worker → ManualRunner). One issue worth addressing.

Code Issues

Should Fix

  • src/triggers/shared/manual-runner.ts:130-134createWorkItem failure will block agent execution. The createWorkItem call sits inside the outer try block that also runs the agent. If it throws (DB connectivity issue, unexpected constraint violation), the agent never starts — the error is caught by the outer catch which just logs and returns.

    The existing PM-triggered path in agent-execution.ts:518-530 deliberately wraps the same createWorkItem call in its own try-catch and logs a warning, treating metadata persistence as non-blocking:

    if (workItemId) {
      try {
        await createWorkItem(project.id, workItemId, { ... });
      } catch (err) {
        logger.warn('Failed to persist work-item row for PM-triggered run', { ... });
      }
    }

    Consider the same pattern in the manual runner so metadata persistence failures don't prevent the agent from running.

🕵️ claude-code · claude-opus-4-6 · run details

@mongrel-intelligence mongrel-intelligence deleted a comment from aaight Apr 22, 2026
@maksymilian-majer maksymilian-majer force-pushed the feat/manual-run-work-item-metadata branch from de31e0b to 58560ff Compare April 22, 2026 11:15
@maksymilian-majer
Copy link
Copy Markdown
Contributor Author

Addressed the review feedback in 58560ffc.

createWorkItem persistence for manual-run metadata is now best-effort: failures are caught and logged with logger.warn, and the agent still runs. Added unit coverage for that failure path.

Verification:

  • npm test -- tests/unit/triggers/manual-runner.test.ts
  • pre-push npm run test:fast -- --changed origin/dev

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@maksymilian-majer
Copy link
Copy Markdown
Contributor Author

Added a separate follow-up commit for the Codecov patch coverage issue: 3c58622e test(api): cover queued manual run metadata.

It covers the queued runs.trigger path with workItemUrl and workItemTitle, which are the missing lines Codecov highlighted in src/api/routers/runs.ts.

Verification:

  • npm test -- tests/unit/queue/retry-run-projectId.test.ts
  • npm test -- tests/unit/api/routers/runs.test.ts
  • pre-push npm run test:fast -- --changed origin/dev

@nhopeatall
Copy link
Copy Markdown
Collaborator

nhopeatall commented Apr 22, 2026

⚠️ review agent failed

Error: Claude Code returned an error result: You've hit your limit · resets Apr 23, 7pm (UTC)

Manual intervention may be required.

@zbigniewsobiecki zbigniewsobiecki merged commit 48b5bf3 into mongrel-intelligence:dev Apr 22, 2026
6 checks passed
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

Summary

LGTM - The implementation successfully plumbs optional manual run metadata through the CLI and dashboard API to the worker, properly persisting it to the DB.

Analysis

  • DB interactions are properly wrapped in a try/catch so a transient database failure during manual run persistence doesn't abort the agent run.
  • startWatchdog was appropriately moved inside the try block right before the async createWorkItem call, ensuring the watchdog protects against hangs during the DB operation.
  • The logic handles existing records appropriately without clobbering fields with undefined values.
  • Good test coverage of both the success and error paths.

🕵️ opencode · google/gemini-3.1-pro-preview · run details

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.

3 participants