- switch email and automation screens from WorkspaceLayout to WorkspaceView + useWorkspacesState - add promptPrefix prop to WorkspaceView, thread into WorkspaceContext - automation dynamically adds/removes chat panel while preserving persisted sizes - use displayText for session title so prompt prefix doesn't leak into titles - fix email context filter to match screens/email workspace key Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { useMemo, useCallback } from 'react';
|
|
import type { LayoutNode, PanelComponents } from 'officerdev';
|
|
import { WorkspaceView } from 'officerdev';
|
|
import { useWorkspacesState } from 'state/useWorkspacesState';
|
|
import { useIsMobile } from 'hooks/useIsMobile';
|
|
import { useGlobal } from 'hooks/useGlobal';
|
|
import { defaultLayout } from './defaultLayout';
|
|
import { EmailList } from './EmailList';
|
|
import { EmailReader } from './EmailReader';
|
|
|
|
const PROMPT_PREFIX = `You are an email assistant. The user has a local SQLite email database available via the "email-db" tool — use it for all email queries (search, count, stats, aggregations, deletions) unless the user explicitly asks you to use Gmail. Do not use the Gmail integration for questions about existing emails.`;
|
|
|
|
export const EmailScreen = () => {
|
|
const isMobile = useIsMobile();
|
|
const [selectedId, setSelectedId] = useGlobal<string | null>('EMAIL_SELECTED', null);
|
|
const workspace = useWorkspacesState<LayoutNode>('screens/email', defaultLayout);
|
|
|
|
const components: PanelComponents = useMemo(
|
|
() => ({
|
|
'email-list': EmailList,
|
|
'email-reader': EmailReader,
|
|
}),
|
|
[],
|
|
);
|
|
|
|
const mobilePanelId = isMobile && selectedId ? 'email-reader' : undefined;
|
|
const onMobileBack = useCallback(() => setSelectedId(null), [setSelectedId]);
|
|
|
|
return (
|
|
<div className="h-full w-full pt-2">
|
|
<WorkspaceView
|
|
workspace={workspace}
|
|
locked
|
|
components={components}
|
|
promptPrefix={PROMPT_PREFIX}
|
|
mobilePanelId={mobilePanelId}
|
|
onMobilePanelChange={mobilePanelId ? () => onMobileBack() : undefined}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|