refactor: full rewrite of Chrome Free AI with base session caching, reusable sessions, and better response and abort signals - #33
Open
iamaamir wants to merge 9 commits into
Open
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
- base.clone() is async (returns Promise) in real Prompt API but mock was synchronous — session received a Promise object, not a session, causing 'c.prompt is not a function' and 'c.destroy is not a function' - Added await base.clone() in _runWithSession - Made mock clone() async to match real API surface - Wrapped session.destroy() in try/catch in finally block to prevent destroy errors from masking successful prompt results
…ation tests Adds 42 tests covering ChromeFreeAIProvider session lifecycle: - isAvailable / getStatus / ensureModel - Base session creation, caching, reuse, concurrent dedup - destroySessions with generation invalidation - _runWithSession clone-per-check and skipSessionCache paths - AbortError handling and availability gates - Session metrics lifecycle tracking Adds 6 cascade signal propagation tests: - Pre-aborted signal rejected before level attempt - Mid-flight abort increments aborted counter - AbortError stops cascade (no level 2 attempt) - Cache not updated on mid-flight abort - Unknown providerOptions passed through to _doCorrectGrammar Modifies CascadeProvider test helper to accept _options parameter for accurate signaling passthrough.
Remove baseSessionGenerationByLevel.delete() from TTL expiry path which caused an extra session create on retry. Clear _baseSessionCreatedAt in destroySessions for consistency. Add 3 TTL unit tests (reuse within TTL, expire after TTL, cross-level isolation) and E2E-CFAI-007 tab-removal e2e test (close tab during in-flight check, verify abort + no crash).
iamaamir
force-pushed
the
feat/refactor-chrome-ai
branch
from
June 2, 2026 15:57
17f84a6 to
6e60d96
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
AbortControllerregistry ingrammar.jsLanguageModel.create()callsdestroySessionscleanupskipSessionCache) to avoid pinning base sessionsTest Plan