Skip to content

fix(worktree): add agent timeout and gh preflight to worktree-start (#154) - #165

Merged
gerchowl merged 2 commits into
devfrom
bugfix/154-worktree-start-silent-fail-agent-print-hang
Feb 24, 2026
Merged

gerchowl merged 2 commits into
devfrom
bugfix/154-worktree-start-silent-fail-agent-print-hang

Conversation

@gerchowl

@gerchowl gerchowl commented Feb 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes two preflight gaps in just worktree-start that cause silent or confusing failures:

  1. agent --print hang: When no linked branch exists, the recipe uses agent --print to derive a branch name. In headless mode this can hang indefinitely. The script now wraps the call in a 30s timeout and prints a clear error with manual workaround when it fails.

  2. gh repo set-default ambiguity: When multiple remotes exist (e.g. origin + fork), gh cannot auto-detect the target repo. The recipe now checks for a default repo before any gh API calls, auto-resolves from origin when possible, or fails with clear instructions.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • scripts/derive-branch-summary.sh (new): Extracts agent-based branch summary derivation with timeout and BRANCH_SUMMARY_CMD mock for tests
  • justfile.worktree: Adds gh repo set-default preflight; replaces inline agent call with derive-branch-summary.sh
  • assets/workspace/.devcontainer/justfile.worktree: Synced from manifest
  • tests/bats/worktree.bats: Three new tests for derive-branch-summary (success, timeout, error message)
  • CHANGELOG.md: Entry under Fixed

Changelog Entry

Fixed

  • worktree-start preflight gaps — agent hang and gh repo set-default (#154)
    • Add timeout (30s) to agent-based branch summary derivation; failure produces clear error with manual workaround
    • Add gh repo set-default preflight before any gh API calls; auto-resolve from origin or fail with instructions
    • Extract derive-branch-summary.sh with BRANCH_SUMMARY_CMD mock for tests; BATS tests for timeout and error paths

Testing

  • Tests pass locally (just test-bats — all 12 worktree tests pass)
  • Manual testing performed (describe below)

Manual Testing Details

N/A — BATS tests cover derive-branch-summary success, timeout, and error paths. Manual verification of gh preflight and agent timeout can be done by reproducing the conditions in the issue.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

N/A

Refs: #154

@gerchowl
gerchowl merged commit debc0c4 into dev Feb 24, 2026
5 checks passed
@gerchowl
gerchowl deleted the bugfix/154-worktree-start-silent-fail-agent-print-hang branch February 24, 2026 12:51
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.

1 participant