@theia/ai-chat-ui 1.69.0 → 1.70.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"question-part-renderer.d.ts","sourceRoot":"","sources":["../../../src/browser/chat-response-renderer/question-part-renderer.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,qBACa,oBACT,YAAW,wBAAwB,CAAC,uBAAuB,CAAC;IAE5D,SAAS,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM;IAOhD,MAAM,CAAC,QAAQ,EAAE,uBAAuB,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS;CA8B3E"}
1
+ {"version":3,"file":"question-part-renderer.d.ts","sourceRoot":"","sources":["../../../src/browser/chat-response-renderer/question-part-renderer.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAsC,uBAAuB,EAA2B,MAAM,gBAAgB,CAAC;AAK3I,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,qBACa,oBACT,YAAW,wBAAwB,CAAC,uBAAuB,CAAC;IAE5D,SAAS,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM;IAOhD,MAAM,CAAC,QAAQ,EAAE,uBAAuB,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS;CAO3E"}
@@ -18,6 +18,8 @@ const tslib_1 = require("tslib");
18
18
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
19
19
  // *****************************************************************************
20
20
  const ai_chat_1 = require("@theia/ai-chat");
21
+ const core_1 = require("@theia/core");
22
+ const browser_1 = require("@theia/core/lib/browser");
21
23
  const inversify_1 = require("@theia/core/shared/inversify");
22
24
  const React = require("@theia/core/shared/react");
23
25
  let QuestionPartRenderer = class QuestionPartRenderer {
@@ -28,19 +30,111 @@ let QuestionPartRenderer = class QuestionPartRenderer {
28
30
  return -1;
29
31
  }
30
32
  render(question, node) {
31
- const isDisabled = question.isReadOnly || question.selectedOption !== undefined || !node.response.isWaitingForInput;
32
- return (React.createElement("div", { className: "theia-QuestionPartRenderer-root" },
33
- React.createElement("div", { className: "theia-QuestionPartRenderer-question" }, question.question),
34
- React.createElement("div", { className: "theia-QuestionPartRenderer-options" }, question.options.map((option, index) => (React.createElement("button", { className: `theia-button theia-QuestionPartRenderer-option ${question.selectedOption?.text === option.text ? 'selected' : ''}`, onClick: () => {
35
- if (!question.isReadOnly && question.handler) {
36
- question.selectedOption = option;
37
- question.handler(option);
38
- }
39
- }, disabled: isDisabled, key: index, title: option.description }, option.text))))));
33
+ if (question.multiSelect) {
34
+ return React.createElement(MultiSelectQuestion, { question: question, node: node });
35
+ }
36
+ return React.createElement(SingleSelectQuestion, { question: question, node: node });
40
37
  }
41
38
  };
42
39
  exports.QuestionPartRenderer = QuestionPartRenderer;
43
40
  exports.QuestionPartRenderer = QuestionPartRenderer = tslib_1.__decorate([
44
41
  (0, inversify_1.injectable)()
45
42
  ], QuestionPartRenderer);
43
+ function isResolved(question) {
44
+ return question.selectedOptions !== undefined;
45
+ }
46
+ function skipQuestion(question) {
47
+ if (question.isReadOnly) {
48
+ return;
49
+ }
50
+ question.selectedOptions = [];
51
+ if (question.multiSelect) {
52
+ if (question.handler) {
53
+ question.handler([]);
54
+ }
55
+ }
56
+ else {
57
+ question.onSkip?.();
58
+ }
59
+ }
60
+ function isOptionSelected(question, option) {
61
+ return question.selectedOptions?.some(s => s.text === option.text) === true;
62
+ }
63
+ function DismissButton({ question, disabled }) {
64
+ if (disabled) {
65
+ return undefined;
66
+ }
67
+ return (React.createElement("button", { className: `theia-QuestionPartRenderer-dismiss ${(0, browser_1.codicon)('close')}`, onClick: () => skipQuestion(question), title: core_1.nls.localizeByDefault('Dismiss') }));
68
+ }
69
+ function SingleSelectQuestion({ question, node }) {
70
+ const isDisabled = question.isReadOnly || isResolved(question) || !node.response.isWaitingForInput;
71
+ const hasDescriptions = question.options.some(option => option.description);
72
+ return (React.createElement("div", { className: "theia-QuestionPartRenderer-root" },
73
+ question.onSkip && React.createElement(DismissButton, { question: question, disabled: isDisabled }),
74
+ question.header && React.createElement("div", { className: "theia-QuestionPartRenderer-header" }, question.header),
75
+ React.createElement("div", { className: "theia-QuestionPartRenderer-question" }, question.question),
76
+ React.createElement("div", { className: `theia-QuestionPartRenderer-options ${hasDescriptions ? 'has-descriptions' : ''}` }, question.options.map((option, index) => (React.createElement("button", { className: `theia-QuestionPartRenderer-option ${isOptionSelected(question, option) ? 'selected' : ''}`, onClick: () => {
77
+ if (!question.isReadOnly && question.handler) {
78
+ question.selectedOption = option;
79
+ question.handler(option);
80
+ }
81
+ }, disabled: isDisabled, key: index },
82
+ React.createElement("span", { className: "theia-QuestionPartRenderer-option-label" }, option.text),
83
+ option.description && (React.createElement("span", { className: "theia-QuestionPartRenderer-option-description" }, option.description))))))));
84
+ }
85
+ function MultiSelectQuestion({ question, node }) {
86
+ const restoredIndices = React.useMemo(() => {
87
+ if (question.selectedOptions && question.selectedOptions.length > 0) {
88
+ const indices = new Set();
89
+ for (const selected of question.selectedOptions) {
90
+ const idx = question.options.findIndex(o => o.text === selected.text);
91
+ if (idx >= 0) {
92
+ indices.add(idx);
93
+ }
94
+ }
95
+ return indices;
96
+ }
97
+ return new Set();
98
+ }, []);
99
+ const [selectedIndices, setSelectedIndices] = React.useState(restoredIndices);
100
+ const [confirmed, setConfirmed] = React.useState(isResolved(question));
101
+ const isDisabled = question.isReadOnly || confirmed || !node.response.isWaitingForInput;
102
+ const hasDescriptions = question.options.some(option => option.description);
103
+ const toggleOption = React.useCallback((index) => {
104
+ if (isDisabled) {
105
+ return;
106
+ }
107
+ setSelectedIndices(prev => {
108
+ const next = new Set(prev);
109
+ if (next.has(index)) {
110
+ next.delete(index);
111
+ }
112
+ else {
113
+ next.add(index);
114
+ }
115
+ return next;
116
+ });
117
+ }, [isDisabled]);
118
+ const handleConfirm = React.useCallback(() => {
119
+ if (isDisabled || selectedIndices.size === 0) {
120
+ return;
121
+ }
122
+ const selectedOpts = Array.from(selectedIndices)
123
+ .sort((a, b) => a - b)
124
+ .map(i => question.options[i]);
125
+ question.selectedOptions = selectedOpts;
126
+ setConfirmed(true);
127
+ if (question.handler) {
128
+ question.handler(selectedOpts);
129
+ }
130
+ }, [isDisabled, selectedIndices]);
131
+ return (React.createElement("div", { className: "theia-QuestionPartRenderer-root" },
132
+ React.createElement(DismissButton, { question: question, disabled: isDisabled }),
133
+ question.header && React.createElement("div", { className: "theia-QuestionPartRenderer-header" }, question.header),
134
+ React.createElement("div", { className: "theia-QuestionPartRenderer-question" }, question.question),
135
+ React.createElement("div", { className: `theia-QuestionPartRenderer-options ${hasDescriptions ? 'has-descriptions' : ''}` }, question.options.map((option, index) => (React.createElement("button", { className: `theia-QuestionPartRenderer-option ${selectedIndices.has(index) ? 'selected' : ''}`, onClick: () => toggleOption(index), disabled: isDisabled, key: index },
136
+ React.createElement("span", { className: "theia-QuestionPartRenderer-option-label" }, option.text),
137
+ option.description && (React.createElement("span", { className: "theia-QuestionPartRenderer-option-description" }, option.description)))))),
138
+ !isDisabled && (React.createElement("button", { className: "theia-QuestionPartRenderer-confirm theia-button main", onClick: handleConfirm, disabled: selectedIndices.size === 0 }, core_1.nls.localize('theia/ai-chat-ui/confirm', 'Confirm')))));
139
+ }
46
140
  //# sourceMappingURL=question-part-renderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"question-part-renderer.js","sourceRoot":"","sources":["../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C,OAAO,CAAC,MAAM,CAAC,CAAC;oBAC7B,CAAC;gBACL,CAAC,EACD,QAAQ,EAAE,UAAU,EACpB,GAAG,EAAE,KAAK,EACV,KAAK,EAAE,MAAM,CAAC,WAAW,IAExB,MAAM,CAAC,IAAI,CACP,CACZ,CAAC,CAEJ,CACJ,CACT,CAAC;IACN,CAAC;CAEJ,CAAA;AAxCY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,sBAAU,GAAE;GACA,oBAAoB,CAwChC"}
1
+ {"version":3,"file":"question-part-renderer.js","sourceRoot":"","sources":["../../../src/browser/chat-response-renderer/question-part-renderer.tsx"],"names":[],"mappings":";;;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,4CAA2I;AAC3I,sCAAkC;AAClC,qDAAkD;AAClD,4DAA0D;AAC1D,kDAAkD;AAM3C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAG7B,SAAS,CAAC,QAA6B;QACnC,IAAI,iCAAuB,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,OAAO,EAAE,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;IACd,CAAC;IAED,MAAM,CAAC,QAAiC,EAAE,IAAkB;QACxD,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;YACvB,OAAO,oBAAC,mBAAmB,IAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC;QACnE,CAAC;QACD,OAAO,oBAAC,oBAAoB,IAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC;IACpE,CAAC;CAEJ,CAAA;AAjBY,oDAAoB;+BAApB,oBAAoB;IAD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AAQ,CAAC,MAAM,CAAO;QAC9F,6BAAK,SAAS,EAAC,qCAAqC,IAAE,QAAQ,CAAC,QAAQ,CAAO;QAC9E,6BAAK,SAAS,EAAE,sCAAsC,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,IAC5F,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CACrC,gCACI,SAAS,EAAE,qCAAqC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAC9F,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAClC,QAAQ,EAAE,UAAU,EACpB,GAAG,EAAE,KAAK;YAEV,8BAAM,SAAS,EAAC,yCAAyC,IAAE,MAAM,CAAC,IAAI,CAAQ;YAC7E,MAAM,CAAC,WAAW,IAAI,CACnB,8BAAM,SAAS,EAAC,+CAA+C,IAAE,MAAM,CAAC,WAAW,CAAQ,CAC9F,CACI,CACZ,CAAC,CACA;QACL,CAAC,UAAU,IAAI,CACZ,gCACI,SAAS,EAAC,sDAAsD,EAChE,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,eAAe,CAAC,IAAI,KAAK,CAAC,IAEnC,UAAG,CAAC,QAAQ,CAAC,0BAA0B,EAAE,SAAS,CAAC,CAC/C,CACZ,CACC,CACT,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@theia/ai-chat-ui",
3
- "version": "1.69.0",
3
+ "version": "1.70.0-next.0+746bd8e6e",
4
4
  "description": "Theia - AI Chat UI Extension",
5
5
  "dependencies": {
6
- "@theia/ai-chat": "1.69.0",
7
- "@theia/ai-core": "1.69.0",
8
- "@theia/core": "1.69.0",
9
- "@theia/editor": "1.69.0",
10
- "@theia/editor-preview": "1.69.0",
11
- "@theia/filesystem": "1.69.0",
12
- "@theia/monaco": "1.69.0",
6
+ "@theia/ai-chat": "1.70.0-next.0+746bd8e6e",
7
+ "@theia/ai-core": "1.70.0-next.0+746bd8e6e",
8
+ "@theia/core": "1.70.0-next.0+746bd8e6e",
9
+ "@theia/editor": "1.70.0-next.0+746bd8e6e",
10
+ "@theia/editor-preview": "1.70.0-next.0+746bd8e6e",
11
+ "@theia/filesystem": "1.70.0-next.0+746bd8e6e",
12
+ "@theia/monaco": "1.70.0-next.0+746bd8e6e",
13
13
  "@theia/monaco-editor-core": "1.96.302",
14
- "@theia/preferences": "1.69.0",
15
- "@theia/workspace": "1.69.0",
14
+ "@theia/preferences": "1.70.0-next.0+746bd8e6e",
15
+ "@theia/workspace": "1.70.0-next.0+746bd8e6e",
16
16
  "date-fns": "^4.1.0",
17
17
  "tslib": "^2.6.2",
18
18
  "uuid": "^9.0.1"
@@ -56,5 +56,5 @@
56
56
  "nyc": {
57
57
  "extends": "../../configs/nyc.json"
58
58
  },
59
- "gitHead": "3b413470b0f990dc0d6e4287da02a6b6e21d3239"
59
+ "gitHead": "746bd8e6e43be90c1e1f59d226429a78f4590466"
60
60
  }
@@ -13,7 +13,9 @@
13
13
  //
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
- import { ChatResponseContent, QuestionResponseContent } from '@theia/ai-chat';
16
+ import { ChatResponseContent, MultiSelectQuestionResponseHandler, QuestionResponseContent, QuestionResponseHandler } from '@theia/ai-chat';
17
+ import { nls } from '@theia/core';
18
+ import { codicon } from '@theia/core/lib/browser';
17
19
  import { injectable } from '@theia/core/shared/inversify';
18
20
  import * as React from '@theia/core/shared/react';
19
21
  import { ReactNode } from '@theia/core/shared/react';
@@ -32,33 +34,162 @@ export class QuestionPartRenderer
32
34
  }
33
35
 
34
36
  render(question: QuestionResponseContent, node: ResponseNode): ReactNode {
35
- const isDisabled = question.isReadOnly || question.selectedOption !== undefined || !node.response.isWaitingForInput;
37
+ if (question.multiSelect) {
38
+ return <MultiSelectQuestion question={question} node={node} />;
39
+ }
40
+ return <SingleSelectQuestion question={question} node={node} />;
41
+ }
36
42
 
37
- return (
38
- <div className="theia-QuestionPartRenderer-root">
39
- <div className="theia-QuestionPartRenderer-question">{question.question}</div>
40
- <div className="theia-QuestionPartRenderer-options">
41
- {
42
- question.options.map((option, index) => (
43
- <button
44
- className={`theia-button theia-QuestionPartRenderer-option ${question.selectedOption?.text === option.text ? 'selected' : ''}`}
45
- onClick={() => {
46
- if (!question.isReadOnly && question.handler) {
47
- question.selectedOption = option;
48
- question.handler(option);
49
- }
50
- }}
51
- disabled={isDisabled}
52
- key={index}
53
- title={option.description}
54
- >
55
- {option.text}
56
- </button>
57
- ))
58
- }
59
- </div>
60
- </div>
61
- );
43
+ }
44
+
45
+ function isResolved(question: QuestionResponseContent): boolean {
46
+ return question.selectedOptions !== undefined;
47
+ }
48
+
49
+ function skipQuestion(question: QuestionResponseContent): void {
50
+ if (question.isReadOnly) {
51
+ return;
52
+ }
53
+ question.selectedOptions = [];
54
+ if (question.multiSelect) {
55
+ if (question.handler) {
56
+ (question.handler as MultiSelectQuestionResponseHandler)([]);
57
+ }
58
+ } else {
59
+ question.onSkip?.();
60
+ }
61
+ }
62
+
63
+ function isOptionSelected(question: QuestionResponseContent, option: { text: string }): boolean {
64
+ return question.selectedOptions?.some(s => s.text === option.text) === true;
65
+ }
66
+
67
+ function DismissButton({ question, disabled }: { question: QuestionResponseContent, disabled: boolean }): React.JSX.Element | undefined {
68
+ if (disabled) {
69
+ return undefined;
62
70
  }
71
+ return (
72
+ <button
73
+ className={`theia-QuestionPartRenderer-dismiss ${codicon('close')}`}
74
+ onClick={() => skipQuestion(question)}
75
+ title={nls.localizeByDefault('Dismiss')}
76
+ />
77
+ );
78
+ }
79
+
80
+ function SingleSelectQuestion({ question, node }: { question: QuestionResponseContent, node: ResponseNode }): React.JSX.Element {
81
+ const isDisabled = question.isReadOnly || isResolved(question) || !node.response.isWaitingForInput;
82
+ const hasDescriptions = question.options.some(option => option.description);
83
+
84
+ return (
85
+ <div className="theia-QuestionPartRenderer-root">
86
+ {question.onSkip && <DismissButton question={question} disabled={isDisabled} />}
87
+ {question.header && <div className="theia-QuestionPartRenderer-header">{question.header}</div>}
88
+ <div className="theia-QuestionPartRenderer-question">{question.question}</div>
89
+ <div className={`theia-QuestionPartRenderer-options ${hasDescriptions ? 'has-descriptions' : ''}`}>
90
+ {
91
+ question.options.map((option, index) => (
92
+ <button
93
+ className={`theia-QuestionPartRenderer-option ${isOptionSelected(question, option) ? 'selected' : ''}`}
94
+ onClick={() => {
95
+ if (!question.isReadOnly && question.handler) {
96
+ question.selectedOption = option;
97
+ (question.handler as QuestionResponseHandler)(option);
98
+ }
99
+ }}
100
+ disabled={isDisabled}
101
+ key={index}
102
+ >
103
+ <span className="theia-QuestionPartRenderer-option-label">{option.text}</span>
104
+ {option.description && (
105
+ <span className="theia-QuestionPartRenderer-option-description">{option.description}</span>
106
+ )}
107
+ </button>
108
+ ))
109
+ }
110
+ </div>
111
+ </div>
112
+ );
113
+ }
114
+
115
+ function MultiSelectQuestion({ question, node }: { question: QuestionResponseContent, node: ResponseNode }): React.JSX.Element {
116
+ const restoredIndices = React.useMemo(() => {
117
+ if (question.selectedOptions && question.selectedOptions.length > 0) {
118
+ const indices = new Set<number>();
119
+ for (const selected of question.selectedOptions) {
120
+ const idx = question.options.findIndex(o => o.text === selected.text);
121
+ if (idx >= 0) {
122
+ indices.add(idx);
123
+ }
124
+ }
125
+ return indices;
126
+ }
127
+ return new Set<number>();
128
+ }, []);
63
129
 
130
+ const [selectedIndices, setSelectedIndices] = React.useState<Set<number>>(restoredIndices);
131
+ const [confirmed, setConfirmed] = React.useState(isResolved(question));
132
+ const isDisabled = question.isReadOnly || confirmed || !node.response.isWaitingForInput;
133
+ const hasDescriptions = question.options.some(option => option.description);
134
+
135
+ const toggleOption = React.useCallback((index: number): void => {
136
+ if (isDisabled) {
137
+ return;
138
+ }
139
+ setSelectedIndices(prev => {
140
+ const next = new Set(prev);
141
+ if (next.has(index)) {
142
+ next.delete(index);
143
+ } else {
144
+ next.add(index);
145
+ }
146
+ return next;
147
+ });
148
+ }, [isDisabled]);
149
+
150
+ const handleConfirm = React.useCallback((): void => {
151
+ if (isDisabled || selectedIndices.size === 0) {
152
+ return;
153
+ }
154
+ const selectedOpts = Array.from(selectedIndices)
155
+ .sort((a, b) => a - b)
156
+ .map(i => question.options[i]);
157
+ question.selectedOptions = selectedOpts;
158
+ setConfirmed(true);
159
+ if (question.handler) {
160
+ (question.handler as MultiSelectQuestionResponseHandler)(selectedOpts);
161
+ }
162
+ }, [isDisabled, selectedIndices]);
163
+
164
+ return (
165
+ <div className="theia-QuestionPartRenderer-root">
166
+ <DismissButton question={question} disabled={isDisabled} />
167
+ {question.header && <div className="theia-QuestionPartRenderer-header">{question.header}</div>}
168
+ <div className="theia-QuestionPartRenderer-question">{question.question}</div>
169
+ <div className={`theia-QuestionPartRenderer-options ${hasDescriptions ? 'has-descriptions' : ''}`}>
170
+ {question.options.map((option, index) => (
171
+ <button
172
+ className={`theia-QuestionPartRenderer-option ${selectedIndices.has(index) ? 'selected' : ''}`}
173
+ onClick={() => toggleOption(index)}
174
+ disabled={isDisabled}
175
+ key={index}
176
+ >
177
+ <span className="theia-QuestionPartRenderer-option-label">{option.text}</span>
178
+ {option.description && (
179
+ <span className="theia-QuestionPartRenderer-option-description">{option.description}</span>
180
+ )}
181
+ </button>
182
+ ))}
183
+ </div>
184
+ {!isDisabled && (
185
+ <button
186
+ className="theia-QuestionPartRenderer-confirm theia-button main"
187
+ onClick={handleConfirm}
188
+ disabled={selectedIndices.size === 0}
189
+ >
190
+ {nls.localize('theia/ai-chat-ui/confirm', 'Confirm')}
191
+ </button>
192
+ )}
193
+ </div>
194
+ );
64
195
  }
