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
12 changes: 2 additions & 10 deletions apps/desktop/src/components/CloudWorkspacePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useEffect, useRef, useState } from "react";
import { Check, Cloud, FileText, FolderOpen, Laptop2, Loader2, MessageSquare, Plus, RefreshCw, Send, ShieldCheck, Users, X } from "lucide-react";
import { useCloudWorkspace } from "../hooks/use-cloud-workspace";
import type { CloudWorkspaceController } from "../hooks/use-cloud-workspace";
import { MessageContent } from "./MessageContent";
import { publishTeamWorkspaceNav, subscribeTeamWorkspaceRequest } from "../lib/team-workspace-events";
import { CloudWorkspaceDrawer } from "./CloudWorkspaceDrawer";

const friendlyCloudError = (message: string) => message.toLowerCase().includes("fetch failed")
Expand All @@ -13,8 +12,7 @@ function CloudRetryError({ message, className = "", onRetry }: { message: string
return <div className={`cloud-error cloud-retry-error ${className}`.trim()}><span>{friendlyCloudError(message)}</span><button onClick={onRetry}><RefreshCw /> Retry</button></div>;
}

export function CloudWorkspacePanel() {
const cloud = useCloudWorkspace();
export function CloudWorkspacePanel({ cloud }: { cloud: CloudWorkspaceController }) {
const [workspaceName, setWorkspaceName] = useState("BlockRun Cloud Workspace");
const [inviteInput, setInviteInput] = useState("");
const [message, setMessage] = useState("");
Expand All @@ -29,12 +27,6 @@ export function CloudWorkspacePanel() {
const scrollRef = useRef<HTMLDivElement>(null);

useEffect(() => { scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight }); }, [cloud.messages, cloud.sending]);
useEffect(() => publishTeamWorkspaceNav({
items: cloud.workspaces.map((workspace) => ({ id: workspace.id, name: workspace.name, role: workspace.role, memberCount: workspace.members.length, version: workspace.version })),
activeId: cloud.activeId,
loading: cloud.loading && !cloud.session,
}), [cloud.activeId, cloud.loading, cloud.session, cloud.workspaces]);
useEffect(() => subscribeTeamWorkspaceRequest(cloud.setActiveId), [cloud.setActiveId]);

const openFile = async (path: string) => {
setSelectedFile(path);
Expand Down
40 changes: 29 additions & 11 deletions apps/desktop/src/components/FranklinChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { useWallet } from "../hooks/use-wallet";
import { useTryLang } from "../lib/i18n";
import { prepareImageForUpload } from "../lib/image-compress";
import { useStudioRegistry } from "../hooks/use-studio-registry";
import { requestTeamWorkspace, subscribeTeamWorkspaceNav, type TeamWorkspaceNavState } from "../lib/team-workspace-events";
import { useCloudWorkspace } from "../hooks/use-cloud-workspace";
import { safeExternalHttpUrl } from "../lib/external-url";

// Composer "focus" modes — force a specific live-data tool (server tool_choice).
Expand Down Expand Up @@ -86,8 +86,18 @@ export function FranklinChat() {
const history = useChatHistory(auth.address, chatSpace);
const usage = useSpend();
const studio = useStudioRegistry();
const [teamNav, setTeamNav] = useState<TeamWorkspaceNavState>({ items: [], activeId: null, loading: true });
useEffect(() => subscribeTeamWorkspaceNav(setTeamNav), []);
const cloud = useCloudWorkspace();
const teamNav = {
items: cloud.workspaces.map((workspace) => ({
id: workspace.id,
name: workspace.name,
role: workspace.role,
memberCount: workspace.members.length,
version: workspace.version,
})),
activeId: cloud.activeId,
loading: cloud.loading && !cloud.session,
};
const chat = useFranklinChat(history.messages, history.setMessages, history.ensureConvId);
const { mode, setMode, model, setModel, models, selectedModel, status, activeTool, needsToolWallet, genConvId, mediaJobs, error, pendingPermission, respondToPermission, isBusy, isConnected, send, stop, stopMedia, regenerate, imageSize, setImageSize, imageSizes, videoRatio, setVideoRatio, videoRatios, videoResolution, setVideoResolution, videoResolutions } = chat;
const genHere = genConvId === null || genConvId === history.activeId;
Expand Down Expand Up @@ -240,20 +250,28 @@ export function FranklinChat() {
return (
<div className="try-shell">
<HistorySidebar
conversations={history.visibleConversations}
conversations={history.personalConversations}
activeId={history.activeId}
onNew={() => {
if (chatSpace === "team") requestTeamWorkspace(null);
else history.newChat();
onNewChat={() => {
setChatSpace("personal");
history.newChatInSpace("personal");
setView("chat");
closeSidebarOnMobile();
}}
onNewProject={() => {
setChatSpace("team");
cloud.setActiveId(null);
setView("chat");
closeSidebarOnMobile();
}}
onSelect={(id) => {
history.selectChat(id);
setChatSpace("personal");
history.selectChatInSpace("personal", id);
setView("chat");
closeSidebarOnMobile();
}}
onDelete={history.deleteChat}
onTogglePinned={history.togglePinned}
view={view}
onView={(v) => {
setView(v);
Expand All @@ -267,13 +285,13 @@ export function FranklinChat() {
switchingWalletChain={switchingWalletChain}
onSwitchWalletChain={switchWalletChain}
chatSpace={chatSpace}
onChatSpace={setChatSpace}
teamModeEnabled={studio.teamModeEnabled}
teamWorkspaces={teamNav.items}
activeTeamWorkspaceId={teamNav.activeId}
teamLoading={teamNav.loading}
onTeamWorkspace={(id) => {
requestTeamWorkspace(id);
setChatSpace("team");
cloud.setActiveId(id);
setView("chat");
closeSidebarOnMobile();
}}
Expand Down Expand Up @@ -357,7 +375,7 @@ export function FranklinChat() {
</div>

{chatSpace === "team" && view === "chat" ? (
<CloudWorkspacePanel />
<CloudWorkspacePanel cloud={cloud} />
) : view === "agents" ? (
<AgentsPanel
agents={studio.agents}
Expand Down
Loading
Loading