Skip to content

Commit bb450f4

Browse files
authored
agent sessions - narrow down event blockage on anchor elements in markdown only (#276345)
* agent sessions - narrow down event blockage on anchor elements in markdown only * . * .
1 parent 6a8e8d3 commit bb450f4

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,27 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer<IAgentSes
144144
if (typeof session.element.description === 'string') {
145145
template.description.textContent = session.element.description;
146146
} else {
147-
template.elementDisposable.add(this.markdownRendererService.render(session.element.description, {
147+
const descriptionMarkdown = this.markdownRendererService.render(session.element.description, {
148148
sanitizerConfig: {
149149
replaceWithPlaintext: true,
150150
allowedTags: {
151151
override: allowedChatMarkdownHtmlTags,
152152
},
153153
allowedLinkSchemes: { augment: [this.productService.urlProtocol] }
154154
},
155-
}, template.description));
156-
157-
// TODO@bpasero this is needed so that a user can click into a link of the session
158-
// without opening the session itself. Revisit this approach as we want to move
159-
// away from allowing different results based on where the user clicks.
160-
template.elementDisposable.add(addDisposableListener(template.description, EventType.MOUSE_DOWN, e => e.stopPropagation()));
161-
template.elementDisposable.add(addDisposableListener(template.description, EventType.CLICK, e => e.stopPropagation()));
162-
template.elementDisposable.add(addDisposableListener(template.description, EventType.AUXCLICK, e => e.stopPropagation()));
155+
}, template.description);
156+
template.elementDisposable.add(descriptionMarkdown);
157+
158+
// Prevent link clicks from opening the session itself
159+
// by stopping propagation of mouse events from links
160+
// within (TODO@bpasero revisit this in the future).
161+
// eslint-disable-next-line no-restricted-syntax
162+
const anchors = descriptionMarkdown.element.querySelectorAll('a');
163+
for (const anchor of anchors) {
164+
template.elementDisposable.add(addDisposableListener(anchor, EventType.MOUSE_DOWN, e => e.stopPropagation()));
165+
template.elementDisposable.add(addDisposableListener(anchor, EventType.CLICK, e => e.stopPropagation()));
166+
template.elementDisposable.add(addDisposableListener(anchor, EventType.AUXCLICK, e => e.stopPropagation()));
167+
}
163168
}
164169

165170
// Status (updated every minute)

src/vs/workbench/contrib/chat/browser/agentSessions/media/agentsessionsactions.css

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,24 @@
1616
padding: 0 4px 0 0; /* to make space for hover effect */
1717
}
1818

19-
span.agent-session-diff-files {
19+
.agent-session-diff-files {
2020
color: var(--vscode-descriptionForeground);
2121
}
2222

23-
span.agent-session-diff-added {
23+
.agent-session-diff-added {
2424
color: var(--vscode-chat-linesAddedForeground);
2525
}
2626

27-
span.agent-session-diff-removed {
27+
.agent-session-diff-removed {
2828
color: var(--vscode-chat-linesRemovedForeground);
2929
}
3030
}
31+
32+
.monaco-list-row.selected .agent-session-item .agent-session-toolbar {
33+
34+
.agent-session-diff-files,
35+
.agent-session-diff-added,
36+
.agent-session-diff-removed {
37+
color: unset;
38+
}
39+
}

0 commit comments

Comments
 (0)