Skip to content

Commit 0338f4e

Browse files
authored
Merge pull request #176 from sourcery-ai/ben/sou-1462-fix-scrolling-of-code-blocks-should-not-cause-all-messages
fix: update layout and ensure code blocks do not cause the whole box to overflow
2 parents ff66401 + eafc218 commit 0338f4e

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

media/chat.css

+22-10
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
.sidebar__section-container {
33
transition: all 0.3s ease;
44
overflow: auto;
5-
max-height: 85vh;
6-
}
7-
8-
.sidebar__section-container.is-opening {
9-
max-height: 70vh;
5+
flex-grow: 1;
106
}
117

128
.sidebar__section-container:not(.active) {
@@ -15,6 +11,12 @@
1511
}
1612

1713
/* ------------- Chat UI ------------- */
14+
.sidebar__chat-assistant-body {
15+
display: flex;
16+
flex-direction: column;
17+
height: 100%;
18+
}
19+
1820
.sidebar__chat-assistant--dialogue-container {
1921
padding: 0 var(--spacing-md);
2022
margin: 0;
@@ -23,7 +25,10 @@
2325
}
2426

2527
.sidebar__chat-assistant--chat-bubble {
26-
display: inline-grid;
28+
display: flex;
29+
overflow: hidden;
30+
width: 100%;
31+
gap: var(--spacing-md);
2732
align-items: flex-end;
2833
grid-gap: var(--spacing-md) var(--spacing-xs);
2934
margin-bottom: var(--spacing-md);
@@ -33,14 +38,18 @@
3338
/* Change width of columns based on agent/user */
3439
.sidebar__chat-assistant--chat-bubble-agent {
3540
grid-template-columns: 32px 1fr;
41+
flex-direction: row;
3642
}
3743

3844
.sidebar__chat-assistant--chat-bubble-user {
3945
grid-template-columns: 1fr 32px;
46+
flex-direction: row-reverse;
4047
}
4148

4249
/* Styles for avatars */
4350
.sidebar__chat-assistant--chat-avatar-container {
51+
flex-shrink: 0;
52+
flex-grow: 0;
4453
background: var(--vscode-foreground);
4554
padding: var(--spacing-xs);
4655
border-radius: 100%;
@@ -49,7 +58,6 @@
4958
display: flex;
5059
align-items: center;
5160
justify-content: center;
52-
flex: auto;
5361
}
5462

5563
.sidebar__chat-assistant--agent-avatar-image {
@@ -63,6 +71,9 @@
6371
background-color: var(--vscode-settings-textInputBackground);
6472
padding: var(--spacing-xs);
6573
border-radius: var(--spacing-xs);
74+
flex-grow: 1;
75+
flex-shrink: 1;
76+
overflow: hidden;
6677
}
6778

6879
.sidebar__chat-assistant--chat-bubble-content-user {
@@ -100,6 +111,8 @@
100111
background-color: var(--vscode-editor-background);
101112
margin: 0;
102113
border-radius: var(--spacing-xs);
114+
overflow-x: auto;
115+
width: 100%;
103116
}
104117

105118
.sidebar__chat-assistant--code-block {
@@ -221,9 +234,8 @@
221234
border-bottom: 1px solid var(--vscode-sideBar-border);
222235
padding: var(--spacing-md);
223236
background-color: var(--vscode-sideBar-background);
224-
position: absolute;
225-
bottom: -1px;
226-
width: 100%;
237+
flex-shrink: 0;
238+
flex-grow: 0;
227239
}
228240

229241
.sidebar__chat-assistant--textarea-container {

src/chat.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export class ChatProvider implements vscode.WebviewViewProvider {
224224
/* eslint-enable @typescript-eslint/naming-convention */
225225

226226
return `<!DOCTYPE html>
227-
<html lang="en">
227+
<html lang="en" style="height: 100%">
228228
<head>
229229
<meta charset="UTF-8">
230230
<!--
@@ -241,7 +241,7 @@ export class ChatProvider implements vscode.WebviewViewProvider {
241241
<link href="${hljsUri}" rel="stylesheet">
242242
243243
</head>
244-
<body>
244+
<body class="sidebar__chat-assistant-body">
245245
<section class="sidebar__section-container active" data-section="chat-assistant">
246246
<ul class="sidebar__chat-assistant--dialogue-container">
247247

src/webview/chat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ const chatAvatar = `<div class="sidebar__chat-assistant--chat-avatar-container">
8282
// Function to add a user message to the chat interface
8383
function addUserMessageToUI(message) {
8484
const templateMessage = `
85+
${chatAvatar}
8586
<div class="sidebar__chat-assistant--chat-bubble-content-user">
8687
<p class="sidebar__chat-assistant--chat-bubble-text">${message}</p>
8788
</div>
88-
${chatAvatar}
8989
`;
9090
const userMessageElement = document.createElement("li");
9191
userMessageElement.classList.add("sidebar__chat-assistant--chat-bubble");

0 commit comments

Comments
 (0)