Skip to content

Commit

Permalink
feat: teammates feature (#1433)
Browse files Browse the repository at this point in the history
* feat: coach ai teammate

* fix: integration

* fix: integration

* fix: integration

* fix: integration

* fix: coach form UI

* fix: success message after save coach info

* fix: coach ai in model or column context

* fix: doc model ai coach

* fix: citations

* fix: model generation

* fix: config for teammates feature

* fix: coach ai

* fix: make citations link to frontend

* fix: teammates enabled flag from backend

* fix: interactions

* fix: learning redirection

* revert: unnecessary changes

* revert: generated files

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/webview_provider/altimateWebviewProvider.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* chore: cleanup

* chore: cleanup

* fix: tasklabel for citations

* fix: content update

* fix: lib updates

* fix: ts error

* fix: ts error

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
saravmajestic and coderabbitai[bot] authored Oct 3, 2024
1 parent 20ca78d commit eb1344b
Show file tree
Hide file tree
Showing 43 changed files with 47,460 additions and 28,004 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
"description": "Enable dbt docs collaboration.",
"default": true
},
"dbt.enableTeammates": {
"type": "boolean",
"description": "Enable AltimateAI teammates feature.",
"default": false
},
"dbt.enableQueryBookmarks": {
"type": "boolean",
"description": "Enable Query history and bookmarks feature",
Expand Down
2 changes: 2 additions & 0 deletions src/altimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ export interface DocsGenerateResponse {
column_descriptions?: {
column_name: string;
column_description: string;
column_citations?: { id: string; content: string }[];
}[];
model_description?: string;
model_citations?: { id: string; content: string }[];
}

export interface DBTCoreIntegration {
Expand Down
9 changes: 5 additions & 4 deletions src/services/docGenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,19 @@ export class DocGenService {
}

private async transmitAIGeneratedModelDocs(
description: string,
response: DocsGenerateResponse,
syncRequestId?: string,
panel?: WebviewView | WebviewPanel,
) {
if (panel) {
const result = syncRequestId
? {
command: "response",
args: { body: { description }, syncRequestId, status: true },
args: { body: response, syncRequestId, status: true },
}
: {
command: "renderAIGeneratedModelDocs",
description,
response,
};
await panel.webview.postMessage(result);
}
Expand Down Expand Up @@ -375,6 +375,7 @@ export class DocGenService {
generatedDocsForColumn.column_descriptions.map((entry) => ({
name: entry.column_name,
description: entry.column_description,
citations: entry.column_citations,
})),
message.syncRequestId,
);
Expand Down Expand Up @@ -471,7 +472,7 @@ export class DocGenService {
return;
}
this.transmitAIGeneratedModelDocs(
generateDocsForModel.model_description,
generateDocsForModel,
message.syncRequestId,
panel,
);
Expand Down
31 changes: 31 additions & 0 deletions src/webview_provider/altimateWebviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ export class AltimateWebviewProvider implements WebviewViewProvider {
t.onEvent(d as SharedStateEventEmitterProps),
),
);

workspace.onDidChangeConfiguration(
(e) => {
if (e.affectsConfiguration("dbt.enableTeammates")) {
const isEnabled = workspace
.getConfiguration("dbt")
.get<boolean>("enableTeammates", false);
const event = isEnabled ? "TeammatesEnabled" : "TeammatesDisabled";
this.telemetry.sendTelemetryEvent(event);
if (this._panel) {
this.sendResponseToWebview({
command: "teammatesUpdated",
data: isEnabled,
});
}
}
},
this,
this._disposables,
);
}

public isWebviewView(
Expand Down Expand Up @@ -223,6 +243,17 @@ export class AltimateWebviewProvider implements WebviewViewProvider {

try {
switch (command) {
case "getTeammatesStatus":
{
const isEnabled = workspace
.getConfiguration("dbt")
.get<boolean>("enableTeammates", false);
this.sendResponseToWebview({
command: "teammatesUpdated",
data: isEnabled,
});
break;
}
case "configEnabled":
this.handleSyncRequestFromWebview(
syncRequestId,
Expand Down
1 change: 1 addition & 0 deletions src/webview_provider/docsEditPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface DBTDocumentation {
export interface AIColumnDescription {
name: string;
description: string;
citations?: { id: string; content: string }[];
}

export interface DocsGenPanelView extends WebviewViewProvider {
Expand Down
1 change: 1 addition & 0 deletions webview_panels/.storybook/__mocks__/crypto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
17 changes: 14 additions & 3 deletions webview_panels/.storybook/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ let func = undefined;
export const vscode = {
postMessage: async (args: Record<string, unknown>) => {
if (args.syncRequestId) {
const body = typeof func === 'function' ? (func as Function)(args) : data;
let response;
let status = true;
try {
const body =
typeof func === "function" ? await (func as (args: Record<string, unknown>) => unknown)(args) : data;
response = { body };
} catch (error) {
response = {
error: (error as Error).message,
};
status = false;
}
setTimeout(() => {
window.postMessage({
command: "response",
args: {
syncRequestId: args.syncRequestId,
body,
status: true,
...response,
status,
},
});
}, timer);
Expand Down
5 changes: 5 additions & 0 deletions webview_panels/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config: StorybookConfig = {
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
staticDirs: ["../src/assets"],
framework: {
name: "@storybook/react-vite",
options: {},
Expand All @@ -23,6 +24,10 @@ const config: StorybookConfig = {
config.resolve.alias["@vscodeApi"] = require.resolve(
"./__mocks__/vscode.ts"
);

config.resolve.alias["crypto"] = require.resolve(
"./__mocks__/crypto.ts"
);
}
// Merge custom configuration into the default config
return mergeConfig(config, {
Expand Down
Loading

0 comments on commit eb1344b

Please sign in to comment.