|
| 1 | +--- code-server.orig/lib/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionInputPills.ts |
| 2 | ++++ code-server/lib/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionInputPills.ts |
| 3 | +@@ -19,8 +19,9 @@ |
| 4 | + import { localize } from '../../../../../../nls.js'; |
| 5 | + import { IAgentHostConnectionsService, IAgentHostSessionResolution } from '../../../../../../platform/agentHost/common/agentHostConnectionsService.js'; |
| 6 | + import { toAgentHostUri } from '../../../../../../platform/agentHost/common/agentHostUri.js'; |
| 7 | +-import { resolveChangesetUriTemplate, resolveChatChangesetCatalogue, selectDefaultChangeset, type DefaultChangesetKind } from '../../../../../../platform/agentHost/common/changesetUri.js'; |
| 8 | ++import { ChangesetKind, resolveChangesetUriTemplate, resolveChatChangesetCatalogue, selectDefaultChangeset, type DefaultChangesetKind } from '../../../../../../platform/agentHost/common/changesetUri.js'; |
| 9 | + import { ISessionArtifact, isGitHubArtifactLink, readSessionArtifactsNewestFirst, SessionArtifactType } from '../../../../../../platform/agentHost/common/sessionArtifacts.js'; |
| 10 | ++import { SessionConfigKey } from '../../../../../../platform/agentHost/common/sessionConfigKeys.js'; |
| 11 | + import { supportsAgentHostArtifactRemoval } from '../../../../../../platform/agentHost/common/meta/agentHostArtifactRemovalMeta.js'; |
| 12 | + import { observableFromSubscription } from '../../../../../../platform/agentHost/common/state/agentSubscription.js'; |
| 13 | + import { Changeset, ChangesetState, ChangesetStatus, ChatOriginKind, ChatState, DEFAULT_CHAT_ID, getSessionChatResource, getSessionRelatedPullRequestUrls, isSubagentChatUri, parseChatUri, readSessionFolderGitHubState, readSessionGitHubState, SessionState, SessionSummaryMeta, StateComponents } from '../../../../../../platform/agentHost/common/state/sessionState.js'; |
| 14 | +@@ -571,12 +572,13 @@ |
| 15 | + const session = sessionState.read(reader); |
| 16 | + const resolvedCatalogue = resolveChatChangesetCatalogue(chat.toString(), chatState.read(reader)?.changesets, session?.changesets, session?.defaultChat); |
| 17 | + const selectableEntries = resolvedCatalogue?.filter(({ changeset }) => !changeset.uriTemplate.includes('{')); |
| 18 | +- const selectedChangeset = selectDefaultChangeset(selectableEntries?.map(({ changeset }) => changeset), currentResolution.defaultChangesetKind); |
| 19 | ++ const defaultChangesetKind = currentResolution.defaultChangesetKind ?? (session?.config?.values[SessionConfigKey.Isolation] === 'worktree' ? ChangesetKind.Branch : ChangesetKind.Session); |
| 20 | ++ const selectedChangeset = selectDefaultChangeset(selectableEntries?.map(({ changeset }) => changeset), defaultChangesetKind); |
| 21 | + const selectedEntry = selectableEntries?.find(({ changeset }) => changeset === selectedChangeset); |
| 22 | + return resolveAgentHostChangeset( |
| 23 | + selectedEntry?.owner === 'session' ? currentResolution.backendSession : chat, |
| 24 | + selectedChangeset ? [selectedChangeset] : undefined, |
| 25 | +- currentResolution.defaultChangesetKind, |
| 26 | ++ defaultChangesetKind, |
| 27 | + ); |
| 28 | + }); |
| 29 | + const changesetStateSource = derived(this, reader => { |
| 30 | +--- code-server.orig/lib/vscode/src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSessionInputPills.test.ts |
| 31 | ++++ code-server/lib/vscode/src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSessionInputPills.test.ts |
| 32 | +@@ -681,6 +681,61 @@ |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | ++ test('folder sessions default the Changes pill to Session Changes when the provider has no override', () => { |
| 37 | ++ const instantiationService = createInstantiationService(); |
| 38 | ++ const sessionResource = URI.parse('agent-host-copilot:/session'); |
| 39 | ++ const backendSession = URI.parse('copilot:/session'); |
| 40 | ++ const backendChat = URI.parse(buildDefaultChatUri(backendSession)); |
| 41 | ++ const connection = new StaticAgentConnection(new Map<StateComponents, SessionState | ChatState | ChangesetState>([ |
| 42 | ++ [StateComponents.Session, { |
| 43 | ++ defaultChat: backendChat.toString(), |
| 44 | ++ chats: [], |
| 45 | ++ config: { values: { isolation: 'folder' } }, |
| 46 | ++ changesets: [ |
| 47 | ++ { label: 'Branch Changes', uriTemplate: 'changeset/branch', changeKind: ChangesetKind.Branch }, |
| 48 | ++ { label: 'Session Changes', uriTemplate: 'changeset/session', changeKind: ChangesetKind.Session }, |
| 49 | ++ ], |
| 50 | ++ } as unknown as SessionState], |
| 51 | ++ [StateComponents.Chat, {} as ChatState], |
| 52 | ++ [StateComponents.Changeset, { status: ChangesetStatus.Ready, files: [] } as unknown as ChangesetState], |
| 53 | ++ ])); |
| 54 | ++ const persistentContent = document.createElement('div'); |
| 55 | ++ document.body.appendChild(persistentContent); |
| 56 | ++ store.add(toDisposable(() => persistentContent.remove())); |
| 57 | ++ const widget = upcastPartial<ChatWidget>({ |
| 58 | ++ inputPart: upcastPartial<ChatInputPart>({ |
| 59 | ++ persistentContentContainerElement: persistentContent, |
| 60 | ++ registerChatPetHorizontalPlatformProvider: () => Disposable.None, |
| 61 | ++ }), |
| 62 | ++ onDidChangeViewModel: Event.None, |
| 63 | ++ viewModel: upcastPartial<ChatViewModel>({ sessionResource }), |
| 64 | ++ setPersistentContentHeight: () => { }, |
| 65 | ++ }); |
| 66 | ++ const connectionsService = upcastPartial<IAgentHostConnectionsService>({ |
| 67 | ++ onDidChangeConnections: Event.None, |
| 68 | ++ onDidChangeSessionResolution: Event.None, |
| 69 | ++ connections: [], |
| 70 | ++ resolveSessionResource: () => ({ connection, connectionAuthority: 'local', backendSession }), |
| 71 | ++ }); |
| 72 | ++ const browserViewService = upcastPartial<IBrowserViewWorkbenchService>({ |
| 73 | ++ onDidChangeBrowserViews: Event.None, |
| 74 | ++ getKnownBrowserViews: () => new Map(), |
| 75 | ++ }); |
| 76 | ++ const visibility = store.add(instantiationService.createInstance(SessionChatPillVisibility)); |
| 77 | ++ instantiationService.stub(ISessionChatPillVisibilityService, visibility); |
| 78 | ++ const [clipboardService, configurationService, editorService, openerService] = instantiationService.invokeFunction(accessor => [ |
| 79 | ++ accessor.get(IClipboardService), accessor.get(IConfigurationService), accessor.get(IEditorService), accessor.get(IOpenerService), |
| 80 | ++ ] as const); |
| 81 | ++ |
| 82 | ++ store.add(new AgentHostSessionInputPills( |
| 83 | ++ widget, false, connectionsService, browserViewService, clipboardService, configurationService, |
| 84 | ++ editorService, instantiationService, openerService, visibility, noProvisionalSessions, labelService, notificationService, |
| 85 | ++ )); |
| 86 | ++ |
| 87 | ++ const changesetRequest = connection.requested.findLast(request => request.kind === StateComponents.Changeset); |
| 88 | ++ assert.strictEqual(changesetRequest?.resource.toString(), `${backendSession.toString()}/changeset/session`); |
| 89 | ++ }); |
| 90 | ++ |
| 91 | + test('resolves the configured session changeset and ignores templated entries', () => { |
| 92 | + const backendSession = URI.parse('ahp-session:/session'); |
| 93 | + const changesets: readonly Changeset[] = [ |
0 commit comments