@theia/ai-ide 1.72.0-next.59 → 1.72.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.
- package/lib/browser/architect-agent.js +1 -1
- package/lib/browser/architect-agent.js.map +1 -1
- package/lib/browser/chat-sessions-welcome-message-provider.d.ts +2 -1
- package/lib/browser/chat-sessions-welcome-message-provider.d.ts.map +1 -1
- package/lib/browser/chat-sessions-welcome-message-provider.js +122 -32
- package/lib/browser/chat-sessions-welcome-message-provider.js.map +1 -1
- package/lib/browser/chat-sessions-welcome-message-provider.spec.d.ts +2 -0
- package/lib/browser/chat-sessions-welcome-message-provider.spec.d.ts.map +1 -0
- package/lib/browser/chat-sessions-welcome-message-provider.spec.js +156 -0
- package/lib/browser/chat-sessions-welcome-message-provider.spec.js.map +1 -0
- package/lib/browser/user-interaction-tool-renderer.d.ts.map +1 -1
- package/lib/browser/user-interaction-tool-renderer.js +63 -39
- package/lib/browser/user-interaction-tool-renderer.js.map +1 -1
- package/lib/browser/user-interaction-tool.d.ts +19 -10
- package/lib/browser/user-interaction-tool.d.ts.map +1 -1
- package/lib/browser/user-interaction-tool.js +43 -54
- package/lib/browser/user-interaction-tool.js.map +1 -1
- package/lib/browser/user-interaction-tool.spec.js +66 -41
- package/lib/browser/user-interaction-tool.spec.js.map +1 -1
- package/lib/common/user-interaction-tool.d.ts +1 -0
- package/lib/common/user-interaction-tool.d.ts.map +1 -1
- package/lib/common/user-interaction-tool.js +43 -15
- package/lib/common/user-interaction-tool.js.map +1 -1
- package/lib/common/user-interaction-tool.spec.js +27 -0
- package/lib/common/user-interaction-tool.spec.js.map +1 -1
- package/package.json +22 -22
- package/src/browser/architect-agent.ts +1 -1
- package/src/browser/chat-sessions-welcome-message-provider.spec.ts +186 -0
- package/src/browser/chat-sessions-welcome-message-provider.tsx +132 -35
- package/src/browser/style/index.css +43 -3
- package/src/browser/user-interaction-tool-renderer.tsx +74 -49
- package/src/browser/user-interaction-tool.spec.ts +73 -46
- package/src/browser/user-interaction-tool.ts +52 -58
- package/src/common/user-interaction-tool.spec.ts +29 -0
- package/src/common/user-interaction-tool.ts +42 -15
|
@@ -129,6 +129,35 @@ describe('parseUserInteractionArgs', () => {
|
|
|
129
129
|
expect(result!.interactions[0].links).to.have.length(1);
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
+
it('should ignore invalid rightRef placeholders and keep multi-step file links', () => {
|
|
133
|
+
const emptyRightRefPlaceholder = {
|
|
134
|
+
path: '',
|
|
135
|
+
gitRef: '',
|
|
136
|
+
line: 0,
|
|
137
|
+
empty: false,
|
|
138
|
+
label: ''
|
|
139
|
+
};
|
|
140
|
+
const input = JSON.stringify({
|
|
141
|
+
interactions: ['README.md', 'package.json', 'CONTRIBUTING.md'].map((path, index) => ({
|
|
142
|
+
title: `File link: ${path}`,
|
|
143
|
+
message: 'Open the file link.',
|
|
144
|
+
links: [{
|
|
145
|
+
ref: { path, gitRef: '', line: 1, empty: false, label: '' },
|
|
146
|
+
rightRef: emptyRightRefPlaceholder,
|
|
147
|
+
label: `Open ${path}`,
|
|
148
|
+
autoOpen: index === 0
|
|
149
|
+
}]
|
|
150
|
+
}))
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const result = parseUserInteractionArgs(input);
|
|
154
|
+
expect(result!.interactions.map(step => step.links![0])).to.deep.equal([
|
|
155
|
+
{ ref: { path: 'README.md', line: 1 }, label: 'Open README.md', autoOpen: true },
|
|
156
|
+
{ ref: { path: 'package.json', line: 1 }, label: 'Open package.json', autoOpen: false },
|
|
157
|
+
{ ref: { path: 'CONTRIBUTING.md', line: 1 }, label: 'Open CONTRIBUTING.md', autoOpen: false }
|
|
158
|
+
]);
|
|
159
|
+
});
|
|
160
|
+
|
|
132
161
|
it('should accept multiple steps in order', () => {
|
|
133
162
|
const input = JSON.stringify({
|
|
134
163
|
interactions: [
|
|
@@ -195,10 +195,15 @@ function parseStep(raw: unknown): UserInteractionStep | undefined {
|
|
|
195
195
|
}
|
|
196
196
|
let links: UserInteractionLink[] | undefined;
|
|
197
197
|
if (Array.isArray(obj.links)) {
|
|
198
|
-
const filtered = obj.links
|
|
198
|
+
const filtered = obj.links
|
|
199
|
+
.map(normalizeUserInteractionLink)
|
|
200
|
+
.filter((link: UserInteractionLink | undefined): link is UserInteractionLink => link !== undefined);
|
|
199
201
|
links = filtered.length > 0 ? filtered : undefined;
|
|
200
|
-
} else
|
|
201
|
-
|
|
202
|
+
} else {
|
|
203
|
+
const link = normalizeUserInteractionLink(obj.link);
|
|
204
|
+
if (link) {
|
|
205
|
+
links = [link];
|
|
206
|
+
}
|
|
202
207
|
}
|
|
203
208
|
return {
|
|
204
209
|
title: obj.title,
|
|
@@ -208,30 +213,52 @@ function parseStep(raw: unknown): UserInteractionStep | undefined {
|
|
|
208
213
|
};
|
|
209
214
|
}
|
|
210
215
|
|
|
211
|
-
function
|
|
216
|
+
function normalizeContentRef(ref: unknown): ContentRef | undefined {
|
|
212
217
|
if (typeof ref === 'string') {
|
|
213
|
-
return ref.length > 0;
|
|
218
|
+
return ref.length > 0 ? ref : undefined;
|
|
214
219
|
}
|
|
215
220
|
if (ref && typeof ref === 'object') {
|
|
216
221
|
const obj = ref as Record<string, unknown>;
|
|
217
222
|
if (obj.empty === true) {
|
|
218
|
-
|
|
223
|
+
const empty: EmptyContentRef = { empty: true };
|
|
224
|
+
if (typeof obj.label === 'string' && obj.label.length > 0) {
|
|
225
|
+
empty.label = obj.label;
|
|
226
|
+
}
|
|
227
|
+
return empty;
|
|
228
|
+
}
|
|
229
|
+
if (typeof obj.path === 'string' && obj.path.length > 0) {
|
|
230
|
+
const pathRef: PathContentRef = { path: obj.path };
|
|
231
|
+
if (typeof obj.gitRef === 'string' && obj.gitRef.length > 0) {
|
|
232
|
+
pathRef.gitRef = obj.gitRef;
|
|
233
|
+
}
|
|
234
|
+
if (typeof obj.line === 'number' && Number.isFinite(obj.line) && obj.line > 0) {
|
|
235
|
+
pathRef.line = obj.line;
|
|
236
|
+
}
|
|
237
|
+
return pathRef;
|
|
219
238
|
}
|
|
220
|
-
return typeof obj.path === 'string' && obj.path.length > 0;
|
|
221
239
|
}
|
|
222
|
-
return
|
|
240
|
+
return undefined;
|
|
223
241
|
}
|
|
224
242
|
|
|
225
|
-
function
|
|
243
|
+
export function normalizeUserInteractionLink(link: unknown): UserInteractionLink | undefined {
|
|
226
244
|
if (!link || typeof link !== 'object') {
|
|
227
|
-
return
|
|
245
|
+
return undefined;
|
|
228
246
|
}
|
|
229
247
|
const obj = link as Record<string, unknown>;
|
|
230
|
-
|
|
231
|
-
|
|
248
|
+
const ref = normalizeContentRef(obj.ref);
|
|
249
|
+
if (!ref) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
const normalized: UserInteractionLink = { ref };
|
|
253
|
+
const rightRef = normalizeContentRef(obj.rightRef);
|
|
254
|
+
if (rightRef) {
|
|
255
|
+
normalized.rightRef = rightRef;
|
|
256
|
+
}
|
|
257
|
+
if (typeof obj.label === 'string' && obj.label.length > 0) {
|
|
258
|
+
normalized.label = obj.label;
|
|
232
259
|
}
|
|
233
|
-
if (obj.
|
|
234
|
-
|
|
260
|
+
if (typeof obj.autoOpen === 'boolean') {
|
|
261
|
+
normalized.autoOpen = obj.autoOpen;
|
|
235
262
|
}
|
|
236
|
-
return
|
|
263
|
+
return normalized;
|
|
237
264
|
}
|