fix(lsp): scope cache fallback by runtime provider#2354
Conversation
Greptile SummaryThis PR scopes the LSP client cache key by runtime provider ID and introduces a
Confidence Score: 4/5Safe to merge after addressing the canHandle/resolveUris contract gap in builtinAlpine. The core refactor is well-structured and the new resolveUris hook is a clean abstraction. One concrete gap exists in builtinAlpine: canHandle approves untitled documents in file:// workspaces via the canUseRealPath branch (which looks at rootUri, not the document URI), but resolveUris will throw for the same documents if no cacheFile is present. The error is caught and LSP silently drops, making this a regression for untitled files opened inside a project folder without a cache file assigned. The rest of the changes — provider-scoped cache keys, scope-aware useWsFolders, removal of the global cache fallback — are correct. src/cm/lsp/runtimes/builtinAlpine.ts — the canHandle method needs !isUntitled(context) added to its first branch. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant CM as LspClientManager
participant RRT as #resolveRuntimeTarget
participant RDU as #resolveDocumentUri
participant SP as selectRuntimeProvider
participant RP as LspRuntimeProvider
participant EC as #ensureClient
CM->>RRT: attach(server, uri, file, view)
RRT->>RDU: normalizeDocumentUri(uri)
RDU-->>RRT: "normalizedDocumentUri | null"
RRT->>SP: selectRuntimeProvider(server, providerContext)
SP->>RP: canHandle(server, context)
RP-->>SP: boolean
SP-->>RRT: "runtimeProvider | null"
alt provider found
RRT->>RP: resolveUris(server, resolutionContext)
RP-->>RRT: "{documentUri, rootUri, scope} | null"
RRT-->>CM: ResolvedRuntimeTarget
CM->>EC: ensureClient(server, context, target)
Note over EC: key = serverId@providerId::__document__::uri (scope=document) or pluginKey(serverId@providerId, rootUri) (scope=workspace)
EC-->>CM: ClientState
else no provider or no documentUri
RRT-->>CM: null (warn, skip)
end
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant CM as LspClientManager
participant RRT as #resolveRuntimeTarget
participant RDU as #resolveDocumentUri
participant SP as selectRuntimeProvider
participant RP as LspRuntimeProvider
participant EC as #ensureClient
CM->>RRT: attach(server, uri, file, view)
RRT->>RDU: normalizeDocumentUri(uri)
RDU-->>RRT: "normalizedDocumentUri | null"
RRT->>SP: selectRuntimeProvider(server, providerContext)
SP->>RP: canHandle(server, context)
RP-->>SP: boolean
SP-->>RRT: "runtimeProvider | null"
alt provider found
RRT->>RP: resolveUris(server, resolutionContext)
RP-->>RRT: "{documentUri, rootUri, scope} | null"
RRT-->>CM: ResolvedRuntimeTarget
CM->>EC: ensureClient(server, context, target)
Note over EC: key = serverId@providerId::__document__::uri (scope=document) or pluginKey(serverId@providerId, rootUri) (scope=workspace)
EC-->>CM: ClientState
else no provider or no documentUri
RRT-->>CM: null (warn, skip)
end
Reviews (2): Last reviewed commit: "fix" | Re-trigger Greptile |
No description provided.