refactor: AI features cleanup wave 1 (providers, ViewModel, MCP, Copilot)#1111
Merged
refactor: AI features cleanup wave 1 (providers, ViewModel, MCP, Copilot)#1111
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…add SSE keep-alive
…ent settings defaults
…add source identity guard
0ab6b93 to
59e7dad
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
Wave 1 of the AI features audit (see
AI_FEATURES_AUDIT.md). 13 commits across 8 focused refactors. Production builds clean, AI test target runs.What changed
Core/AI/Chat/JSONValue.swiftandChatToolJSONFormatter.swift. All chat tools, providers, and the MCP wire now shareJsonValue. Encoding helpers live as native methods on the type.IntelligenceFocusBorder+IntelligenceShimmer). Replaced with a single 1ptColor.accentColorstroke, matching macOS HIG.+Streaming,+SchemaContext,+ToolApproval,+MessageEditing,+SlashCommands,+Persistence. Main file now 293 lines. Replaced 3-boolean state machine (isStreaming/lastMessageFailed/pendingApproval) with a singleStreamingStateenum. Added re-entry guard onstartStreaming(). RemovederrorMessagedidSet side effect, added explicitclearError().String+AIEndpoint.swift(normalizedEndpoint()), newJSONValue+Encoding.swift. Anthropic, OpenAI-compatible, and Gemini all share endpoint normalization, JSON encoding, and a unifiedmapHTTPError(Gemini's 403 special case folded into the base via parameter).fetchAvailableModelsstandardized at 5s timeout.Timerdebounce withTask<Void, Never>?+Task.sleep. AddedsourceIdentity: ObjectIdentifiertoInlineSuggestionSource; manager verifies identity before applying so source switches (Copilot ↔ AI Chat) cannot apply stale results. LiftedacceptCommandout of the sharedInlineSuggestionstruct entirely; Copilot tracks LSP commands in its own private[UUID: LSPCommand]map keyed by suggestion id. Debounce duration moved toAISettings.inlineSuggestionDebounceMs(default 500ms, clamped 50-5000).MCPHttpServerTransport.swiftintoMCPHttpConnectionContext,MCPHttpRequestRouter,MCPSseWriter. MigratedPairingExchangeStorefrom@unchecked Sendable+NSLocktoactor. TightenedMCPAuthPolicy.sessionApprovalstoprivate. Added: keep-aliveSSE heartbeat every 30s.AIConversationgainedschemaVersion: Intwith backward-compatible decode.AISettings.includeSchema/includeCurrentQuerydefaults are now consistent across regularinit,init(from:), anddefault.CustomSlashCommandStorage.add()rejects duplicate names with a typed error surfaced via alert.CopilotService.stop()wrapsshutdown()RPC in a 10swithTaskGrouprace.LSPTransport.stop()is now async, cancels the readTask, and explicitly closes stdin/stdoutFileHandles before terminating the process. The read loop usesFileHandle.bytesAsyncSequence. RenamedCopilotSchemaContext→CopilotPreambleBuilder.CopilotBinaryManagerstrips thecom.apple.quarantinexattr after SHA-512 verify.Files
AIChatViewModel.swift1249 → 293 linesTest plan
xcodebuild buildgreen for the production targetswiftlint lint --strictclean on every touched filefixError*for MongoDB/Redis assume plugin metadata loads in test target;OpenTableTabTestshits a pre-existing assertion inMainContentCoordinator+FilterState.swift:311. Out of scope for this PR.)Out of scope (Wave 2)
See section 4 of
AI_FEATURES_AUDIT.mdfor the full backlog.