Skip to content

Commit 4c4a87a

Browse files
committed
Some improvements for VS code extension Library index
1 parent 54db6d1 commit 4c4a87a

File tree

7 files changed

+32
-14
lines changed

7 files changed

+32
-14
lines changed

packages/common/src/dto/function/function.dto.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface FunctionDefinitionDto {
1919
id: string;
2020
context: string;
2121
name: string;
22+
description: string;
2223
arguments: FunctionArgument[];
2324
returnType: string;
2425
customCode?: string;

packages/vscode-extension/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 0.1.8
2+
* Some library index tree related improvements
3+
14
### 0.1.7
25
* Added library index tree
36

packages/vscode-extension/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Poly Assistant",
44
"description": "Poly AI assistant for VS Code",
55
"icon": "resources/poly-logo.png",
6-
"version": "0.1.7",
6+
"version": "0.1.8",
77
"publisher": "Poly API Corp",
88
"engines": {
99
"vscode": "^1.75.0"
@@ -76,12 +76,14 @@
7676
{
7777
"type": "tree",
7878
"id": "poly.library-index-view",
79-
"name": "Library",
79+
"icon": "resources/poly-library-index.png",
80+
"name": "poly",
8081
"when": "polyLibraryInstalled == true"
8182
},
8283
{
8384
"id": "poly.library-info",
84-
"name": "Library",
85+
"name": "poly",
86+
"icon": "resources/poly-library-index.png",
8587
"when": "polyLibraryInstalled == false"
8688
}
8789
]
8.5 KB
Loading

packages/vscode-extension/src/library-index-view-provider.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@ class LibraryTreeItem extends vscode.TreeItem {
1111
super(label, collapsibleState);
1212
switch (data.type) {
1313
case 'function':
14-
this.tooltip = new vscode.MarkdownString(`**Function** \n${data.name}(${data.arguments.map(arg => `${arg.name}: ${arg.type}`).join(', ')})`);
14+
const title = data.customCode ? 'Custom function' : 'Function';
15+
this.tooltip = new vscode.MarkdownString(
16+
`**${title}**\n\n---\n\n${data.description
17+
? `${data.description}\n\n---\n\n`
18+
: ''}${data.name}(${data.arguments.map(arg => `${arg.name}: ${arg.type}`).join(', ')})`,
19+
);
1520
break;
1621
case 'webhookHandle':
17-
this.tooltip = new vscode.MarkdownString(`**Webhook listener** \n${data.name}()`);
22+
this.tooltip = new vscode.MarkdownString(
23+
`**Webhook listener**\n\n---\n\n${data.name}()`,
24+
);
1825
break;
1926
default:
20-
this.tooltip = new vscode.MarkdownString(`**Context** \n${label}`);
27+
this.tooltip = new vscode.MarkdownString(
28+
`**Context**\n\n---\n\n${label}`,
29+
);
2130
break;
2231
}
2332
}
@@ -55,13 +64,11 @@ export default class LibraryIndexViewProvider implements vscode.TreeDataProvider
5564
}
5665

5766
getTreeItem(element: LibraryTreeItem): TreeItem | Thenable<TreeItem> {
58-
if (element.data.type === 'function' || element.data.type === 'webhookHandle') {
59-
element.command = {
60-
title: 'Copy to clipboard',
61-
command: 'poly.copyLibraryItem',
62-
arguments: [element],
63-
};
64-
}
67+
element.command = {
68+
title: 'Copy to clipboard',
69+
command: 'poly.copyLibraryItem',
70+
arguments: [element],
71+
};
6572
return element;
6673
}
6774

@@ -72,7 +79,7 @@ export default class LibraryIndexViewProvider implements vscode.TreeDataProvider
7279
}
7380

7481
static copyLibraryItem(item: LibraryTreeItem) {
75-
const { parentPath, data } = item;
82+
const { parentPath, data, label } = item;
7683
switch (data.type) {
7784
case 'function':
7885
vscode.env.clipboard.writeText(`await ${parentPath}.${data.name}(${data.arguments.map(arg => `${arg.name}`).join(', ')});`);
@@ -81,7 +88,10 @@ export default class LibraryIndexViewProvider implements vscode.TreeDataProvider
8188
vscode.env.clipboard.writeText(`${parentPath}.${data.name}(data => {\n\n});`);
8289
break;
8390
default:
91+
console.log('%c ', 'background: yellow; color: black', item);
92+
vscode.env.clipboard.writeText(`await ${parentPath}.${label}.`);
8493
break;
8594
}
95+
vscode.window.showInformationMessage('Copied');
8696
}
8797
}
3.17 KB
Binary file not shown.

src/function/function.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ export class FunctionService {
292292
return {
293293
id: urlFunction.publicId,
294294
name: urlFunction.name,
295+
description: urlFunction.description,
295296
context: urlFunction.context,
296297
arguments: this.getArguments(urlFunction),
297298
returnType: urlFunction.responseType,
@@ -313,6 +314,7 @@ export class FunctionService {
313314
return {
314315
id: customFunction.publicId,
315316
name: customFunction.name,
317+
description: customFunction.description,
316318
context: customFunction.context,
317319
arguments: JSON.parse(customFunction.arguments),
318320
returnType: customFunction.returnType,

0 commit comments

Comments
 (0)