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
@@ -0,0 +1,15 @@
import { Construction } from "lucide-react";

export function ChatUnderConstruction() {
return (
<div className="flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center">
<Construction className="size-8 text-muted-foreground" />
<div className="space-y-1">
<p className="font-medium text-sm">Chat is being reworked</p>
<p className="text-muted-foreground text-xs">
We're rebuilding this feature. Check back soon.
</p>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ChatUnderConstruction } from "./ChatUnderConstruction";
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
import { ChatUnderConstruction } from "renderer/components/ChatUnderConstruction";
import type { ChatLaunchConfig } from "shared/tabs-types";
import { ChatPaneInterface as WorkspaceChatInterface } from "./components/WorkspaceChatInterface";
import { useWorkspaceChatController } from "./hooks/useWorkspaceChatController";

export function ChatPane({
onSessionIdChange,
sessionId,
workspaceId,
initialLaunchConfig,
onConsumeLaunchConfig,
}: {
// Chat is temporarily disabled while it's being reworked; the pane keeps its
// props so existing chat panes still mount without churn in the registry.
export function ChatPane(_props: {
onSessionIdChange: (sessionId: string | null) => void;
sessionId: string | null;
workspaceId: string;
initialLaunchConfig?: ChatLaunchConfig | null;
onConsumeLaunchConfig?: () => void;
}) {
const { organizationId, workspacePath, handleNewChat, getOrCreateSession } =
useWorkspaceChatController({
onSessionIdChange,
sessionId,
workspaceId,
});

return (
<WorkspaceChatInterface
getOrCreateSession={getOrCreateSession}
initialLaunchConfig={initialLaunchConfig ?? null}
onConsumeLaunchConfig={onConsumeLaunchConfig}
isFocused
onResetSession={handleNewChat}
sessionId={sessionId}
workspaceId={workspaceId}
organizationId={organizationId}
cwd={workspacePath}
/>
);
return <ChatUnderConstruction />;
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
import {
ChatRuntimeServiceProvider,
ChatServiceProvider,
} from "@superset/chat-legacy/client";
import { useCallback } from "react";
import type { MosaicBranch } from "react-mosaic-component";
import { createChatServiceIpcClient } from "renderer/components/Chat/utils/chat-service-client";
import { electronQueryClient } from "renderer/providers/ElectronTRPCProvider";
import { ChatUnderConstruction } from "renderer/components/ChatUnderConstruction";
import { useTabsStore } from "renderer/stores/tabs/store";
import type { SplitPaneOptions, Tab } from "renderer/stores/tabs/types";
import { TabContentContextMenu } from "../../TabContentContextMenu";
import { BasePaneWindow, PaneToolbarActions } from "../components";
import { ChatPaneInterface } from "./ChatPaneInterface";
import { SessionSelector } from "./components/SessionSelector";
import { useChatPaneController } from "./hooks/useChatPaneController";
import { createChatRuntimeServiceIpcClient } from "./utils/chat-runtime-service-client";

const chatRuntimeIpcClient = createChatRuntimeServiceIpcClient();
const chatIpcClient = createChatServiceIpcClient();

interface ChatPaneProps {
paneId: string;
Expand Down Expand Up @@ -48,11 +35,12 @@ interface ChatPaneProps {
onMoveToNewTab: () => void;
}

// Chat is temporarily disabled while it's being reworked; the pane keeps its
// chrome (toolbar, split/close, context menu) but renders a placeholder.
export function ChatPane({
paneId,
path,
tabId,
workspaceId,
splitPaneAuto,
splitPaneHorizontal,
splitPaneVertical,
Expand All @@ -62,141 +50,53 @@ export function ChatPane({
onMoveToTab,
onMoveToNewTab,
}: ChatPaneProps) {
const isFocused = useTabsStore((s) => s.focusedPaneIds[tabId] === paneId);
const equalizePaneSplits = useTabsStore((s) => s.equalizePaneSplits);
const paneName = useTabsStore((s) => s.panes[paneId]?.name ?? "New Chat");
const setTabAutoTitle = useTabsStore((s) => s.setTabAutoTitle);
const setPaneAutoTitle = useTabsStore((s) => s.setPaneAutoTitle);
const {
sessionId,
launchConfig,
organizationId,
workspacePath,
isSessionInitializing,
hasCurrentSessionRecord,
sessionItems,
handleSelectSession,
handleNewChat,
handleStartFreshSession,
handleDeleteSession,
ensureCurrentSessionRecord,
consumeLaunchConfig,
} = useChatPaneController({
paneId,
workspaceId,
});

const applySubmittedMessageFallbackTitle = useCallback(
(message: string) => {
const normalized = message.trim().replace(/\s+/g, " ");
if (!normalized) return;
const fallbackTitle =
normalized.length > 72
? `${normalized.slice(0, 69).trimEnd()}...`
: normalized;

const state = useTabsStore.getState();
const pane = state.panes[paneId];
const tab = state.tabs.find((candidate) => candidate.id === tabId);
const tabPaneCount = Object.values(state.panes).filter(
(candidate) => candidate.tabId === tabId,
).length;
const paneName = pane?.name?.trim() ?? "";
const tabName = tab?.name?.trim() ?? "";
const hasCustomTabTitle = Boolean(tab?.userTitle?.trim());
const shouldSetPaneTitle =
paneName.length === 0 || paneName === "New Chat";
const shouldSetTabTitle =
!hasCustomTabTitle &&
(tabName.length === 0 ||
tabName === "New Chat" ||
(tabPaneCount === 1 && pane?.type === "chat"));

if (shouldSetPaneTitle) {
setPaneAutoTitle(paneId, fallbackTitle);
}
if (shouldSetTabTitle) {
setTabAutoTitle(tabId, fallbackTitle);
}
},
[paneId, setPaneAutoTitle, setTabAutoTitle, tabId],
);

return (
<ChatRuntimeServiceProvider
client={chatRuntimeIpcClient}
queryClient={electronQueryClient}
<BasePaneWindow
paneId={paneId}
path={path}
tabId={tabId}
splitPaneAuto={splitPaneAuto}
removePane={removePane}
setFocusedPane={setFocusedPane}
renderToolbar={(handlers) => (
<div className="flex h-full w-full items-center justify-between px-3">
<span className="min-w-0 flex-1 truncate pr-2 text-sm">
{paneName}
</span>
<PaneToolbarActions
splitOrientation={handlers.splitOrientation}
onSplitPane={handlers.onSplitPane}
onClosePane={handlers.onClosePane}
/>
</div>
)}
>
<ChatServiceProvider
client={chatIpcClient}
queryClient={electronQueryClient}
<TabContentContextMenu
onSplitHorizontal={() => splitPaneHorizontal(tabId, paneId, path)}
onSplitVertical={() => splitPaneVertical(tabId, paneId, path)}
onSplitWithNewChat={() =>
splitPaneVertical(tabId, paneId, path, {
paneType: "chat",
})
}
onSplitWithNewBrowser={() =>
splitPaneVertical(tabId, paneId, path, { paneType: "webview" })
}
onEqualizePaneSplits={() => equalizePaneSplits(tabId)}
onClosePane={() => removePane(paneId)}
currentTabId={tabId}
availableTabs={availableTabs}
onMoveToTab={onMoveToTab}
onMoveToNewTab={onMoveToNewTab}
closeLabel="Close Chat"
>
<BasePaneWindow
paneId={paneId}
path={path}
tabId={tabId}
splitPaneAuto={splitPaneAuto}
removePane={removePane}
setFocusedPane={setFocusedPane}
renderToolbar={(handlers) => (
<div className="flex h-full w-full items-center justify-between px-3">
<div className="flex min-w-0 flex-1 items-center gap-2 pr-2">
<SessionSelector
currentSessionId={sessionId}
sessions={sessionItems}
fallbackTitle={paneName}
isSessionInitializing={isSessionInitializing}
onSelectSession={handleSelectSession}
onNewChat={handleNewChat}
onDeleteSession={handleDeleteSession}
/>
</div>
<PaneToolbarActions
splitOrientation={handlers.splitOrientation}
onSplitPane={handlers.onSplitPane}
onClosePane={handlers.onClosePane}
/>
</div>
)}
>
<TabContentContextMenu
onSplitHorizontal={() => splitPaneHorizontal(tabId, paneId, path)}
onSplitVertical={() => splitPaneVertical(tabId, paneId, path)}
onSplitWithNewChat={() =>
splitPaneVertical(tabId, paneId, path, {
paneType: "chat",
})
}
onSplitWithNewBrowser={() =>
splitPaneVertical(tabId, paneId, path, { paneType: "webview" })
}
onEqualizePaneSplits={() => equalizePaneSplits(tabId)}
onClosePane={() => removePane(paneId)}
currentTabId={tabId}
availableTabs={availableTabs}
onMoveToTab={onMoveToTab}
onMoveToNewTab={onMoveToNewTab}
closeLabel="Close Chat"
>
<div className="h-full w-full">
<ChatPaneInterface
paneId={paneId}
sessionId={sessionId}
initialLaunchConfig={launchConfig}
workspaceId={workspaceId}
organizationId={organizationId}
cwd={workspacePath}
isFocused={isFocused}
isSessionReady={hasCurrentSessionRecord}
ensureSessionReady={ensureCurrentSessionRecord}
onStartFreshSession={handleStartFreshSession}
onConsumeLaunchConfig={consumeLaunchConfig}
onUserMessageSubmitted={applySubmittedMessageFallbackTitle}
/>
</div>
</TabContentContextMenu>
</BasePaneWindow>
</ChatServiceProvider>
</ChatRuntimeServiceProvider>
<div className="h-full w-full">
<ChatUnderConstruction />
</div>
</TabContentContextMenu>
</BasePaneWindow>
);
}
Loading