refactor(terminal): extract hibernation logic into TerminalHibernationManager#4762
Merged
gregpriday merged 2 commits intodevelopfrom Apr 1, 2026
Merged
Conversation
…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
6bf7f51 to
9db46e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hibernate()andunhibernate()mechanics fromTerminalInstanceServiceinto a newTerminalHibernationManagerclass, dropping TIS by ~200 linesisNonKeyboardInputinto a sharedinputUtils.tsmodule so it can be reused without importing the full serviceResolves #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 TISsrc/services/terminal/TerminalInstanceService.ts— delegates toTerminalHibernationManager; net reduction of ~200 linessrc/services/terminal/inputUtils.ts—isNonKeyboardInputextracted heresrc/services/terminal/__tests__/TerminalHibernationManager.test.ts— 19 isolated unit testsTesting
All 19 unit tests pass. Typecheck and lint are clean. This establishes the extraction pattern for the next natural seam (attach/detach lifecycle).