Skip to content

refactor(terminal): extract hibernation logic into TerminalHibernationManager#4762

Merged
gregpriday merged 2 commits intodevelopfrom
feature/issue-4732-extract-hibernation-logic
Apr 1, 2026
Merged

refactor(terminal): extract hibernation logic into TerminalHibernationManager#4762
gregpriday merged 2 commits intodevelopfrom
feature/issue-4732-extract-hibernation-logic

Conversation

@gregpriday
Copy link
Copy Markdown
Collaborator

Summary

  • Extracts hibernate() and unhibernate() mechanics from TerminalInstanceService into a new TerminalHibernationManager class, dropping TIS by ~200 lines
  • Extracts isNonKeyboardInput into a shared inputUtils.ts module so it can be reused without importing the full service
  • Adds 19 unit tests covering the hibernation manager in isolation (previously untestable without standing up the full service)

Resolves #4732

Changes

  • src/services/terminal/TerminalHibernationManager.ts — new class handling xterm buffer serialisation, DOM/WebGL resource disposal, and restore-from-hibernation; orchestration policy stays in TIS
  • src/services/terminal/TerminalInstanceService.ts — delegates to TerminalHibernationManager; net reduction of ~200 lines
  • src/services/terminal/inputUtils.tsisNonKeyboardInput extracted here
  • src/services/terminal/__tests__/TerminalHibernationManager.test.ts — 19 isolated unit tests

Testing

All 19 unit tests pass. Typecheck and lint are clean. This establishes the extraction pattern for the next natural seam (attach/detach lifecycle).

…nManager

- Move hibernate() and unhibernate() from TerminalInstanceService into new
  TerminalHibernationManager class with dependency-injected deps interface
- Extract isNonKeyboardInput to inputUtils.ts to avoid circular imports,
  re-export from TerminalInstanceService to preserve existing import paths
- TIS hibernate/unhibernate become one-line delegators, reducing TIS by ~200 lines
- Add 18 isolated unit tests for TerminalHibernationManager
- All 418 existing terminal tests pass without modification

Closes #4732
- Fix TypeScript cast errors: use `as unknown as` for addon dispose casts
- Add missing test for waiting agent terminal hibernate guard
@gregpriday gregpriday force-pushed the feature/issue-4732-extract-hibernation-logic branch from 6bf7f51 to 9db46e1 Compare April 1, 2026 12:25
@gregpriday gregpriday merged commit dfc0569 into develop Apr 1, 2026
@gregpriday gregpriday deleted the feature/issue-4732-extract-hibernation-logic branch April 1, 2026 12:25
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.

Extract hibernation logic from TerminalInstanceService

1 participant