Skip to content

Conversation

@G-hoon
Copy link

@G-hoon G-hoon commented Jan 17, 2026

Summary

  • Fix flaky mainSessionID tests caused by state pollution in parallel test execution
  • Use _resetForTesting() consistently across all test files that modify session state

Changes

  • src/hooks/keyword-detector/index.test.ts: Replace setMainSession(undefined) with _resetForTesting() in beforeEach/afterEach hooks
  • src/features/claude-code-session-state/state.test.ts: Un-skip the previously flaky test

Root Cause

Some test files were using setMainSession(undefined) which only clears _mainSessionID, but _resetForTesting() also clears subagentSessions. This inconsistency caused state pollution when tests run in parallel.

Testing

bun test src/features/claude-code-session-state/state.test.ts src/hooks/keyword-detector/index.test.ts

Ran 5 consecutive test runs with 0 failures.

Fixes #848


Summary by cubic

Consistently reset session state in tests using _resetForTesting() to stop flaky mainSessionID failures and prevent state leaks across parallel runs. Fixes #848.

  • Bug Fixes
    • Replace setMainSession(undefined) with _resetForTesting() in keyword-detector tests; add cleanup in afterEach.
    • Unskip the “should return undefined when not set” test in claude-code-session-state.

Written for commit 0d10bcd. Summary will update on new commits.

- Replace setMainSession(undefined) with _resetForTesting() in keyword-detector tests
- Add _resetForTesting() to afterEach hooks for proper cleanup
- Un-skip the previously flaky mainSessionID test in state.test.ts

Fixes code-yeongyu#848
@github-actions
Copy link
Contributor

github-actions bot commented Jan 17, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@G-hoon
Copy link
Author

G-hoon commented Jan 17, 2026

I have read the CLA Document and I hereby sign the CLA

Copy link

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

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

github-actions bot added a commit that referenced this pull request Jan 17, 2026
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.

Flaky test: mainSessionID tests fail in parallel execution

1 participant