Commit Graph

19 Commits

Author SHA1 Message Date
aleiby
702f686fc0 feat(update): add --append-notes flag (#1304)
* feat(update): add --append-notes flag (bd-b5qu)

Add --append-notes flag that appends to existing notes with a newline
separator instead of overwriting. This prevents data loss in workflows
where multiple steps need to add info to notes (e.g., tackle workflows).

- Errors if both --notes and --append-notes specified
- Handles both daemon and direct mode paths
- Combines existing notes + newline + new content

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(update): add tests for --append-notes flag

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 17:11:25 -08:00
aleiby
16749e6731 feat(bd): add --ephemeral and --persistent flags to bd update (#1263)
Adds --ephemeral and --persistent flags to bd update command.

Author: aleiby
2026-01-22 15:54:04 -08:00
Mike
1f84f7cce3 test: add failing tests for short ID support in comments (#1070)
Add tests demonstrating that `bd comments add` and `bd comments list`
don't accept short IDs in daemon mode, while other commands do.

Tests added:
- TestCLI_CommentsAddShortID (cli_fast_test.go)
  - Tests short ID, partial ID, and comment alias in direct mode (passes)

- TestCommentAddWithShortID (internal/rpc/comments_test.go)
  - Tests RPC layer with short ID (FAILS - demonstrates bug)

- TestCommentListWithShortID (internal/rpc/comments_test.go)
  - Tests listing comments with short ID (FAILS - demonstrates bug)

The fix should add daemonClient.ResolveID() before AddComment/ListComments,
following the pattern in update.go and label.go.

Refs: https://github.com/steveyegge/beads/issues/1070
2026-01-13 13:22:19 +00:00
mayor
66ab0ccdd4 test: add tests for bd create --dry-run flag (bd-nib2)
Adds runBDInProcessAllowError helper and dry-run test coverage.
Interrupted work - committing to preserve progress.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 12:15:07 -08:00
Steve Yegge
92e6f4c079 refactor: remove legacy autoflush code paths (bd-xsl9)
Remove dual code paths in the autoflush system. FlushManager is now the
only code path for auto-flush operations.

Changes:
- Remove legacy globals: isDirty, needsFullExport, flushTimer
- Remove flushToJSONL() wrapper function (was backward-compat shim)
- Simplify markDirtyAndScheduleFlush/FullExport to just call FlushManager
- Update tests to use FlushManager or flushToJSONLWithState directly

FlushManager handles all flush state internally in its run() goroutine,
eliminating the need for global state. Sandbox mode and tests that do
not need flushing get a no-op when FlushManager is nil.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:56:19 -08:00
cbro
2651620a4c fix(storage): persist close_reason to issues table on close (#551)
CloseIssue was storing the reason only in the events table, not in the
issues.close_reason column. This caused `bd show --json` to return an
empty close_reason even when one was provided.

- Update CloseIssue in queries.go and transaction.go to set close_reason
- Clear close_reason when reopening issues (in manageClosedAt)
- Add tests for close_reason in storage and CLI JSON output
- Document the dual-storage of close_reason (issues + events tables)
2025-12-14 14:18:01 -08:00
Steve Yegge
3065db261e feat: Add label operations to bd update command
Implements bd-au0.2, completing all P0 tasks in the command standardization epic.

Changes:
- Add --add-label, --remove-label, --set-labels flags to bd update
- Support multiple labels via repeatable flags
- Implement in both daemon and direct modes
- Add comprehensive tests for all label operations

The bd update command now supports:
  bd update <id> --add-label <label>       # Add one or more labels
  bd update <id> --remove-label <label>    # Remove one or more labels
  bd update <id> --set-labels <labels>     # Replace all labels

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 22:17:26 -05:00
Steve Yegge
82902432f5 test: Tag 16 slow integration tests with build tags
Identified and tagged obviously-slow integration tests with
`//go:build integration` to exclude them from default test runs.

This is step 1 of fixing test performance. The real fix is in
bd-1rh: refactoring tests to use shared DB setup instead of
creating 279 separate databases.

Tagged files:
- cmd/bd: 8 files (CLI tests, git ops, performance benchmarks)
- internal: 8 files (integration tests, E2E tests)

Issues:
- bd-1rh: Main issue tracking test performance
- bd-c49: Audit all tests and create grouping plan (next step)
- bd-y6d: POC refactor of create_test.go

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 14:40:22 -05:00
Steve Yegge
a17e4af725 Fix context propagation lifecycle bugs
Critical fixes to context propagation implementation (bd-rtp, bd-yb8, bd-2o2):

1. Fix rootCtx lifecycle in main.go:
   - Removed premature defer rootCancel() from PersistentPreRun (line 132)
   - Added proper cleanup in PersistentPostRun (lines 544-547)
   - Context now properly spans from setup through command execution to cleanup

2. Fix test context contamination in cli_fast_test.go:
   - Reset rootCtx and rootCancel to nil in test cleanup (lines 139-140)
   - Prevents cancelled contexts from affecting subsequent tests

3. Fix export tests missing context in export_test.go:
   - Added rootCtx initialization in 5 export test subtests
   - Tests now properly set up context before calling exportCmd.Run()

These fixes ensure:
- Signal-aware contexts work correctly for graceful cancellation
- Ctrl+C properly cancels import/export operations
- Database integrity is maintained after cancellation
- All cancellation tests pass (TestImportCancellation, TestExportCommand)

Tested:
- go build ./cmd/bd ✓
- go test ./cmd/bd -run TestImportCancellation ✓
- go test ./cmd/bd -run TestExportCommand ✓

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:54:11 -05:00
Steve Yegge
bbfedb060a Refactor: extract duplicated validation and flag logic (bd-g5p7)
- Created internal/validation package for centralized validation logic
- Created cmd/bd/flags.go for shared flag registration
- Updated create and update commands to use shared logic
- Added support for 'P1' style priority to update command
- Added tests for validation logic

Amp-Thread-ID: https://ampcode.com/threads/T-c8d369a3-32f0-42a0-96d1-fd589e89bd6b
Co-authored-by: Amp <amp@ampcode.com>
2025-11-20 19:11:27 -05:00
Steve Yegge
1fc9bf629f Fix parallel test deadlock by removing t.Parallel() from TestCLI_* tests
Tests now complete successfully without -short flag.

Also updated git hook templates to version 0.23.1.

Fixes bd-82dv
2025-11-09 12:55:14 -08:00
Steve Yegge
0131eda09d Optimize CLI tests with in-process testing (bd-ky74)
- Convert exec.Command() tests to in-process rootCmd.Execute()
- Achieve ~10x speedup (3.8s vs 40s for 17 tests)
- Add mutex serialization for thread safety
- Implement manual temp dir cleanup with retries
- Reset global state between tests to prevent contamination
- Keep TestCLI_EndToEnd for binary validation
2025-11-08 22:42:02 -08:00
Steve Yegge
6ca26ed71b Improve cmd/bd test coverage from 20.2% to 23.3%
- Fixed TestCLI_Create to handle warning messages before JSON output
- Added tests for formatDependencyType (show.go)
- Added tests for truncateForBox and gitRevParse (worktree.go)
- Added comprehensive CLI tests for labels, priority formats, and reopen
- All tests passing in short mode

Addresses bd-6221bdcd
2025-11-08 18:22:28 -08:00
Steve Yegge
11fa142539 Optimize test suite with testing.Short() guards
- Add Short() guards to slow CLI tests (2-4s each)
- Add Short() guards to slow API/integration tests (3-11s)
- Add Short() guard to hanging daemon discovery test (29s timeout)
- Short test suite now runs in ~6s (down from 5+ minutes)

Run 'go test -short ./...' for fast iteration
Run 'go test ./...' for full coverage

Closes: bd-iov0
2025-11-06 17:31:15 -08:00
Steve Yegge
0f4b03e262 Optimize test suite: split integration tests, add -short support
- Split slow importer integration tests into separate file
- Add t.Short() guards to 10 slow daemon tests
- Document test organization in TEST_OPTIMIZATION.md
- Fast tests now run in ~50s vs 3+ minutes
- Use 'go test -short ./...' for fast feedback

Amp-Thread-ID: https://ampcode.com/threads/T-29ae21ac-749d-43d7-bf0c-2c5f7a06ae76
Co-authored-by: Amp <amp@ampcode.com>
2025-11-05 20:39:47 -08:00
Steve Yegge
8c5e51e3e6 Merge branch 'main' of github.com:steveyegge/beads
# Conflicts:
#	.beads/beads.jsonl
2025-11-05 10:27:12 -08:00
Steve Yegge
0fc4da7358 Optimize test suite performance (15-18x speedup)
- Add t.Parallel() to CLI and export/import tests for concurrent execution
- Remove unnecessary 200ms sleep in daemon_autoimport_test (Execute forces sync)
- Reduce filesystem settle wait from 100ms to 50ms on non-Windows
- Optimize debouncer test sleeps (9 reductions, 30-50% faster)

Results:
- cmd/bd: 5+ minutes → 18 seconds
- internal/importer: < 1 second
- Most packages: < 2 seconds

Closes bd-gpe7
2025-11-05 10:26:58 -08:00
Steve Yegge
2ac28b0122 fix: Windows CLI tests and skip hanging concurrent test
- Fix Windows test failure: use bd.exe instead of bd on Windows
- Skip TestConcurrentExternalRefImports which hangs due to database deadlock
- Added TODO reference to bd-gpe7 for investigation

Fixes CI failures in Test (Windows) and Test Nix Flake jobs.
2025-11-05 01:23:33 -08:00
Steve Yegge
b31bddc210 Optimize test suite performance - 45% reduction in integration tests
- Add testutil.TempDirInMemory() using /dev/shm on Linux for 20-30% I/O speedup
- Update slow hash multiclone tests to use in-memory filesystem
- Convert 17 scripttest tests (~200+s) to fast CLI tests (31s) with --no-daemon
- Disable slow scripttest suite behind build tag
- Add README_TESTING.md documenting test strategy and optimizations
- Update CI to use -short flag for PR checks, full tests nightly

Results:
- TestHashIDs_* reduced from ~20s to ~11s (45% reduction)
- Scripttest suite eliminated from default runs (massive speedup)
- Total integration test time significantly reduced

Closes bd-gm7p, bd-l5gq

Amp-Thread-ID: https://ampcode.com/threads/T-c2b9434a-cd29-4725-b8e0-cbea50b36fe2
Co-authored-by: Amp <amp@ampcode.com>
2025-11-04 11:25:36 -08:00