stop couriering a system prompt through the framework
`promptPrefix` was a workspace-context field: the email and browser screens set it, `WorkspaceView` put it on the context, and `ChatPanelWrapper` read it back off. Only the chat app has ever understood what the string is, so the framework was carrying an app's vocabulary between two places that both know each other. `components` already exists for this — a screen supplies its own component for a panel id, and `PanelSlot` prefers it over the registry while still taking header and provider from the registry entry, so a screen-mounted chat panel keeps its normal chrome. Both screens now do that, and pass the prefix as a prop. `ChatPanelWrapper` is exported from the barrel for it. Also removes the same prop from `WorkspaceLayout`, where it had no callers at all: every preview and settings pane rendering through it was already handing its chat panels an undefined prefix.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useMemo, useCallback, useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router';
|
||||
import type { LayoutNode, PanelComponents } from 'officerdev';
|
||||
import { WorkspaceView } from 'officerdev';
|
||||
import { WorkspaceView, ChatPanelWrapper } from 'officerdev';
|
||||
import { useDashboardState } from 'state/useDashboardState';
|
||||
import { useIsMobile } from 'hooks/useIsMobile';
|
||||
import { useGlobal } from 'hooks/useGlobal';
|
||||
@@ -12,6 +12,11 @@ import { ComposeModal } from './Compose';
|
||||
|
||||
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.`;
|
||||
|
||||
// The prefix is this screen's, so this screen mounts the chat panel that gets it — rather than handing
|
||||
// the string to the workspace to courier down to whichever app happens to read it. The panel id is the
|
||||
// one in `defaultLayout`, and the layout is locked, so it is the same panel either way.
|
||||
const EmailChatPanel = () => <ChatPanelWrapper panelId="email-chat" promptPrefix={PROMPT_PREFIX} />;
|
||||
|
||||
export const EmailScreen = () => {
|
||||
const isMobile = useIsMobile();
|
||||
const { emailId } = useParams<{ emailId?: string }>();
|
||||
@@ -37,6 +42,7 @@ export const EmailScreen = () => {
|
||||
() => ({
|
||||
'email-list': EmailList,
|
||||
'email-reader': EmailReader,
|
||||
'email-chat': EmailChatPanel,
|
||||
}),
|
||||
[],
|
||||
);
|
||||
@@ -50,7 +56,6 @@ export const EmailScreen = () => {
|
||||
workspace={workspace}
|
||||
locked
|
||||
components={components}
|
||||
promptPrefix={PROMPT_PREFIX}
|
||||
mobilePanelId={mobilePanelId}
|
||||
onMobilePanelChange={mobilePanelId ? () => onMobileBack() : undefined}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user