Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
kill-rightbar (#1618)
Eric Hayes9795eca8ba2c
diff --git a/js/app/packages/app/component/GlobalHotkeys.tsx b/js/app/packages/app/component/GlobalHotkeys.tsxindex 1e9be7061f..6575602cc8 100644--- a/js/app/packages/app/component/GlobalHotkeys.tsx+++ b/js/app/packages/app/component/GlobalHotkeys.tsx@@ -2,7 +2,6 @@ import { useOpenInstructionsMd } from '@core/component/AI/util/instructions';import { useSettingsState } from '@core/constant/SettingsState';import { TOKENS } from '@core/hotkey/tokens';import type { ValidHotkey } from '@core/hotkey/types';-import { useBigChat } from '@core/signal/layout';import { AiInstructionsIcon } from '@queries/storage/instructions-md';import { registerHotkey } from 'core/hotkey/hotkeys';import { createMemo } from 'solid-js';@@ -22,8 +21,6 @@ import { CREATABLE_BLOCKS, setCreateMenuOpen } from './Launcher';import { useSplitLayout } from './split-layout/layout';export default function GlobalShortcuts() {- const [_, setBigChatOpen] = useBigChat();-const canFit = () => globalSplitManager()?.canAppendSplit() ?? true;const { toggleSettings } = useSettingsState();@@ -88,18 +85,6 @@ export default function GlobalShortcuts() {runWithInputFocused: true,});- registerHotkey({- hotkeyToken: TOKENS.global.toggleBigChat,- hotkey: 'cmd+j',- scopeId: 'global',- description: 'Toggle big chat',- keyDownHandler: () => {- setBigChatOpen((v) => !v);- return true;- },- runWithInputFocused: true,- });-const { openWithSplit } = useSplitLayout();const createNewSplit = () => {diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsxindex 9132a8ef64..e23e1c9d8d 100644--- a/js/app/packages/app/component/Layout.tsx+++ b/js/app/packages/app/component/Layout.tsx@@ -1,30 +1,29 @@+import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';import { mountGlobalFocusListener } from '@app/signal/focus';import { useIsAuthenticated } from '@core/auth';import { Resize } from '@core/component/Resize';import { usePaywallState } from '@core/constant/PaywallState';+import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';import {LAYOUT_CONTEXT_ID,setPersistedLayoutSizes,} from '@core/signal/layout';+import { updateCookie } from '@core/util/cookies';import { type RouteSectionProps, useLocation } from '@solidjs/router';+import { cn } from '@ui/utils/classname';import { attachGlobalDOMScope } from 'core/hotkey/hotkeys';import { createEffect, onMount, Show, Suspense } from 'solid-js';-import { updateCookie } from '@core/util/cookies';import Banner from './banner/Banner';import { GlobalBulkEditEntityModal } from './bulk-edit-entity/BulkEditEntityModal';import { CommandMenu } from './command';-import { PropertyEditorModal } from './property-edit-modal/PropertyEditorModal';import GlobalShortcuts from './GlobalHotkeys';import { ItemDndProvider } from './ItemDragAndDrop';import { createMenuOpen, Launcher, setCreateMenuOpen } from './Launcher';import { Paywall } from './paywall/Paywall';-import { RightbarWrapper } from './rightbar/Rightbar';+import { PropertyEditorModal } from './property-edit-modal/PropertyEditorModal';import { SettingsWrapper } from './settings/SettingsWrapper';import { ShortcutsHelper } from './settings/ShortcutsHelper';-import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';-import { cn } from '@ui/utils/classname';import { useAppSquishHandlers } from './useAppSquishHandlers';-import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';const AUTH_URLS = [`${ROUTER_BASE_CONCAT}login`,@@ -138,7 +137,6 @@ export function Layout(props: RouteSectionProps) {<Resize.Panel id={LAYOUT_CONTEXT_ID} minSize={250}>{props.children}</Resize.Panel>- <RightbarWrapper /><SettingsWrapper /></ItemDndProvider></Resize.Zone>diff --git a/js/app/packages/app/component/dock/Dock.tsx b/js/app/packages/app/component/dock/Dock.tsxindex 11801007ac..37a93efd53 100644--- a/js/app/packages/app/component/dock/Dock.tsx+++ b/js/app/packages/app/component/dock/Dock.tsx@@ -1,39 +1,32 @@-import { ENABLE_DOCK_NOTITIFCATIONS } from '@core/constant/featureFlags';-import { GlobalNotificationBell } from '@core/component/GlobalNotificationBell';-import { Show } from 'solid-js';-import { isRightPanelOpen, useToggleRightPanel } from '@core/signal/layout';-import { useSettingsState } from '@core/constant/SettingsState';-import { useGlobalNotificationSource } from '../GlobalAppState';-import MacroCreateIcon from '@macro-icons/macro-create-b.svg';-import { globalSplitManager } from '@app/signal/splitLayout';-import { ClippedPanel } from '@core/component/ClippedPanel';-import { withAnalytics } from '@coparse/analytics';-import SplitIcon from '@macro-icons/new-split.svg';-import IconAI from '@macro-icons/wide/star.svg';-import IconGear from '@macro-icons/macro-gear.svg';-import IconLogo from '@macro-icons/macro-logo.svg';-import { BasicTierLimit } from './BasicTierLimit';-import { Hotkey } from '@core/component/Hotkey';-import { setCreateMenuOpen } from '../Launcher';-import { useHasPaidAccess } from '@core/auth';-import { TOKENS } from '@core/hotkey/tokens';-import { Button } from '@ui/components/Button';-import { LabelAndHotKey } from '@core/component/Tooltip';-import { isMobile } from '@core/mobile/isMobile';-import { CommandState } from '../command';+import { globalSplitManager } from "@app/signal/splitLayout";+import { useHasPaidAccess } from "@core/auth";+import { ClippedPanel } from "@core/component/ClippedPanel";+import { GlobalNotificationBell } from "@core/component/GlobalNotificationBell";+import { Hotkey } from "@core/component/Hotkey";+import { LabelAndHotKey } from "@core/component/Tooltip";+import { ENABLE_DOCK_NOTITIFCATIONS } from "@core/constant/featureFlags";+import { useSettingsState } from "@core/constant/SettingsState";+import { TOKENS } from "@core/hotkey/tokens";+import { isMobile } from "@core/mobile/isMobile";+import MacroCreateIcon from "@macro-icons/macro-create-b.svg";+import IconGear from "@macro-icons/macro-gear.svg";+import IconLogo from "@macro-icons/macro-logo.svg";+import SplitIcon from "@macro-icons/new-split.svg";+import { Button } from "@ui/components/Button";+import { Show } from "solid-js";+import { CommandState } from "../command";+import { useGlobalNotificationSource } from "../GlobalAppState";+import { setCreateMenuOpen } from "../Launcher";+import { BasicTierLimit } from "./BasicTierLimit";export function Dock() {- const notificationSource = useGlobalNotificationSource();- const isRightPanelCollapsed = () => !isRightPanelOpen();- // const [debugOpen, setDebugOpen] = createSignal(false);- const { track, TrackingEvents } = withAnalytics();- const toggleRightPanel = useToggleRightPanel();- const { settingsOpen, toggleSettings } = useSettingsState();- const hasPaid = useHasPaidAccess();+ const notificationSource = useGlobalNotificationSource();+ const { settingsOpen, toggleSettings } = useSettingsState();+ const hasPaid = useHasPaidAccess();- return (- <>- <style>{`+ return (+ <>+ <style>{`.dock-button-hover{transition: var(--transition);background-color: #0000;@@ -46,59 +39,60 @@ export function Dock() {}`}</style>- <div- style={{- 'padding': '0 var(--gutter-size) var(--gutter-size) var(--gutter-size)',- 'height': 'calc(40px + var(--gutter-size))',- 'box-sizing': 'border-box',- 'width': '100vw'- }}- >- <ClippedPanel bl br>- <div style={{- 'grid-template-columns': 'min-content 1fr min-content',- 'box-sizing': 'border-box',- 'scrollbar-width': 'none',- 'align-content': 'center',- 'overflow-y': 'hidden',- 'padding': '0 7px',- 'display': 'grid',- 'height': '100%',- 'gap': '7px',- }}>-- <div- style={{- 'border-right': '1px solid var(--color-edge-muted)',- 'grid-auto-columns': 'min-content',- 'grid-auto-flow': 'column',- 'align-items': 'center',- 'padding-right': '7px',- 'display': 'grid',- 'gap': '7px'- }}- >- <div- style={{- 'grid-template-columns': 'min-content min-content',- 'box-sizing': 'border-box',- 'align-items': 'center',- 'padding': '0 4px',- 'display': 'grid',- 'height': '24px',- 'gap': '7px'- }}- onClick={CommandState.toggle}- class="dock-button-hover"- data-hotkey-token={TOKENS.global.commandMenu}- >- <IconLogo- style={{- 'display': 'block',- 'height': '9px'- }}- />- {/*<div style={{+ <div+ style={{+ padding: "0 var(--gutter-size) var(--gutter-size) var(--gutter-size)",+ height: "calc(40px + var(--gutter-size))",+ "box-sizing": "border-box",+ width: "100vw",+ }}+ >+ <ClippedPanel bl br>+ <div+ style={{+ "grid-template-columns": "min-content 1fr min-content",+ "box-sizing": "border-box",+ "scrollbar-width": "none",+ "align-content": "center",+ "overflow-y": "hidden",+ padding: "0 7px",+ display: "grid",+ height: "100%",+ gap: "7px",+ }}+ >+ <div+ style={{+ "border-right": "1px solid var(--color-edge-muted)",+ "grid-auto-columns": "min-content",+ "grid-auto-flow": "column",+ "align-items": "center",+ "padding-right": "7px",+ display: "grid",+ gap: "7px",+ }}+ >+ <div+ style={{+ "grid-template-columns": "min-content min-content",+ "box-sizing": "border-box",+ "align-items": "center",+ padding: "0 4px",+ display: "grid",+ height: "24px",+ gap: "7px",+ }}+ onClick={CommandState.toggle}+ class="dock-button-hover"+ data-hotkey-token={TOKENS.global.commandMenu}+ >+ <IconLogo+ style={{+ display: "block",+ height: "9px",+ }}+ />+ {/*<div style={{'font-family': 'monospace','background-color': '#f00','font-size': '10px',@@ -106,38 +100,42 @@ export function Dock() {}}><Hotkey token={TOKENS.global.createCommand}/></div>*/}- <div class="**:border-none! flex border border-edge-muted text-[0.625rem] rounded-xs items-center px-1.5 py-0.25">- <Hotkey shortcut="cmd+k" class="flex gap-1" />- </div>- </div>+ <div class="**:border-none! flex border border-edge-muted text-[0.625rem] rounded-xs items-center px-1.5 py-0.25">+ <Hotkey shortcut="cmd+k" class="flex gap-1" />+ </div>+ </div>- <div style={{- 'background-color': 'var(--color-edge-muted)',- 'height': '38px',- 'width': '1px',- }} />+ <div+ style={{+ "background-color": "var(--color-edge-muted)",+ height: "38px",+ width: "1px",+ }}+ />- <div- style={{- 'grid-template-columns': 'min-content min-content',- 'box-sizing': 'border-box',- 'align-items': 'center',- 'padding': '0 4px',- 'display': 'grid',- 'height': '24px',- 'gap': '10px'- }}- onClick={() => { setCreateMenuOpen(true) }}- class="dock-button-hover"- data-hotkey-token={TOKENS.global.createCommand}- >- <MacroCreateIcon- style={{- 'display': 'block',- 'height': '9px'- }}- />- {/*<div style={{+ <div+ style={{+ "grid-template-columns": "min-content min-content",+ "box-sizing": "border-box",+ "align-items": "center",+ padding: "0 4px",+ display: "grid",+ height: "24px",+ gap: "10px",+ }}+ onClick={() => {+ setCreateMenuOpen(true);+ }}+ class="dock-button-hover"+ data-hotkey-token={TOKENS.global.createCommand}+ >+ <MacroCreateIcon+ style={{+ display: "block",+ height: "9px",+ }}+ />+ {/*<div style={{'background-color': '#f00','font-family': 'monospace','font-size': '10px',@@ -145,108 +143,108 @@ export function Dock() {}}><Hotkey token={TOKENS.global.commandMenu}/></div>*/}- <div class="**:border-none! flex border border-edge-muted text-[0.625rem] rounded-xs items-center px-1.5 py-0.25">- <Hotkey shortcut="c" />- </div>- </div>- </div>-- <Show- when={!isMobile()}- fallback={<div></div>}- >- <div style={{- 'border-top': '1px solid var(--edge-muted)',- 'color': 'var(--ink-extra-muted)',- 'justify-content': 'center',- 'font-family': 'monospace',- 'align-items': 'center',- 'font-size': '0.75rem',- 'line-height': '1rem',- 'display': 'flex',- 'gap': '4px',- }}>- <Show when={!hasPaid()}>- <BasicTierLimit />- </Show>+ <div class="**:border-none! flex border border-edge-muted text-[0.625rem] rounded-xs items-center px-1.5 py-0.25">+ <Hotkey shortcut="c" />+ </div>+ </div>+ </div>- <div class="w-full"/>+ <Show when={!isMobile()} fallback={<div></div>}>+ <div+ style={{+ "border-top": "1px solid var(--edge-muted)",+ color: "var(--ink-extra-muted)",+ "justify-content": "center",+ "font-family": "monospace",+ "align-items": "center",+ "font-size": "0.75rem",+ "line-height": "1rem",+ display: "flex",+ gap: "4px",+ }}+ >+ <Show when={!hasPaid()}>+ <BasicTierLimit />+ </Show>- <Show when={ENABLE_DOCK_NOTITIFCATIONS}>- <GlobalNotificationBell notificationSource={notificationSource} />- </Show>- </div>- </Show>+ <div class="w-full" />- <div style={{- 'border-left': '1px solid var(--color-edge-muted)',- 'grid-auto-columns': 'min-content',- 'grid-auto-flow': 'column',- 'align-items': 'center',- 'padding-left': '7px',- 'display': 'grid',- 'height': '38px',- 'gap': '4px'- }}>- <Button- onClick={() => {- if (isRightPanelCollapsed()) { track(TrackingEvents.RIGHTBAR.OPEN) }- else { track(TrackingEvents.RIGHTBAR.CLOSE) }- toggleRightPanel();- }}- class="p-1 size-6"- classList={{- "bg-accent/20 text-accent": !isRightPanelCollapsed(),- }}- tooltip={- <LabelAndHotKey label='Toggle AI Panel' hotkeyToken={TOKENS.split.go.toggleRightPanel} />- }- >- <IconAI />- </Button>+ <Show when={ENABLE_DOCK_NOTITIFCATIONS}>+ <GlobalNotificationBell+ notificationSource={notificationSource}+ />+ </Show>+ </div>+ </Show>- <div class="mobile-width:hidden">- <Button- tooltip={<LabelAndHotKey label='Create New Split' hotkeyToken={TOKENS.global.createNewSplit} />}- onClick={() => {- const manager = globalSplitManager();- if (manager) {- const canFit = manager.resizeContext()?.canFit({ minSize: 400 }) ?? true;- if (canFit) {- manager.createNewSplit({- content: {- id: 'unified-list',- type: 'component',- },- referredFrom: 'dock'- });- }- }- }}- class="p-1"- >- <SplitIcon class="h-4"/>- </Button>- </div>+ <div+ style={{+ "border-left": "1px solid var(--color-edge-muted)",+ "grid-auto-columns": "min-content",+ "grid-auto-flow": "column",+ "align-items": "center",+ "padding-left": "7px",+ display: "grid",+ height: "38px",+ gap: "4px",+ }}+ >+ <div class="mobile-width:hidden">+ <Button+ tooltip={+ <LabelAndHotKey+ label="Create New Split"+ hotkeyToken={TOKENS.global.createNewSplit}+ />+ }+ onClick={() => {+ const manager = globalSplitManager();+ if (manager) {+ const canFit =+ manager.resizeContext()?.canFit({ minSize: 400 }) ??+ true;+ if (canFit) {+ manager.createNewSplit({+ content: {+ id: "unified-list",+ type: "component",+ },+ referredFrom: "dock",+ });+ }+ }+ }}+ class="p-1"+ >+ <SplitIcon class="h-4" />+ </Button>+ </div>- <Button- tooltip={<LabelAndHotKey label={settingsOpen() ? 'Close Settings' : 'Open Settings'} hotkeyToken={TOKENS.global.toggleSettings} />}- onClick={() => { toggleSettings() }}- class="p-1 size-6"- classList={{- "bg-accent/20 text-accent": settingsOpen(),- }}- >- <IconGear />- </Button>- </div>- </div>- </ClippedPanel>- </div>+ <Button+ tooltip={+ <LabelAndHotKey+ label={settingsOpen() ? "Close Settings" : "Open Settings"}+ hotkeyToken={TOKENS.global.toggleSettings}+ />+ }+ onClick={() => {+ toggleSettings();+ }}+ class="p-1 size-6"+ classList={{+ "bg-accent/20 text-accent": settingsOpen(),+ }}+ >+ <IconGear />+ </Button>+ </div>+ </div>+ </ClippedPanel>+ </div>- {/*<Show when={DEV_MODE_ENV}>+ {/*<Show when={DEV_MODE_ENV}><Debug/></Show>*/}- </>- );+ </>+ );}diff --git a/js/app/packages/app/component/rightbar/Rightbar.tsx b/js/app/packages/app/component/rightbar/Rightbar.tsxdeleted file mode 100644index 9541d5263d..0000000000--- a/js/app/packages/app/component/rightbar/Rightbar.tsx+++ /dev/null@@ -1,785 +0,0 @@-import { globalSplitManager } from '@app/signal/splitLayout';-import { useIsAuthenticated } from '@core/auth';-import { AiChatEmptyState } from '@core/component/AI/component/AIChatEmptyState';-import { DragDropWrapper } from '@core/component/AI/component/DragDrop';-import type { ChatSendInput } from '@core/component/AI/component/input/buildRequest';-import { useSendChatMessage } from '@core/component/AI/component/input/buildRequest';-import { useChatMarkdownArea } from '@core/component/AI/component/input/useChatMarkdownArea';-import { ChatMessages } from '@core/component/AI/component/message/ChatMessages';-import {- ChatInputProvider,- ChatProvider,- useChatContext,- useChatInputContext,-} from '@core/component/AI/context';-import { useEntityDropAttachment } from '@core/component/AI/hook/useEntityDropAttachment';-import { getPendingSend } from '@core/component/AI/signal/pendingSend';-import { registerToolHandler } from '@core/component/AI/signal/tool';-import type {- Attachment,- ChatMessageWithAttachments,- Model,-} from '@core/component/AI/types';-import { parseModel } from '@core/component/AI/util';-import {- getChatInputStoredState,- storeChatState,-} from '@core/component/AI/util/storage';-import { CustomScrollbar } from '@core/component/CustomScrollbar';-import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';-import { Hotkey } from '@core/component/Hotkey';-import { DropdownMenuContent, MenuItem } from '@core/component/Menu';-import { ReferencesModal } from '@core/component/ReferencesModal';-import { Resize } from '@core/component/Resize';-import type { Permissions } from '@core/component/SharePermissions';-import { getPermissions } from '@core/component/SharePermissions';-import { ShareButton } from '@core/component/TopBar/ShareButton';-import { ENABLE_REFERENCES_MODAL } from '@core/constant/featureFlags';-import { usePaywallState } from '@core/constant/PaywallState';-import { settingsOpen } from '@core/constant/SettingsState';-import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';-import { TOKENS } from '@core/hotkey/tokens';-import {- isRightPanelOpen,- useBigChat,- useToggleRightPanel,-} from '@core/signal/layout';-import { rightbarChatId, setRightbarChatId } from '@core/signal/rightbar';-import { isErr } from '@core/util/maybeResult';-import ContractIcon from '@icon/regular/arrows-in.svg';-import ExpandIcon from '@icon/regular/arrows-out.svg';-import ChatIcon from '@icon/regular/chat.svg';-import HistoryIcon from '@icon/regular/clock-counter-clockwise.svg';-import NotepadIcon from '@icon/regular/notepad.svg';-import PlusIcon from '@icon/regular/plus.svg';-import XIcon from '@icon/regular/x.svg';-import { DropdownMenu } from '@kobalte/core/dropdown-menu';-import { invalidateUserQuota } from '@queries/auth';-import { refetchHistory, useHistoryQuery } from '@queries/history/history';-import { cognitionApiServiceClient } from '@service-cognition/client';-import { AccessLevel } from '@service-cognition/generated/schemas/accessLevel';-import { connectionGatewayClient } from '@service-connection/client';-import type { ChatMessageStream } from '@service-connection/stream';-import { state as connectionState } from '@service-connection/websocket';-import { Button } from '@ui/components/Button';-import { WebsocketConnectionState } from '@websocket';-import { ChatInput } from 'core/component/AI/component/input/ChatInput';-import { useOpenInstructionsMd } from 'core/component/AI/util/instructions';-import type { LexicalEditor } from 'lexical';-import {- type Accessor,- createEffect,- createMemo,- createSignal,- For,- type JSXElement,- on,- onCleanup,- type Setter,- Show,- Suspense,- untrack,-} from 'solid-js';-import { SplitlikeContainer } from '../split-layout/components/SplitContainer';--type ChatData = {- messages: ChatMessageWithAttachments[];- name: string | undefined;- model: Model | undefined;- attachments: Attachment[];- userAccessLevel?: AccessLevel;-};--const getChatData = async (chatId: string): Promise<ChatData> => {- if (!chatId)- return { messages: [], name: undefined, model: undefined, attachments: [] };-- const res = await cognitionApiServiceClient.getChat({ chat_id: chatId });- // TODO: show error state- if (isErr(res, 'UNAUTHORIZED')) {- throw new Error('Unauthorized to fetch chat');- }- if (isErr(res)) {- throw new Error('Failed to fetch chat');- }-- const [, chat] = res;- const messages = chat.chat.messages;- const name = chat.chat.name;-- let model: Model | undefined;- let attachments: Attachment[] = [];-- const { model: localModel, attachments: localAttachments } =- getChatInputStoredState(chatId);-- model = localModel ?? parseModel(chat.chat.model);-- attachments =- localAttachments ??- new Map(chat.chat.attachments.map((a) => [a.attachmentId, a]))- .values()- .toArray();-- return {- messages,- name,- model,- attachments,- userAccessLevel: chat.userAccessLevel as AccessLevel,- };-};--const usePersistentChats = () => {- const historyQuery = useHistoryQuery();- return createMemo(() =>- (historyQuery.data ?? []).filter(- (item) => item.type === 'chat' && item.isPersistent- )- );-};--const PersistentChatList = (props: { onSelect: (chatId: string) => void }) => {- const persistentChats = usePersistentChats();- return (- <DropdownMenuContent class="z-modal w-60 h-120 overflow-y-auto">- <For each={persistentChats()}>- {(chat) => (- <MenuItem- text={chat.name}- icon={ChatIcon}- onClick={() => props.onSelect(chat.id)}- />- )}- </For>- </DropdownMenuContent>- );-};--// Trigger button component for the persistent chat list-export const PersistentChatHistoryButton = (props: {- setChatId: (chatId: string | undefined) => void;-}) => {- const [showMenu, setShowMenu] = createSignal(false);-- const onSelect = (chatId: string) => {- props.setChatId(chatId);- setShowMenu(false);- };-- return (- <DropdownMenu open={showMenu()} onOpenChange={setShowMenu}>- <DropdownMenu.Trigger>- <DeprecatedIconButton- size="sm"- icon={HistoryIcon}- theme="current"- tooltip={{ label: 'Toggle recent threads' }}- onDeepClick={() => setShowMenu((prev) => !prev)}- />- </DropdownMenu.Trigger>-- <DropdownMenu.Portal>- <PersistentChatList onSelect={onSelect} />- </DropdownMenu.Portal>- </DropdownMenu>- );-};--function TopBar(props: {- chatId: string | undefined;- setChatId: (chatId: string | undefined) => void;- chatName?: string;- userPermissions: Accessor<Permissions>;-}) {- const createNewRightbarChat = () => {- props.setChatId(undefined);- };- const openInstructions = useOpenInstructionsMd();- const [bigChatOpen, setBigChatOpen] = useBigChat();- const toggleRightPanel = useToggleRightPanel();-- return (- <div- class="h-10 border-b border-edge-muted flex items-center w-full px-2 shrink-0 grow-0"- data-split-panel- >- <Button- tooltip="Close Assistant Panel"- class="p-1 size-6"- onClick={() => {- if (bigChatOpen()) {- setBigChatOpen(false);- } else {- toggleRightPanel();- }- }}- >- <XIcon />- </Button>- <Button- tooltip={- <div class="flex flex-row gap-x-1">- <div>Create New Chat</div>- <div class="flex border border-edge-muted text-[0.625rem] rounded-xs items-center px-1.5 py-0.25 font-normal">- <Hotkey shortcut="ctrl+t" />- </div>- </div>- }- class="p-1 size-6"- onClick={createNewRightbarChat}- >- <PlusIcon />- </Button>- <div class="grow" />- <div class="flex items-center gap-1">- <Show when={ENABLE_REFERENCES_MODAL && props.chatId}>- <ReferencesModal- documentId={props.chatId!}- documentName={props.chatName ?? 'New Chat'}- entityType="chat"- />- </Show>- <Show when={props.chatId}>- <ShareButton- id={props.chatId!}- name={props.chatName ?? 'New Chat'}- userPermissions={props.userPermissions()}- itemType="chat"- />- </Show>- <DeprecatedIconButton- size="sm"- icon={NotepadIcon}- tooltip={{ label: 'Edit AI Instructions' }}- theme="current"- onClick={() => {- openInstructions();- }}- />- <PersistentChatHistoryButton setChatId={props.setChatId} />- <DeprecatedIconButton- size="sm"- icon={bigChatOpen() ? ContractIcon : ExpandIcon}- tooltip={{- label: bigChatOpen()- ? 'Minimize Assistant Panel'- : 'Spotlight Assistant Panel',- hotkeyToken: TOKENS.global.toggleBigChat,- }}- theme="current"- onClick={() => {- setBigChatOpen((v) => !v);- }}- />- </div>- </div>- );-}--/** Renders messages + stream effects. Only mounted inside ChatProvider. */-function RightbarChatArea(props: { isBig?: boolean }) {- const chat = useChatContext();- const input = useChatInputContext();- const [messagesContainerRef, setMessagesContainerRef] =- createSignal<HTMLElement>();-- createEffect(() => {- const stream_ = chat.stream();- if (stream_ && stream_.data().length > 0) {- invalidateUserQuota();- }- });-- createEffect(() => {- const stream_ = chat.stream();- if (!stream_ || stream_.isDone()) {- input.setIsGenerating(false);- if (stream_?.isDone()) {- invalidateUserQuota();- }- return;- } else {- input.setIsGenerating(true);- }- });-- registerToolHandler(() => {- const s = chat.stream();- if (!s) return undefined;- return { data: s.data };- });-- return (- <>- <Show when={chat.messages().length === 0}>- <div class="h-full flex flex-col items-center justify-center">- <AiChatEmptyState />- </div>- </Show>- <Show when={chat.messages().length > 0 || !props.isBig}>- <div class="relative flex-1 min-h-0 w-full">- <div- data-chat-scroll- class="size-full overflow-y-auto overflow-x-hidden scroll-smooth flex justify-center scrollbar-hidden"- ref={setMessagesContainerRef}- >- <div class="w-full macro-message-width macro-message-padding">- <ChatMessages messageActions={undefined} />- </div>- </div>- <CustomScrollbar scrollContainer={messagesContainerRef} />- </div>- </Show>- </>- );-}--export function Rightbar(props: {- chatId: string | undefined;- onSend: (args: ChatSendInput) => void;- chatName: string | undefined;- isBig?: boolean;- userPermissions: Accessor<Permissions>;- onUnmount?: () => void;- initialState?: {- model: Model | undefined;- attachments: Attachment[];- text: string | undefined;- };- setState: {- setChatId: (chatId: string | undefined) => void;- setModel: Setter<Model | undefined>;- setAttachments: Setter<Attachment[]>;- setText: Setter<string | undefined>;- };- children?: JSXElement;-}) {- const input = useChatInputContext();-- // NOTE: due to mount race condition in the markdown area, we need to set the initial value here- const chatMarkdownArea = useChatMarkdownArea({- initialValue: props.initialState?.text,- addAttachment: (a) => input.attachments.addAttachment(a),- });-- // Entity drag-and-drop support- const { droppable, isDraggingOver } = useEntityDropAttachment(- 'rightbar-chat-input',- input.attachments- );- false && droppable;-- createEffect(() => {- if (!props.initialState) return;- input.setModel(props.initialState.model);- input.attachments.setAttached(props.initialState.attachments);- });-- onCleanup(() => {- props.onUnmount?.();- });-- createEffect(() => {- const inputText = chatMarkdownArea.markdownText();- const attached = input.attachments.attached();- const model_ = input.model();- props.setState.setText(inputText);- props.setState.setAttachments(attached);- props.setState.setModel(model_);- });-- const [editor, setEditor] = createSignal<LexicalEditor>();- let borrowedFocus: Element | null = null;- const returnFocus = () => {- if (- borrowedFocus &&- borrowedFocus.isConnected &&- borrowedFocus instanceof HTMLElement- ) {- borrowedFocus.focus();- } else {- globalSplitManager()?.returnFocus();- }- };-- // Defering these effects so that they don't trigger on first load- createEffect(- on(- () => props.isBig,- (isBig) => {- if (isBig) {- borrowedFocus = document.activeElement;- editor()?.focus();- } else {- if (untrack(isRightPanelOpen)) {- return;- } else {- returnFocus();- }- }- },- { defer: true }- )- );-- createEffect(- on(- isRightPanelOpen,- (isOpen) => {- if (isOpen) {- borrowedFocus = document.activeElement;- editor()?.focus();- } else {- returnFocus();- }- },- { defer: true }- )- );-- return (- <DragDropWrapper- class="relative flex flex-col size-full select-none"- isEntityDraggingOver={isDraggingOver}- >- <div class="overflow-hidden size-full flex flex-col items-center relative">- <div class="absolute inset-0 pointer-events-none" use:droppable />- <TopBar- chatId={props.chatId}- setChatId={props.setState.setChatId}- chatName={props.chatName}- userPermissions={props.userPermissions}- />- <div class="flex flex-col flex-1 min-h-0 p-2 w-full items-center">- {props.children}-- <div class="w-full">- <div class="flex-shrink-0 pt-2 macro-message-width macro-message-padding mx-auto">- <ChatInput- markdown={chatMarkdownArea}- chatId={props.chatId}- isPersistent- showActiveTabs- onSend={props.onSend}- captureEditor={setEditor}- />- </div>- </div>- </div>- </div>- </DragDropWrapper>- );-}--/** Owns rightbar chat state to prevent data loss on panel close */-export const RightbarWrapper = (_props: { isBigChat?: boolean }) => {- const [bigChatOpen, setBigChatOpen] = useBigChat();- const isAuthenticated = useIsAuthenticated();- const [text, setText] = createSignal<string>();- const [chatName, setChatName] = createSignal<string | undefined>();- const [chatId, setChatId] = [rightbarChatId, setRightbarChatId];- const [newChatId, setNewChatId] = createSignal<string | undefined>();- const [messages, setMessages] = createSignal<ChatMessageWithAttachments[]>(- []- );- const [userAccessLevel, setUserAccessLevel] = createSignal<- AccessLevel | undefined- >();- const [model, setModel] = createSignal<Model | undefined>();- const [attachments, setAttachments] = createSignal<Attachment[]>([]);- const [stream, setStream] = createSignal<ChatMessageStream>();- const [waitingForStream, setWaitingForStream] = createSignal(false);- const [initialChatState, setInitialChatState] = createSignal<- | {- model: Model | undefined;- attachments: Attachment[];- text: string | undefined;- }- | undefined- >();- const userPermissions = createMemo(() => getPermissions(userAccessLevel()));-- const [attachHotkeys, scopeId] = useHotkeyDOMScope('ai-chat');-- const clearChatState = () => {- const attached = attachments();- setStream(undefined);- setModel(undefined);- setAttachments(attached);- setText(undefined);- setMessages([]);- setUserAccessLevel(undefined);- setInitialChatState({- model: undefined,- attachments: attached,- text: undefined,- });- };-- // reads from inner component state and saves to this component so we can quickly restore on panel open- const getChatInputState = () => {- const state = {- model: model(),- attachments: attachments(),- text: text(),- };- setInitialChatState(state);- };-- // saves to local storage- const saveChatState = () => {- const chatId_ = chatId();- if (!chatId_) return;- storeChatState(chatId_, {- attachments: attachments(),- model: model(),- });- };-- createEffect(- on([chatId, attachments, model], () => {- saveChatState();- })- );- onCleanup(() => {- saveChatState();- });-- const { showPaywall } = usePaywallState();- const sendChatMessage = useSendChatMessage();-- const onSend = async (request: ChatSendInput) => {- setMessages((p) => [- ...p,- {- id: crypto.randomUUID(),- content: request.content,- role: 'user' as const,- attachments: request.attachments ?? [],- },- ]);- setWaitingForStream(true);-- const result = await sendChatMessage({- ...request,- chatId: chatId(),- });-- setWaitingForStream(false);-- if ('error' in result) {- if (result.paymentError) {- showPaywall();- }- return;- }-- // If no chatId existed, a new chat was created- if (!chatId()) {- setNewChatId(result.chat_id);- setChatId(result.chat_id);- setUserAccessLevel(AccessLevel.owner);- refetchHistory();- }-- setStream(result.stream);- invalidateUserQuota();- };-- // Check for pending sends from SoupChatInput when bigchat opens- createEffect(- on(bigChatOpen, async (isOpen, wasOpen) => {- if (isOpen && !wasOpen) {- const pending = getPendingSend();- if (pending) {- onSend({- content: pending.content,- model: pending.model ?? model() ?? 'claude-haiku-4-5-20251001',- attachments: pending.attachments ?? [],- toolset: { type: 'all' },- });- }- }- })- );-- // load chat state- createEffect(- on(chatId, (chatId_) => {- // empty chat- // moving from no chat to some chat- if (!chatId_) {- clearChatState();- return;- }-- // created a new server chat so we should keep the existing state around- if (chatId_ === newChatId()) {- setInitialChatState({- model: model(),- attachments: attachments(),- text: text(),- });- setNewChatId(undefined);- return;- }-- // load existing server chat- clearChatState();- getChatData(chatId_)- .then(({ messages, name, model, attachments, userAccessLevel }) => {- setChatName(name);- setMessages(messages);- setModel(model);- setAttachments(attachments);- setUserAccessLevel(userAccessLevel);- setInitialChatState({- model,- attachments,- text: undefined,- });- })- .catch((e) => {- console.error('Failed to load chat messages', e);- // TODO: show error state- });- })- );-- // Track/untrack chat entity with connection gateway for stream delivery- createEffect(() => {- const id = chatId();- const connected = connectionState() === WebsocketConnectionState.Open;- if (id && connected) {- connectionGatewayClient.trackEntity({- entity_type: 'chat',- entity_id: id,- action: 'open',- });- }- onCleanup(() => {- if (id) {- connectionGatewayClient.trackEntity({- entity_type: 'chat',- entity_id: id,- action: 'close',- });- }- });- });-- const toggleRightPanel = useToggleRightPanel();-- registerHotkey({- scopeId,- hotkey: 'escape',- hotkeyToken: TOKENS.chat.spotlight.close,- condition: () => Boolean(bigChatOpen() || isRightPanelOpen()),- description: 'Close chat',- runWithInputFocused: true,- keyDownHandler: () => {- if (bigChatOpen()) {- setBigChatOpen(false);- } else {- toggleRightPanel(false);- }- return true;- },- });-- registerHotkey({- scopeId,- hotkey: 'ctrl+t',- hotkeyToken: TOKENS.chat.new,- description: 'Create a new chat',- runWithInputFocused: true,- keyDownHandler: () => {- setChatId(undefined);- return true;- },- });-- registerHotkey({- scopeId,- hotkey: 'ctrl+c',- description: 'Stop stream',- keyDownHandler: () => {- // TODO: implement stop for connection gateway streams- return true;- },- runWithInputFocused: true,- });- return (- <Show when={isAuthenticated()}>- <Resize.Panel- id="sidebar-chat"- minSize={440}- maxSize={800}- hidden={() => !isRightPanelOpen()}- persistent={true}- >- <div- class="size-full invisible"- classList={{- visible: isRightPanelOpen() || bigChatOpen(),- }}- ref={(r) => {- attachHotkeys(r);- }}- >- <SplitlikeContainer- spotlight={bigChatOpen}- setSpotlight={setBigChatOpen}- tr={!bigChatOpen() && !settingsOpen()}- >- <Suspense>- <ChatInputProvider>- <Rightbar- chatId={chatId()}- chatName={chatName()}- onUnmount={getChatInputState}- initialState={initialChatState()}- onSend={onSend}- userPermissions={userPermissions}- setState={{- setChatId,- setModel,- setAttachments,- setText,- }}- isBig={bigChatOpen()}- >- <Show- when={chatId()}- fallback={- <div class="h-full flex flex-col items-center justify-center">- <AiChatEmptyState />- </div>- }- >- {(id) => (- <ChatProvider- chatId={id()}- external={{- messages: [messages, setMessages],- stream: [stream, setStream],- waitingForStream: [- waitingForStream,- setWaitingForStream,- ],- }}- >- <RightbarChatArea isBig={bigChatOpen()} />- </ChatProvider>- )}- </Show>- </Rightbar>- </ChatInputProvider>- </Suspense>- </SplitlikeContainer>- </div>- </Resize.Panel>- </Show>- );-};diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.tsindex ef542018b0..d2c550c458 100644--- a/js/app/packages/app/component/split-layout/layoutManager.ts+++ b/js/app/packages/app/component/split-layout/layoutManager.ts@@ -10,7 +10,7 @@ import type {BlockInstanceHandle,BlockOrchestrator,} from '@core/orchestrator';-import { isRightPanelOpen, isSettingsPanelOpen } from '@core/signal/layout';+import { isSettingsPanelOpen } from '@core/signal/layout';import {type Accessor,createMemo,@@ -503,7 +503,9 @@ export function createSplitLayout(const listeners = contentChangeListeners.get(split.id);if (listeners) {- listeners.forEach((listener) => listener(payload));+ listeners.forEach((listener) => {+ listener(payload);+ });}}@@ -631,7 +633,7 @@ export function createSplitLayout(};function activateSplit(id: SplitId) {- let current = state.activeSplitId;+ const current = state.activeSplitId;setState('lastActiveSplitId', current);if (state.spotlightId && state.spotlightId !== id) {setState('spotlightId', undefined);@@ -640,11 +642,7 @@ export function createSplitLayout(}function spotlightSplit(id: SplitId) {- if (- state.splits.length <= 1 &&- !isSettingsPanelOpen() &&- !isRightPanelOpen()- ) {+ if (state.splits.length <= 1 && !isSettingsPanelOpen()) {return;}const split = state.splits.find((s) => s.id === id);@@ -831,10 +829,10 @@ export function createSplitLayout(}function reconcileSplits(newSplits: SplitContent[]) {- let newState: SplitState[] = [];+ const newState: SplitState[] = [];const currentCompositeSplits = state.splits.map(keyOfSplitState);const newCompositeSplits = newSplits.map(keyOfSplitContent);- let changed =+ const changed =newCompositeSplits.join(',') !== currentCompositeSplits.join(',');if (!changed) return;diff --git a/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts b/js/app/packages/app/component/split-layout/registerSplitHotkeys.tsindex e589671844..3e0efab684 100644--- a/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts+++ b/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts@@ -1,9 +1,4 @@import { TOKENS } from '@core/hotkey/tokens';-import {- isRightPanelOpen,- useBigChat,- useToggleRightPanel,-} from '@core/signal/layout';import { registerHotkey } from 'core/hotkey/hotkeys';import { globalSplitManager } from '../../signal/splitLayout';import { fireMacroJump } from '../MacroJump';@@ -106,25 +101,6 @@ export function registerSplitHotkeys(args: {runWithInputFocused: true,});- // AI side panel - legacy binding.- const [bigChatOpen] = useBigChat();- const toggleRightPanel = useToggleRightPanel();- registerHotkey({- hotkeyToken: TOKENS.split.go.toggleRightPanel,- hotkey: 'cmd+/',- scopeId: splitHotkeyScope,- description: () => {- return isRightPanelOpen() ? 'Close AI panel' : 'Open AI panel';- },- keyDownHandler: () => {- // Always allow closing. Only allow opening when big chat is not open.- toggleRightPanel(!isRightPanelOpen());- return true;- },- condition: () => !bigChatOpen() || isRightPanelOpen(),- runWithInputFocused: true,- });-// Macro Jump - legacy binding.registerHotkey({hotkeyToken: TOKENS.split.go.macroJump,diff --git a/js/app/packages/app/component/split-layout/utils/canSpotlight.ts b/js/app/packages/app/component/split-layout/utils/canSpotlight.tsindex 6a80ec2f1b..f4221549cf 100644--- a/js/app/packages/app/component/split-layout/utils/canSpotlight.ts+++ b/js/app/packages/app/component/split-layout/utils/canSpotlight.ts@@ -1,10 +1,6 @@-import { isRightPanelOpen, isSettingsPanelOpen } from '@core/signal/layout';+import { isSettingsPanelOpen } from '@core/signal/layout';import type { SplitManager } from '../layoutManager';export function canSpotlight(splitManager: SplitManager) {- return (- splitManager.splits().length > 1 ||- isSettingsPanelOpen() ||- isRightPanelOpen()- );+ return splitManager.splits().length > 1 || isSettingsPanelOpen();}diff --git a/js/app/packages/block-chat/client.ts b/js/app/packages/block-chat/client.tsindex c0f839491a..224be4a175 100644--- a/js/app/packages/block-chat/client.ts+++ b/js/app/packages/block-chat/client.ts@@ -1,20 +1,16 @@import { withAnalytics } from '@coparse/analytics';import type { BlockName } from '@core/block';import { usePaywallState } from '@core/constant/PaywallState';-import { isRightPanelOpen, useToggleRightPanel } from '@core/signal/layout';-import { setRightbarChatId } from '@core/signal/rightbar';import { isPaymentError } from '@core/util/handlePaymentError';import { isErr } from '@core/util/maybeResult';import { propsToHref } from '@core/util/url';-import { cognitionApiServiceClient } from '@service-cognition/client';import { postNewHistoryItem } from '@queries/history/history';+import { cognitionApiServiceClient } from '@service-cognition/client';const { track, TrackingEvents } = withAnalytics();export function useOpenChatForAttachment() {const { showPaywall } = usePaywallState();- const isRightPanelCollapsed = () => !isRightPanelOpen();- const toggleRightPanel = useToggleRightPanel();return async function openChatForAttachment(args: {attachmentId: string;@@ -76,12 +72,6 @@ export function useOpenChatForAttachment() {const [, data] = res;recent_id = data?.id;}-- setRightbarChatId(recent_id);-- if (isRightPanelCollapsed()) {- toggleRightPanel?.();- }};}diff --git a/js/app/packages/core/component/GeneralizedPopup/AskAI.tsx b/js/app/packages/core/component/GeneralizedPopup/AskAI.tsxindex 4001837e54..c961148a0a 100644--- a/js/app/packages/core/component/GeneralizedPopup/AskAI.tsx+++ b/js/app/packages/core/component/GeneralizedPopup/AskAI.tsx@@ -8,7 +8,6 @@// import { withAnalytics } from "@coparse/analytics";// import type { BlockName } from "@core/block";// import { type Completion, streamCompletion } from "@core/client/completion";-// import { rightbarChatId } from "@core/signal/rightbar";// import { DropdownMenu } from "@kobalte/core/dropdown-menu";// import BulletPointsIcon from "@phosphor-icons/core/regular/list-bullets.svg?component-solid";// import PencilIcon from "@phosphor-icons/core/regular/pencil.svg?component-solid";@@ -163,7 +162,6 @@// }) {// const blockOrchestrator = useGlobalBlockOrchestrator();// const [preferences, setPreferences] = useAskAiPreferences(props.blockName);-// const getChatId = () => rightbarChatId();// const BlockAllowedPrompts = Object.keys(PromptTypeDisplay).filter(// (_key: string) => {diff --git a/js/app/packages/core/signal/layout/bigChat.ts b/js/app/packages/core/signal/layout/bigChat.tsdeleted file mode 100644index 81405a1609..0000000000--- a/js/app/packages/core/signal/layout/bigChat.ts+++ /dev/null@@ -1,15 +0,0 @@-import { useSearchParams } from '@solidjs/router';-import type { Accessor, Setter } from 'solid-js';--function useQueryBool(param: string): [Accessor<boolean>, Setter<boolean>] {- const [searchParams, setSearchParams] = useSearchParams();- const value = () => Boolean(searchParams[param]);- const setValue: Setter<boolean> = (next) => {- const current = value();- const resolved = typeof next === 'function' ? next(current) : next;- setSearchParams({ [param]: resolved || undefined });- };- return [value, setValue] as const;-}--export const useBigChat = () => useQueryBool('chat');diff --git a/js/app/packages/core/signal/layout/index.ts b/js/app/packages/core/signal/layout/index.tsindex 504a051047..2daaf8e265 100644--- a/js/app/packages/core/signal/layout/index.ts+++ b/js/app/packages/core/signal/layout/index.ts@@ -1,8 +1,6 @@import type { ContextValue } from '@corvu/resizable';import { createSignal } from 'solid-js';-export * from './bigChat';-export * from './rightbar';export * from './settings';export const LAYOUT_CONTEXT_ID = 'layout';diff --git a/js/app/packages/core/signal/layout/rightbar.ts b/js/app/packages/core/signal/layout/rightbar.tsdeleted file mode 100644index 42df92ea12..0000000000--- a/js/app/packages/core/signal/layout/rightbar.ts+++ /dev/null@@ -1,30 +0,0 @@-import { createCallback } from '@solid-primitives/rootless';-import { createSignal } from 'solid-js';--const DEFAULT_RIGHT_PANEL_SIZE = 600;--export const [storedRightPanelSize, setStoredRightPanelSize] = createSignal(- DEFAULT_RIGHT_PANEL_SIZE-);--// Simple boolean signal for right panel collapsed state-// Default to collapsed (true)-export const [isRightPanelOpen, setIsRightPanelOpen] = createSignal(false);--// default to closed right bar-// NOTE: this is no longer persisted to local storage-export const [persistedLayoutSizes, setPersistedLayoutSizes] = createSignal<- [number, number]->([1, 0]);--// Legacy exports for backward compatibility (unused)-export const setResizableContext = () => {};--export function useToggleRightPanel() {- return createCallback((next?: boolean) => {- setIsRightPanelOpen((prev) => {- if (next !== undefined) return next;- return !prev;- });- });-}diff --git a/js/app/packages/core/signal/rightbar.ts b/js/app/packages/core/signal/rightbar.tsdeleted file mode 100644index 8c4869f8dd..0000000000--- a/js/app/packages/core/signal/rightbar.ts+++ /dev/null@@ -1,10 +0,0 @@-import { makePersisted } from '@solid-primitives/storage';-import { createSignal } from 'solid-js';--export const [rightbarChatId, setRightbarChatId] = makePersisted(- createSignal<string | undefined>(undefined),- {- name: 'rightbarChatId',- storage: sessionStorage,- }-);