@@ -786,33 +786,106 @@ div:last-child>.theia-ChatNode {
786
786
  }
787
787
 
788
788
  .theia-QuestionPartRenderer-root {
789
+ position: relative;
789
790
  display: flex;
790
791
  flex-direction: column;
791
- gap: 8px;
792
+ gap: var(--theia-ui-padding);
792
793
  border: var(--theia-border-width) solid var(--theia-sideBarSectionHeader-border);
793
- padding: 8px 12px 12px;
794
- border-radius: 5px;
795
- margin: 0 0 8px 0;
794
+ padding: calc(var(--theia-ui-padding) * 2);
795
+ border-radius: var(--theia-ui-padding);
796
+ margin: 0 0 var(--theia-ui-padding) 0;
797
+ }
798
+
799
+ .theia-QuestionPartRenderer-dismiss {
800
+ position: absolute;
801
+ top: var(--theia-ui-padding);
802
+ right: var(--theia-ui-padding);
803
+ background: none;
804
+ border: none;
805
+ cursor: pointer;
806
+ color: var(--theia-descriptionForeground);
807
+ font-size: var(--theia-ui-font-size1);
808
+ padding: 2px;
809
+ line-height: 1;
810
+ border-radius: calc(var(--theia-ui-padding) * 2 / 3);
811
+ }
812
+
813
+ .theia-QuestionPartRenderer-dismiss:hover {
814
+ color: var(--theia-foreground);
815
+ background-color: var(--theia-toolbar-hoverBackground);
816
+ }
817
+
818
+ .theia-QuestionPartRenderer-header {
819
+ font-weight: 700;
820
+ font-size: var(--theia-ui-font-size0);
821
+ text-transform: uppercase;
822
+ letter-spacing: 0.05em;
823
+ color: var(--theia-descriptionForeground);
824
+ }
825
+
826
+ .theia-QuestionPartRenderer-question {
827
+ margin-bottom: calc(var(--theia-ui-padding) / 2);
796
828
  }
