You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(ai): simplify recent AI code and delete verified dead code
Two passes over the multi-provider-support work.
Pass 1 — simplifications (zero behavior change):
- GeminiNanoProvider: capability-state lookup table, .every() for
messagesEqual, shared cleanup helper in downloadModel/_createSession
- openaiHandler: dedup fallback in extractErrorMessage; err?.message
form kept as (err && err.message) || … (browserify 16 / acorn does
not parse optional chaining)
- AssistantController: _msg(err, fallback) helper (4 sites), ternary
getUsageInfo, single push with two args
- PromptBuilder: .filter(Boolean) for section accumulation, ternary
helpers, filter().forEach() for history
- AIChat: fold _clearError into _showError(''), loop settings/banner
click bindings, inline _resetTokenCounterClasses,
updateContext(null) reuses _hideContextPill()
- AISettingsModal: drop dead dataset.required, data-driven click
bindings
Pass 2 — dead code, each finding adversarially verified with two
independent Explore skeptics (2×14 = 28 refutation attempts). Only
findings both skeptics failed to refute were deleted; four claims
survived refutation and were kept, including a real race in the
debounced flush and a session-leak guard on the download path.
- AssistantController._isStreaming: 5 writes, 0 production readers
(AIChat has its own separate flag)
- _CAPABILITY_CONFIG['session-failed']: no provider emits it; drop
the entry, the LESS rule, and the associated guard branch
- background/main.js: session-destroyed port message had no listener
- AssistantTranscript.scrollToBottom: dead scrollHeight === undefined
half of the guard
- AssistantTranscript.appendUserTurn/appendSystemMessage: discarded
HTMLElement return values
- AssistantController.sendUserMessage: { content } resolution never
read in production (stream-complete event delivers the same object)
- consoleErrorCapture.uninstall: never invoked in production
- AssistantTranscript._appendMessage: showCopyButton === true branch
unreachable (no caller passes true)
Tests: 637 passing (dropped one obsolete session-failed spec).
JSHint: clean.
Net: 13 files, +93 −195 lines.
// Safe innerHTML: roleLabel is from a fixed set, formattedContent is either escaped or markdown-parsed (which itself escapes anything it does not turn into a known formatting tag).
0 commit comments