Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {
AgentBindingsChangedPayload,
AgentLifecyclePayload,
ChatSessionsChangedPayload,
GitChangedPayload,
PageWatchChangedPayload,
PortChangedPayload,
Expand Down Expand Up @@ -57,6 +58,12 @@ export function useWorkspaceEvent(
callback: (payload: PageWatchChangedPayload) => void,
enabled?: boolean,
): void;
export function useWorkspaceEvent(
type: "chat:sessions-changed",
workspaceId: string,
callback: (payload: ChatSessionsChangedPayload) => void,
enabled?: boolean,
): void;
export function useWorkspaceEvent(
type:
| "git:changed"
Expand All @@ -65,7 +72,8 @@ export function useWorkspaceEvent(
| "agent:bindings-changed"
| "terminal:lifecycle"
| "port:changed"
| "page-watch:changed",
| "page-watch:changed"
| "chat:sessions-changed",
workspaceId: string,
callback:
| ((event: FsWatchEvent) => void)
Expand All @@ -74,7 +82,8 @@ export function useWorkspaceEvent(
| ((payload: AgentBindingsChangedPayload) => void)
| ((payload: TerminalLifecyclePayload) => void)
| ((payload: PortChangedPayload) => void)
| ((payload: PageWatchChangedPayload) => void),
| ((payload: PageWatchChangedPayload) => void)
| ((payload: ChatSessionsChangedPayload) => void),
enabled = true,
): void {
const hostUrl = useWorkspaceHostUrl(workspaceId);
Expand Down Expand Up @@ -143,6 +152,15 @@ export function useWorkspaceEvent(
},
);
cleanups.push(removeListener);
} else if (type === "chat:sessions-changed") {
const removeListener = bus.on(
"chat:sessions-changed",
workspaceId,
(_wid, payload) => {
(handler as (payload: ChatSessionsChangedPayload) => void)(payload);
},
);
cleanups.push(removeListener);
} else {
// GitWatcher only watches a workspace while someone holds interest
// (see #6729) — watchGit/unwatchGit drive that refcount so this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { resolveAgentLaunchPresetId } from "@superset/shared/agent-models";
import { FEATURE_FLAGS } from "@superset/shared/constants";
import { useFeatureFlagEnabled } from "posthog-js/react";
import { useMemo } from "react";
import type { AgentSelectAgent } from "renderer/components/AgentSelect";
import { useV2AgentConfigs } from "renderer/hooks/useV2AgentConfigs";
Expand All @@ -10,24 +8,13 @@ interface UseV2AgentChoicesResult {
isFetched: boolean;
}

const SUPERSET_AGENT: AgentSelectAgent = {
id: "superset",
label: "Superset",
iconId: "superset",
};

// Superset chat isn't in the host's `host_agent_configs` table — it's
// chat-v3's entry point, so it rides the same flag as the rest of chat-v3.
// Append after the host's terminal rows so the user's preferred terminal
// agents stay on top.
export function useV2AgentChoices(
hostUrl: string | null,
): UseV2AgentChoicesResult {
const query = useV2AgentConfigs(hostUrl);
const isChatV3Enabled = useFeatureFlagEnabled(FEATURE_FLAGS.CHAT_V3) ?? false;
const agents = useMemo<AgentSelectAgent[]>(() => {
const terminalAgents: AgentSelectAgent[] = (query.data ?? []).map(
(config) => ({
const agents = useMemo<AgentSelectAgent[]>(
() =>
(query.data ?? []).map((config) => ({
id: config.id,
label: config.label,
// Prefer the user's icon override (built-in key or uploaded data
Expand All @@ -38,12 +25,9 @@ export function useV2AgentChoices(
config.presetId,
config.command,
),
}),
);
return isChatV3Enabled
? [...terminalAgents, SUPERSET_AGENT]
: terminalAgents;
}, [query.data, isChatV3Enabled]);
})),
[query.data],
);

return { agents, isFetched: query.isFetched };
}
9 changes: 8 additions & 1 deletion apps/desktop/src/renderer/lib/acpHarness/acpHarness.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { acpHarnessForPreset } from "./acpHarness";
import { acpHarnessForPreset, presetForAcpHarness } from "./acpHarness";

describe("acpHarnessForPreset", () => {
it("maps a preset to its harness", () => {
Expand All @@ -20,3 +20,10 @@ describe("acpHarnessForPreset", () => {
expect(acpHarnessForPreset(undefined)).toBeUndefined();
});
});

describe("presetForAcpHarness", () => {
it("maps a harness back to its preset", () => {
expect(presetForAcpHarness("claude-acp")).toBe("claude");
expect(presetForAcpHarness("claude-code")).toBeUndefined();
});
});
6 changes: 6 additions & 0 deletions apps/desktop/src/renderer/lib/acpHarness/acpHarness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ export function acpHarnessForPreset(
): string | undefined {
return presetId ? ACP_HARNESS_BY_PRESET[presetId] : undefined;
}

export function presetForAcpHarness(harness: string): string | undefined {
return Object.entries(ACP_HARNESS_BY_PRESET).find(
([, candidate]) => candidate === harness,
)?.[0];
}
2 changes: 1 addition & 1 deletion apps/desktop/src/renderer/lib/acpHarness/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { acpHarnessForPreset } from "./acpHarness";
export { acpHarnessForPreset, presetForAcpHarness } from "./acpHarness";
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const PERSISTED_KEY_REGISTRY: ReadonlyArray<
["chatFavoriteModels"],
],
[
"src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/AgentTerminalPane/utils/savedChatMode/savedChatMode.ts",
"src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/ChatPane/utils/savedChatMode/savedChatMode.ts",
["chatModeByAgent"],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import {
} from "@superset/ui/dropdown-menu";
import { BsTerminalPlus } from "react-icons/bs";
import { LuGitCompareArrows } from "react-icons/lu";
import { TbDeviceDesktop, TbMessageCirclePlus, TbWorld } from "react-icons/tb";
import { TbDeviceDesktop, TbWorld } from "react-icons/tb";
import { HotkeyMenuShortcut } from "renderer/components/HotkeyMenuShortcut";

interface AddTabMenuProps {
onAddTerminal: () => void;
onAddChatV3?: (() => void) | undefined;
onAddBrowser: () => void;
onAddChanges: () => void;
onAddDesktop?: (() => void) | undefined;
Expand All @@ -21,7 +20,6 @@ interface AddTabMenuProps {

export function AddTabMenu({
onAddTerminal,
onAddChatV3,
onAddBrowser,
onAddChanges,
onAddDesktop,
Expand All @@ -37,14 +35,6 @@ export function AddTabMenu({
</span>
<HotkeyMenuShortcut hotkeyId="NEW_GROUP" />
</DropdownMenuItem>
{onAddChatV3 && (
<DropdownMenuItem className="gap-2" onClick={onAddChatV3}>
<TbMessageCirclePlus className="size-4" />
<span>
<Trans>Chat v3</Trans>
</span>
</DropdownMenuItem>
)}
<DropdownMenuItem className="gap-2" onClick={onAddBrowser}>
<TbWorld className="size-4" />
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ interface RightPaneAreaProps {
onToggleExpanded: () => void;
onMergeIntoCenter: () => void;
onAdd: (kind: RightPaneKind) => void;
isChatEnabled: boolean;
showWindowControls: boolean;
}

Expand All @@ -51,7 +50,6 @@ export function RightPaneArea({
onToggleExpanded,
onMergeIntoCenter,
onAdd,
isChatEnabled,
showWindowControls,
}: RightPaneAreaProps) {
const { t } = useLingui();
Expand All @@ -68,9 +66,7 @@ export function RightPaneArea({
sources={getV2NotificationSourcesForTab(tab)}
/>
)}
renderAddTabMenu={() => (
<RightPaneAddMenu onAdd={onAdd} isChatEnabled={isChatEnabled} />
)}
renderAddTabMenu={() => <RightPaneAddMenu onAdd={onAdd} />}
renderTabBarTrailing={() => (
<div className="flex items-center gap-1 pr-1">
<RightPaneHeaderButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ import {
LuFolderTree,
LuGitPullRequestArrow,
} from "react-icons/lu";
import { TbMessageCirclePlus, TbWorld } from "react-icons/tb";
import { TbWorld } from "react-icons/tb";
import type { RightPaneKind } from "../../types";

interface RightPaneAddMenuProps {
onAdd: (kind: RightPaneKind) => void;
isChatEnabled: boolean;
}

export function RightPaneAddMenu({
onAdd,
isChatEnabled,
}: RightPaneAddMenuProps) {
export function RightPaneAddMenu({ onAdd }: RightPaneAddMenuProps) {
return (
<>
<DropdownMenuItem className="gap-2" onClick={() => onAdd("files")}>
Expand Down Expand Up @@ -62,14 +58,6 @@ export function RightPaneAddMenu({
<Trans>Browser</Trans>
</span>
</DropdownMenuItem>
{isChatEnabled && (
<DropdownMenuItem className="gap-2" onClick={() => onAdd("chat-v3")}>
<TbMessageCirclePlus className="size-4" />
<span>
<Trans>Chat v3</Trans>
</span>
</DropdownMenuItem>
)}
<DropdownMenuItem className="gap-2" onClick={() => onAdd("terminal")}>
<BsTerminalPlus className="size-4" />
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ export type RightPaneKind =
| "review"
| "pages-list"
| "browser"
| "chat-v3"
| "terminal";
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMemo } from "react";
import type { IconType } from "react-icons";
import { BsTerminalPlus } from "react-icons/bs";
import { LuGitCompareArrows, LuSearch } from "react-icons/lu";
import { TbMessageCirclePlus, TbWorld } from "react-icons/tb";
import { TbWorld } from "react-icons/tb";
import { GitHubStarPill } from "renderer/components/GitHubStarPill";
import { useHotkeyDisplay } from "renderer/hotkeys";
import supersetEmptyStateWordmark from "renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/assets/superset-empty-state-wordmark.svg";
Expand All @@ -13,7 +13,6 @@ import { useTheme } from "renderer/stores/theme";
interface WorkspaceEmptyStateProps {
onOpenBrowser: () => void;
onOpenChanges: () => void;
onOpenChatV3?: (() => void) | undefined;
onOpenQuickOpen: () => void;
onOpenTerminal: () => void;
}
Expand All @@ -29,7 +28,6 @@ interface WorkspaceEmptyStateAction {
export function WorkspaceEmptyState({
onOpenBrowser,
onOpenChanges,
onOpenChatV3,
onOpenQuickOpen,
onOpenTerminal,
}: WorkspaceEmptyStateProps) {
Expand All @@ -51,19 +49,6 @@ export function WorkspaceEmptyState({
icon: BsTerminalPlus,
onClick: onOpenTerminal,
},
...(onOpenChatV3
? [
{
id: "chat-v3",
label: t({
message: "Open Chat v3",
}),
display: [],
icon: TbMessageCirclePlus,
onClick: onOpenChatV3,
},
]
: []),
{
id: "browser",
label: t({
Expand Down Expand Up @@ -97,7 +82,6 @@ export function WorkspaceEmptyState({
newGroupDisplay,
onOpenBrowser,
onOpenChanges,
onOpenChatV3,
onOpenQuickOpen,
onOpenTerminal,
openChangesDisplay,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import {
import { acpHarnessForPreset } from "renderer/lib/acpHarness";
import { terminalQueryColors } from "renderer/lib/terminal/terminal-query-colors";
import type { StoreApi } from "zustand/vanilla";
import type { PaneViewerData, TerminalPaneData } from "../../types";
import type {
ChatPaneData,
PaneViewerData,
TerminalPaneData,
} from "../../types";
import { focusOrAddTerminalPane } from "../../utils/focusTerminalPane";

export interface CreateNewAgentSessionInput {
Expand Down Expand Up @@ -71,19 +75,19 @@ export function useAgentSessionLauncher({
const terminalId = crypto.randomUUID();
const label = config?.label;
const pane = {
kind: "terminal" as const,
kind: "chat-v3" as const,
...(label ? { titleOverride: label } : {}),
data: {
terminalId,
agentSurface: "acp",
sessionId: null,
agent: { id: presetId },
...(input.prompt ? { pendingPrompt: input.prompt } : {}),
...(input.attachments?.length
? { pendingAttachments: input.attachments }
: {}),
...(input.modelId ? { chatModelId: input.modelId } : {}),
...(input.modeId ? { chatModeId: input.modeId } : {}),
} as TerminalPaneData,
} satisfies ChatPaneData,
};
if (input.placement === "split-pane" && state.activeTabId) {
state.addPane({ tabId: state.activeTabId, pane });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useAutoAdoptChatSessions } from "./useAutoAdoptChatSessions";
Loading
Loading