-
Notifications
You must be signed in to change notification settings - Fork 897
feat: superset chat launch config + icon #1983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
eb8ffea
feat: add agent launch orchestrator + superset chat
Kitenite 3662b43
feat: add chat launch config and superset icon
Kitenite 69c70d6
chore: remove agent launch feature flag
Kitenite fab395e
fix: address review nits
Kitenite e7a20af
chore: apply lint fixes
Kitenite 2c823f7
test(desktop): mock posthog in agent session orchestrator test
Kitenite 4107992
chore: format agent session orchestrator test
Kitenite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
apps/desktop/src/renderer/lib/agent-session-orchestrator/adapters/chat-adapter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import type { AgentLaunchRequest } from "@superset/shared/agent-launch"; | ||
| import type { ChatMastraLaunchConfig } from "shared/tabs-types"; | ||
| import type { AgentSessionLaunchContext, LaunchResultPayload } from "../types"; | ||
|
|
||
| type ChatLaunchRequest = Extract<AgentLaunchRequest, { kind: "chat" }>; | ||
|
|
||
| function toLaunchConfig( | ||
| request: ChatLaunchRequest, | ||
| ): ChatMastraLaunchConfig | null { | ||
| const initialPrompt = request.chat.initialPrompt?.trim(); | ||
| const model = request.chat.model?.trim(); | ||
| const retryCount = request.chat.retryCount; | ||
|
|
||
| if (!initialPrompt && !model && retryCount === undefined) { | ||
| return null; | ||
| } | ||
|
|
||
| return { | ||
| initialPrompt: initialPrompt || undefined, | ||
| metadata: model ? { model } : undefined, | ||
| retryCount, | ||
| }; | ||
| } | ||
|
|
||
| export async function launchChatAdapter( | ||
| request: ChatLaunchRequest, | ||
| context: AgentSessionLaunchContext, | ||
| ): Promise<LaunchResultPayload> { | ||
| const tabs = context.tabs; | ||
| if (!tabs) { | ||
| throw new Error("Missing tabs adapter"); | ||
| } | ||
|
|
||
| let tabId: string; | ||
| let paneId: string; | ||
| const launchConfig = toLaunchConfig(request); | ||
|
|
||
| const targetPaneId = request.chat.paneId; | ||
| if (targetPaneId) { | ||
| const targetPane = tabs.getPane(targetPaneId); | ||
| if (!targetPane) { | ||
| throw new Error(`Pane not found: ${targetPaneId}`); | ||
| } | ||
| const tab = tabs.getTab(targetPane.tabId); | ||
| if (!tab || tab.workspaceId !== request.workspaceId) { | ||
| throw new Error(`Tab not found for pane: ${targetPaneId}`); | ||
| } | ||
|
|
||
| if (targetPane.type === "chat-mastra") { | ||
| tabId = tab.id; | ||
| paneId = targetPane.id; | ||
| } else { | ||
| const nextPaneId = tabs.addChatPane(tab.id, { | ||
| launchConfig, | ||
| }); | ||
| tabId = tab.id; | ||
| paneId = nextPaneId; | ||
| } | ||
| } else { | ||
| const created = tabs.addChatTab(request.workspaceId, { | ||
| launchConfig, | ||
| }); | ||
| tabId = created.tabId; | ||
| paneId = created.paneId; | ||
| } | ||
|
|
||
| tabs.setTabAutoTitle(tabId, "Superset Chat"); | ||
|
|
||
| const pane = tabs.getPane(paneId); | ||
| let sessionId = request.chat.sessionId ?? pane?.chatMastra?.sessionId ?? null; | ||
| if (!sessionId) { | ||
| sessionId = crypto.randomUUID(); | ||
| } | ||
|
|
||
| if (pane?.chatMastra?.sessionId !== sessionId) { | ||
| tabs.switchChatSession(paneId, sessionId); | ||
| } | ||
|
|
||
| if (launchConfig) { | ||
| tabs.setChatLaunchConfig(paneId, launchConfig); | ||
| } | ||
|
Comment on lines
+79
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always persist launch config (including When a pane is reused and the new request has no launch config, the current conditional leaves prior 💡 Suggested fix- if (launchConfig) {
- tabs.setChatLaunchConfig(paneId, launchConfig);
- }
+ tabs.setChatLaunchConfig(paneId, launchConfig);🤖 Prompt for AI Agents |
||
|
|
||
| return { | ||
| tabId, | ||
| paneId, | ||
| sessionId, | ||
| }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent success toast after failed existing-workspace agent launch.
On Line 350, failure only shows an error toast, but execution continues and still emits the success toast on Line 357 for existing workspaces.
🛠️ Suggested fix
if (launchRequest && result.wasExisting) { const launchResult = await launchAgentSession(launchRequest, { source: "new-workspace", createOrAttach: (input) => terminalCreateOrAttach.mutateAsync(input), write: (input) => terminalWrite.mutateAsync(input), }); if (launchResult.status === "failed") { toast.error("Failed to start agent", { description: launchResult.error ?? "Failed to start agent session.", }); + return; } }📝 Committable suggestion
🤖 Prompt for AI Agents