Skip to content

refactor(frame-manager): extract WhatsApp sync into lifecycle hooks#6

Merged
jonathanpeterwu merged 6 commits intomainfrom
claude/code-review-improvements-EHU9A
Jan 26, 2026
Merged

refactor(frame-manager): extract WhatsApp sync into lifecycle hooks#6
jonathanpeterwu merged 6 commits intomainfrom
claude/code-review-improvements-EHU9A

Conversation

@jonathanpeterwu
Copy link
Collaborator

  • Create new frame-lifecycle-hooks.ts module for extensible frame events
  • Remove WhatsApp-specific code from FrameManager (was 20 lines of tight coupling)
  • FrameManager now calls frameLifecycleHooks.triggerClose() instead
  • WhatsApp sync registers itself as a hook via registerWhatsAppSyncHook()
  • Benefits:
    • FrameManager no longer knows about WhatsApp
    • Other integrations can subscribe to frame events
    • Better testability and separation of concerns
    • Fire-and-forget hooks don't block frame operations

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG

- Create new frame-lifecycle-hooks.ts module for extensible frame events
- Remove WhatsApp-specific code from FrameManager (was 20 lines of tight coupling)
- FrameManager now calls frameLifecycleHooks.triggerClose() instead
- WhatsApp sync registers itself as a hook via registerWhatsAppSyncHook()
- Benefits:
  - FrameManager no longer knows about WhatsApp
  - Other integrations can subscribe to frame events
  - Better testability and separation of concerns
  - Fire-and-forget hooks don't block frame operations

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG
- Merge duplicate ErrorCode enums into src/core/errors/index.ts
- Add new error codes: AUTH_*, FS_*, GIT_*, NET_* categories
- Add getUserFriendlyMessage() for user-facing error messages
- Move ErrorHandler class with retry/circuit breaker to errors module
- Move validation utilities (validateInput, validateEmail, validatePath)
- error-handler.ts now re-exports from errors for backwards compatibility

Benefits:
- Single source of truth for all error codes
- Consistent error handling across CLI and core
- No more conflicting StackMemoryError class definitions
- Better organization with categorized error codes

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG
…efactoredFrameManager

- Add frameLifecycleHooks integration to RefactoredFrameManager.closeFrame()
- Add missing methods for feature parity with legacy FrameManager:
  - setQueryMode() - change query mode for frame retrieval
  - getRecentFrames() - get recent frames with metadata
  - addContext() - add context metadata to current frame
  - deleteFrame() - delete frame completely (for handoffs)
  - extractTagsFromFrame() - extract tags for categorization
  - calculateFrameImportance() - calculate frame importance
- Add setQueryMode() and removeFrame() to FrameStack

This brings RefactoredFrameManager to feature parity with legacy FrameManager,
enabling eventual removal of the legacy implementation.

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG
…xports

- Update all direct imports from frame-manager.ts to use index.js
- Update type-only imports to use frame-types.ts
- Fix type exports to use `export type` for pure type definitions
  (required because esbuild strips type-only modules at runtime)
- Update tests to use new import paths:
  - FrameManager now refers to RefactoredFrameManager
  - LegacyFrameManager available for backwards compatibility tests

All code now imports FrameManager from index.js, which provides
the RefactoredFrameManager as the primary implementation.

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG
- Delete frame-manager.ts (1,391 lines) - legacy implementation
- Update all imports to use index.js centralized exports
- Fix updateParentFrame to properly update parent_frame_id and depth
- Add validation for non-existent parent frames
- Support parent_frame_id and depth updates in FrameDatabase
- Rewrite cycle detection tests to use unified FrameManager

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG
@jonathanpeterwu jonathanpeterwu merged commit d86a150 into main Jan 26, 2026
2 of 6 checks passed
jonathanpeterwu added a commit that referenced this pull request Jan 28, 2026
* refactor(frame-manager): extract WhatsApp sync into lifecycle hooks

- Create new frame-lifecycle-hooks.ts module for extensible frame events
- Remove WhatsApp-specific code from FrameManager (was 20 lines of tight coupling)
- FrameManager now calls frameLifecycleHooks.triggerClose() instead
- WhatsApp sync registers itself as a hook via registerWhatsAppSyncHook()
- Benefits:
  - FrameManager no longer knows about WhatsApp
  - Other integrations can subscribe to frame events
  - Better testability and separation of concerns
  - Fire-and-forget hooks don't block frame operations

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG

* refactor(errors): consolidate error codes and handler into single module

- Merge duplicate ErrorCode enums into src/core/errors/index.ts
- Add new error codes: AUTH_*, FS_*, GIT_*, NET_* categories
- Add getUserFriendlyMessage() for user-facing error messages
- Move ErrorHandler class with retry/circuit breaker to errors module
- Move validation utilities (validateInput, validateEmail, validatePath)
- error-handler.ts now re-exports from errors for backwards compatibility

Benefits:
- Single source of truth for all error codes
- Consistent error handling across CLI and core
- No more conflicting StackMemoryError class definitions
- Better organization with categorized error codes

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG

* chore: update package-lock.json

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG

* refactor(frame-manager): add lifecycle hooks and missing methods to RefactoredFrameManager

- Add frameLifecycleHooks integration to RefactoredFrameManager.closeFrame()
- Add missing methods for feature parity with legacy FrameManager:
  - setQueryMode() - change query mode for frame retrieval
  - getRecentFrames() - get recent frames with metadata
  - addContext() - add context metadata to current frame
  - deleteFrame() - delete frame completely (for handoffs)
  - extractTagsFromFrame() - extract tags for categorization
  - calculateFrameImportance() - calculate frame importance
- Add setQueryMode() and removeFrame() to FrameStack

This brings RefactoredFrameManager to feature parity with legacy FrameManager,
enabling eventual removal of the legacy implementation.

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG

* refactor(context): migrate all imports to use index.js and fix type exports

- Update all direct imports from frame-manager.ts to use index.js
- Update type-only imports to use frame-types.ts
- Fix type exports to use `export type` for pure type definitions
  (required because esbuild strips type-only modules at runtime)
- Update tests to use new import paths:
  - FrameManager now refers to RefactoredFrameManager
  - LegacyFrameManager available for backwards compatibility tests

All code now imports FrameManager from index.js, which provides
the RefactoredFrameManager as the primary implementation.

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG

* refactor(context): remove legacy FrameManager and consolidate imports

- Delete frame-manager.ts (1,391 lines) - legacy implementation
- Update all imports to use index.js centralized exports
- Fix updateParentFrame to properly update parent_frame_id and depth
- Add validation for non-existent parent frames
- Support parent_frame_id and depth updates in FrameDatabase
- Rewrite cycle detection tests to use unified FrameManager

https://claude.ai/code/session_014ojs76858uGzWb6Hrbs4VG

---------

Co-authored-by: Claude <noreply@anthropic.com>
@jonathanpeterwu jonathanpeterwu deleted the claude/code-review-improvements-EHU9A branch February 13, 2026 13:50
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