797
829
 
798
830
  .theia-QuestionPartRenderer-options {
799
831
  display: flex;
800
832
  flex-wrap: wrap;
801
- gap: 12px;
833
+ gap: var(--theia-ui-padding);
834
+ }
835
+
836
+ .theia-QuestionPartRenderer-options.has-descriptions {
837
+ flex-direction: column;
802
838
  }
803
839
 
804
840
  .theia-QuestionPartRenderer-option {
841
+ display: flex;
842
+ flex-direction: column;
843
+ align-items: flex-start;
844
+ text-align: left;
805
845
  min-width: 100px;
806
846
  flex: 1 1 auto;
807
847
  margin: 0;
848
+ padding: var(--theia-ui-padding) calc(var(--theia-ui-padding) * 2);
849
+ border-radius: var(--theia-ui-padding);
850
+ border: var(--theia-border-width) solid var(--theia-sideBarSectionHeader-border);
851
+ background-color: var(--theia-editor-background);
852
+ color: var(--theia-foreground);
853
+ cursor: pointer;
854
+ line-height: 1.4;
855
+ }
856
+
857
+ .theia-QuestionPartRenderer-option:hover:not(:disabled) {
858
+ background-color: var(--theia-list-hoverBackground);
859
+ }
860
+
861
+ .theia-QuestionPartRenderer-option.selected {
862
+ background-color: var(--theia-button-background);
863
+ color: var(--theia-button-foreground);
864
+ border-color: var(--theia-button-background);
808
865
  }
809
866
 
810
867
  .theia-QuestionPartRenderer-option.selected:disabled:hover {
811
- background-color: var(--theia-button-disabledBackground);
868
+ background-color: var(--theia-button-background);
812
869
  }
813
870
 
814
871
  .theia-QuestionPartRenderer-option:disabled:not(.selected) {
815
- background-color: var(--theia-button-secondaryBackground);
872
+ opacity: var(--theia-mod-disabled-opacity);
873
+ cursor: default;
874
+ }
875
+
876
+ .theia-QuestionPartRenderer-option-label {
877
+ font-weight: 600;
878
+ }
879
+
880
+ .theia-QuestionPartRenderer-option-description {
881
+ font-size: var(--theia-ui-font-size0);
882
+ opacity: 0.8;
883
+ margin-top: 2px;
884
+ }
885
+
886
+ .theia-QuestionPartRenderer-confirm {
887
+ align-self: flex-end;
888
+ margin-top: calc(var(--theia-ui-padding) / 2);
816
889
  }
817
890
 
818
891
  .theia-toolCall,