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
refactor(ai): remove instructions.md from the web app (#8575)
Eric Hayesd3d6f8f7657a
diff --git a/apps/web/src/components/app/GlobalHotkeys.tsx b/apps/web/src/components/app/GlobalHotkeys.tsxindex c2a63b7332..f6ebc668ac 100644--- a/apps/web/src/components/app/GlobalHotkeys.tsx+++ b/apps/web/src/components/app/GlobalHotkeys.tsx@@ -16,7 +16,6 @@ import { useSubscribeToKeypress } from '@app/signal/hotkeyRoot';import { globalSplitManager } from '@app/signal/splitLayout';import { useHandleFileUpload } from '@app/util/handleFileUpload';import { useLogout } from '@core/auth/logout';-import { useOpenInstructionsMd } from '@core/component/AI/util/instructions';import { toast } from '@core/component/Toast/Toast';import { enableSnippets, LOCAL_ONLY } from '@core/constant/featureFlags';import {@@ -40,7 +39,6 @@ import Plus from '@phosphor/plus.svg';import LogoutIcon from '@phosphor/sign-out.svg';import Upload from '@phosphor/upload.svg';import UserIcon from '@phosphor/user.svg';-import { AiInstructionsIcon } from '@queries/storage/instructions-md';import { useMutationUndoContext } from '@queries/undo';import { debounce } from '@solid-primitives/scheduled';import { ThemeChips } from '@theme/components/ThemeChips';@@ -379,19 +377,6 @@ export default function GlobalShortcuts() {runWithInputFocused: true,});- const openInstructions = useOpenInstructionsMd();- registerHotkey({- hotkeyToken: TOKENS.global.instructions,- scopeId: 'global',- description: 'Open AI instructions',- keyDownHandler: () => {- openInstructions();- return true;- },- icon: AiInstructionsIcon,- runWithInputFocused: true,- });-registerHotkey({scopeId: 'global',description: 'MCP setup',diff --git a/apps/web/src/features/block-chat/component/TopBar.tsx b/apps/web/src/features/block-chat/component/TopBar.tsxindex 3cbff4d12b..01a604b2de 100644--- a/apps/web/src/features/block-chat/component/TopBar.tsx+++ b/apps/web/src/features/block-chat/component/TopBar.tsx@@ -10,7 +10,6 @@ import { BlockItemSplitLabel } from '@components/app/split-layout/components/Splimport { useBlockId } from '@core/block';import { ProviderIcon } from '@core/component/AI/component/ProviderIcon';import { useChatInputContext } from '@core/component/AI/context';-import { useOpenInstructionsMd } from '@core/component/AI/util/instructions';import {getShareDrawerRecipientInput,ShareTrigger,@@ -22,7 +21,6 @@ import { useGetPermissions } from '@core/signal/permissions';import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';import IconShared from '@icon/share.svg';import ChatDebugIcon from '@phosphor/chat-text.svg';-import Notepad from '@phosphor/notepad.svg';import type { Accessor } from 'solid-js';export function TopBar(props: {@@ -35,8 +33,6 @@ export function TopBar(props: {const name = useBlockDocumentName(DEFAULT_CHAT_NAME);const chatName = () => name();- const openInstructions = useOpenInstructionsMd();-const permissions = useGetPermissions();const openShare = useShareModal(() => ({id: blockId,@@ -48,11 +44,6 @@ export function TopBar(props: {}));const ops: FileOperation[] = [- {- label: 'Edit AI Instructions',- icon: Notepad,- action: openInstructions,- },...(DEV_MODE_ENV && props.toggleStreamDebug? [{diff --git a/apps/web/src/features/block-md/component/Block.tsx b/apps/web/src/features/block-md/component/Block.tsxindex 87c3880384..eaaf16e723 100644--- a/apps/web/src/features/block-md/component/Block.tsx+++ b/apps/web/src/features/block-md/component/Block.tsx@@ -27,7 +27,6 @@ import {} from '@core/signal/permissions';import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';import { DocumentDebouncedNotificationReadMarker } from '@notifications';-import { useInstructionsMdIdQuery } from '@queries/storage/instructions-md';import { Show, Suspense } from 'solid-js';import { createMarkdownDocumentState } from '../context/markdown-document-state';import type { MarkdownData } from '../definition';@@ -39,7 +38,7 @@ import { MarkdownDocument, MarkdownDocumentContent } from './MarkdownDocument';import { useMarkdownName } from './MarkdownNameProvider';import { ModalsProvider } from './ModalsProvider';import { MarkdownSidePanelSections } from './sidepanel/MarkdownSidePanelSections';-import { InstructionsTopBar, TopBar } from './TopBar';+import { TopBar } from './TopBar';import { useTaskBranchNameHotkey } from './useTaskBranchNameHotkey';export interface BlockMarkdownProps {@@ -74,9 +73,6 @@ export default function MarkdownBlockAdapter(props: BlockMarkdownProps) {});const persistedName = useBlockDocumentName('');const fallbackName = useBlockDocumentName();- const instructionsMdId = useInstructionsMdIdQuery();- const isInstructions = () =>- instructionsMdId.isSuccess && documentId === instructionsMdId.data;const markdownState = createMarkdownDocumentState();if (!useIsNestedBlock())createMarkdownRouteNavigation(@@ -137,7 +133,7 @@ export default function MarkdownBlockAdapter(props: BlockMarkdownProps) {><ModalsProvider><SidePanel.Layout floating>- <Show when={ENABLE_MARKDOWN_SIDE_PANEL && !isInstructions()}>+ <Show when={ENABLE_MARKDOWN_SIDE_PANEL}><MarkdownSidePanelSections /></Show><div class="flex flex-col size-full">@@ -154,18 +150,14 @@ export default function MarkdownBlockAdapter(props: BlockMarkdownProps) {</Show></SplitHeaderRight><Suspense>- <Show when={isInstructions()} fallback={<ManagedTopBar />}>- <InstructionsTopBar />- </Show>+ <ManagedTopBar /></Suspense><Suspense>- <Show when={!isInstructions()}>- <div class="absolute right-4 top-1.5 z-action-menu flex justify-end">- <FindAndReplace- hotkeyScope={blockHotkeyScopeSignal.get()}- />- </div>- </Show>+ <div class="absolute right-4 top-1.5 z-action-menu flex justify-end">+ <FindAndReplace+ hotkeyScope={blockHotkeyScopeSignal.get()}+ />+ </div></Suspense></div><DocumentDebouncedNotificationReadMarker@@ -173,7 +165,6 @@ export default function MarkdownBlockAdapter(props: BlockMarkdownProps) {documentId={documentId}/><MarkdownDocumentContent- isInstructions={isInstructions()}hotkeyScope={blockHotkeyScopeSignal.get()}autoFocus={canAutofocus && !navigatedFromJK()}doInitialSync={data()?.doInitialSync}diff --git a/apps/web/src/features/block-md/component/InstructionsEditor.tsx b/apps/web/src/features/block-md/component/InstructionsEditor.tsxdeleted file mode 100644index 7cec248b07..0000000000--- a/apps/web/src/features/block-md/component/InstructionsEditor.tsx+++ /dev/null@@ -1,443 +0,0 @@-import { SplitBottomPanel } from '@components/app/split-layout/components/SplitBottomPanel';-import { DecoratorRenderer } from '@core/component/LexicalMarkdown/component/core/DecoratorRenderer';-import { FocusClickTarget } from '@core/component/LexicalMarkdown/component/core/FocusClickTarget';-import { LexicalStateDebugger } from '@core/component/LexicalMarkdown/component/debug/LexicalStateDebugger';-import { EmojiMenu } from '@core/component/LexicalMarkdown/component/menu/EmojiMenu';-import { MentionsMenu } from '@core/component/LexicalMarkdown/component/menu/MentionsMenu';-import { SnippetsMenu } from '@core/component/LexicalMarkdown/component/menu/SnippetsMenu';-import {- getErrorDescription,- MarkdownEditorErrors,-} from '@core/component/LexicalMarkdown/constants';-import {- createLexicalWrapper,- LexicalWrapperContext,-} from '@core/component/LexicalMarkdown/context/LexicalWrapperContext';-import {- awaitPlugin,- CLOSE_INLINE_SEARCH_COMMAND,- DefaultShortcuts,- documentMetadataPlugin,- keyboardShortcutsPlugin,- markdownPastePlugin,- mentionsPlugin,- textPastePlugin,-} from '@core/component/LexicalMarkdown/plugins';-import { emojisPlugin } from '@core/component/LexicalMarkdown/plugins/emojis/emojisPlugin';-import { snippetsPlugin } from '@core/component/LexicalMarkdown/plugins/snippets';-import type { MentionLinkResolver } from '@core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin';-import { useUserPromptPlugin } from '@core/component/LexicalMarkdown/plugins/userPrompt';-import { createMenuOperations } from '@core/component/LexicalMarkdown/shared/inlineMenu';-import {- editorFocusSignal,- editorIsEmpty,- getSaveState,- initializeEditorEmpty,- initializeEditorWithState,- setEditorStateFromMarkdown,-} from '@core/component/LexicalMarkdown/utils';-import { ENABLE_MARKDOWN_LIVE_COLLABORATION } from '@core/constant/featureFlags';-import { onElementConnect } from '@core/util/onElementConnect';-import { bufToString } from '@core/util/string';-import type { LoroManager } from '@macro-inc/collaboration/collab/manager';-import {- AwaitNode,- CommentNode,- createPeerIdValidator,- InlineSearchNode,- type PeerIdValidator,- peerIdPlugin,-} from '@macro-inc/lexical-core';-import { Telemetry } from '@macro-inc/observability';-import { debounce } from '@solid-primitives/scheduled';-import type { EditorState } from 'lexical';-import {- type Accessor,- createEffect,- createMemo,- createSignal,- onCleanup,- Show,-} from 'solid-js';-import { useMarkdownDocument } from '../context/markdown-document-context';-import { createSaveMarkdownDocumentMutation } from '../queries/markdown-document-operations';-import { EditorSystemMessage } from './EditorSystemMessage';-import { MarkdownCollabProvider } from './MarkdownCollabProvider';--const EDITOR_PADDING_BOTTOM = 120;--export function InstructionsEditor(props: {- loroManager: LoroManager;- showLexicalStateDebugger?: boolean;- onLexicalStateDebuggerClose?: () => void;- resolveAppLink?: MentionLinkResolver;-}) {- const {- documentId,- documentSource,- element: blockElement,- permissions,- state: documentState,- } = useMarkdownDocument();- const canEdit = permissions.canEdit;- const blockId = documentId();-- const saveDocumentMutation = createSaveMarkdownDocumentMutation();- const {- setMd: setMdStore,- error: editorError,- setError: setEditorError,- } = documentState.editor;- const saveBlocked = () => documentState.comments.activeCommentThread === -1;-- const IS_SYNC = () => documentSource().type === 'sync';-- const debouncedSaveState = debounce(() => {- const state_ = state();- if (!state_ || !canEdit() || saveBlocked()) return;- const savableState = getSaveState(editor.getEditorState());- saveDocumentMutation.mutate({- documentId: blockId,- text: JSON.stringify(savableState),- });- }, 500);-- // flush save state after unblocking- createEffect((prev) => {- const saveBlocked_ = saveBlocked();- // no save on load- if (!saveBlocked_ && prev !== undefined) {- debouncedSaveState();- }-- return saveBlocked_;- }, undefined);-- let editorContainerRef!: HTMLDivElement;-- const [clickTargetHeight, setClickTargetHeight] = createSignal(0);-- const [editorReady, setEditorReady] = createSignal<boolean>(false);-- createEffect(() => {- // We still want the editor to be locked down (for certain things like click events on check- // lists) when the user does not have editor access.- editor.setEditable(canEdit());- });-- const isContentEditable = createMemo(() => {- return (canEdit() ?? false) && !editorError();- });-- const lexicalWrapper = createLexicalWrapper({- type: 'markdown-sync',- namespace: 'block-md-instructions',- isInteractable: isContentEditable,- withIds: true,- });-- const { editor, plugins, cleanup: cleanupPlugins } = lexicalWrapper;-- let [state, setState] = createSignal<EditorState>(editor.getEditorState());-- setMdStore('editor', editor);- setMdStore('plugins', plugins);- const [editorFocus, setEditorFocus] = createSignal(false);- editorFocusSignal(editor, setEditorFocus);-- const mentionsMenuOperations = createMenuOperations();- const emojiMenuOperations = createMenuOperations();- const snippetsMenuOperations = createMenuOperations();-- const peerIdValidator: Accessor<PeerIdValidator> = () => {- if (!IS_SYNC()) {- return createPeerIdValidator(() => undefined, false);- }- const peerId = () => props.loroManager.peerIdStr;- return createPeerIdValidator(peerId, true);- };-- const userPromptPlugin = useUserPromptPlugin({- documentId: blockId,- });-- // plugins- plugins- .richText()- .list()- .markdownShortcuts()- .delete()- .state<EditorState>(setState, 'json')- .history(400, props.loroManager)- .use(userPromptPlugin)- .use(- emojisPlugin({- menu: emojiMenuOperations,- peerIdValidator: peerIdValidator(),- })- )- .use(- mentionsPlugin({- menu: mentionsMenuOperations,- peerIdValidator: peerIdValidator(),- sourceDocumentId: blockId,- disableMentionTracking: true,- })- )- .use(- snippetsPlugin({- menu: snippetsMenuOperations,- peerIdValidator: peerIdValidator(),- sourceDocumentId: blockId,- })- )- .use(textPastePlugin(props.resolveAppLink))- .use(markdownPastePlugin())- .use(awaitPlugin())- .use(- keyboardShortcutsPlugin({- shortcuts: DefaultShortcuts,- })- )- .use(- documentMetadataPlugin({- onVersionError: (error) => setEditorError(error),- })- );-- if (ENABLE_MARKDOWN_LIVE_COLLABORATION) {- const peerId = () => props.loroManager.peerIdStr;- plugins.use(- peerIdPlugin({- peerId,- nodes: [InlineSearchNode, CommentNode, AwaitNode],- })- );- }-- const onConnect = (el: HTMLDivElement) => {- setMdStore('selection', lexicalWrapper.selection);- editor.setRootElement(el);-- // watch the height of the content editable to set the height of- // the focus target- const editorRefObserver = new ResizeObserver(() => {- const blockEl = blockElement();- if (!blockEl) {- setClickTargetHeight(EDITOR_PADDING_BOTTOM);- return;- }- const blockBottom =- blockEl?.getBoundingClientRect().bottom ?? window.innerHeight;-- const targetHeight = blockBottom - el.getBoundingClientRect().bottom - 40;- setClickTargetHeight(Math.max(targetHeight, EDITOR_PADDING_BOTTOM));- });-- editorRefObserver.observe(el);- onCleanup(() => {- editorRefObserver.disconnect();- });- };-- const additionalCleanups: Array<() => void> = [];-- onCleanup(() => {- additionalCleanups.forEach((cleanup) => cleanup());- cleanupPlugins();- });-- createEffect(() => {- // We still want the editor to be locked down (for certain things like click events on check- // lists) when the user does not have editor access.- editor.setEditable(canEdit() ?? false);- });-- const [editorHasNoContent, setEditorHasNoContent] = createSignal(false);-- const isBlankMarkdown = createMemo(() => {- return editorHasNoContent();- });-- // not all changes that can trigger preview display are text content changes.- additionalCleanups.push(- editor.registerUpdateListener(({ editorState }) => {- setEditorHasNoContent(editorIsEmpty(editorState));- })- );-- // handle changes to the editor after initial load- const registerSaveListener = () => {- additionalCleanups.push(- editor.registerUpdateListener(({ mutatedNodes }) => {- if (mutatedNodes === null || mutatedNodes.size === 0) return;- debouncedSaveState();- })- );- };-- const [fileArrayBuffer, setFileArrayBuffer] = createSignal<ArrayBuffer>();- const readFileArrayBuffer = async (file: Blob) => {- setFileArrayBuffer(await file.arrayBuffer());- };- createEffect(() => {- const source = documentSource();- if (source.type !== 'dss') return;-- readFileArrayBuffer(source.file).catch((error) =>- Telemetry.error(error, { surface: 'instructions-editor' })- );- });-- createEffect(() => {- if (documentSource().type !== 'dss') return;- if (editorReady()) return;-- const buf = fileArrayBuffer();- if (!buf) return;- const text = bufToString(buf);-- // Blank state is a new document.- if (text === '') {- setEditorHasNoContent(true);- initializeEditorEmpty(editor);-- registerSaveListener();- return;- }-- // Valid JSON state is an existing document.- let validJson = true;- try {- const parsed = JSON.parse(text);- initializeEditorWithState(editor, parsed);-- // don't open any hanging inline searches.- editor.dispatchCommand(CLOSE_INLINE_SEARCH_COMMAND, undefined);-- if (editorIsEmpty(editor.getEditorState())) {- setEditorHasNoContent(true);- }-- registerSaveListener();- setEditorReady(true);- return;- } catch (e) {- console.error('LexicalParseError : ', e);- validJson = false;- }-- // Fallback is treated as a markdown string.- if (!validJson) {- setEditorStateFromMarkdown(editor, text);- if (editorIsEmpty(editor.getEditorState())) {- setEditorHasNoContent(true);- }-- // Fallback is treated as a markdown string.- if (!validJson) {- setEditorStateFromMarkdown(editor, text);- registerSaveListener();- }-- if (editorIsEmpty(editor)) {- setEditorError(MarkdownEditorErrors.EMPTY_SOURCE);- }- }-- setEditorReady(true);- });-- return (- <LexicalWrapperContext.Provider value={lexicalWrapper}>- <Show when={editorError()}>- {(error) => (- <EditorSystemMessage variant="warning" class="mb-2">- {getErrorDescription(error())}- </EditorSystemMessage>- )}- </Show>- <div class="relative text-base" ref={editorContainerRef}>- <div- ref={(el) => {- onElementConnect(el, () => {- onConnect(el);- });- }}- contentEditable={isContentEditable()}- class="w-full max-w-full"- classList={{- 'select-auto': !canEdit(),- 'md-no-comments': true,- }}- />-- <Show when={IS_SYNC()}>- <MarkdownCollabProvider- editor={editor}- pluginManager={plugins}- editorContainerRef={editorContainerRef}- highlighLayerRef={editorContainerRef}- mappings={lexicalWrapper.mapping!}- editorFocus={editorFocus}- setEditorReady={setEditorReady}- setEditorError={setEditorError}- loroManager={props.loroManager}- />- </Show>-- <FocusClickTarget- editor={editor}- editorFocus={editorFocus}- style={{ height: `${clickTargetHeight()}px` }}- />- <Show when={isBlankMarkdown()}>- <div class="pointer-events-none text-ink-placeholder absolute top-0">- {canEdit()- ? `Enter custom instructions for AI here...`- : `This document is blank...`}- </div>- </Show>-- <DecoratorRenderer editor={editor} />-- <EmojiMenu- editor={editor}- menu={emojiMenuOperations}- useBlockBoundary={true}- />-- <MentionsMenu- editor={editor}- menu={mentionsMenuOperations}- useBlockBoundary={true}- disableMentionTracking={true}- />-- <SnippetsMenu- editor={editor}- menu={snippetsMenuOperations}- useBlockBoundary={true}- sourceDocumentId={blockId}- />-- <Show when={props.showLexicalStateDebugger}>- <Show when={state()}>- {(state) => (- <SplitBottomPanel- id="lexical-state-debugger"- title="Lexical state debugger"- onClose={props.onLexicalStateDebuggerClose}- >- <LexicalStateDebugger- state={state()}- editor={editor}- ></LexicalStateDebugger>- </SplitBottomPanel>- )}- </Show>- </Show>- </div>- </LexicalWrapperContext.Provider>- );-}diff --git a/apps/web/src/features/block-md/component/MarkdownDocument.tsx b/apps/web/src/features/block-md/component/MarkdownDocument.tsxindex 44ffb4df68..1a4372ec78 100644--- a/apps/web/src/features/block-md/component/MarkdownDocument.tsx+++ b/apps/web/src/features/block-md/component/MarkdownDocument.tsx@@ -25,7 +25,6 @@ import {createSignal,on,type ParentProps,- Show,Suspense,} from 'solid-js';import {@@ -42,7 +41,7 @@ import { HistoryWorkspace } from '../history/HistoryWorkspace';import { resumeDocumentSpan, stampLoroSnapshotState } from '../observability';import type { MarkdownDocumentKind, MarkdownDocumentSource } from '../types';import { MarkdownNameProvider } from './MarkdownNameProvider';-import { InstructionsNotebook, Notebook } from './Notebook';+import { Notebook } from './Notebook';type MarkdownLoroManager = LoroManager<typeof MARKDOWN_LORO_SCHEMA>;type SnapshotResult = {@@ -287,7 +286,6 @@ function useMarkdownSnapshotIngest(}export type MarkdownDocumentContentProps = MarkdownSnapshotIngestOptions & {- isInstructions?: boolean;hotkeyScope?: string;autoFocus?: boolean;};@@ -302,8 +300,6 @@ export function MarkdownDocumentContent(props: MarkdownDocumentContentProps) {useMarkdownSnapshotIngest(loroManager, props);- const isInstructions = () => props.isInstructions ?? false;-return (<div class="w-full grow overflow-hidden relative" data-block-content><Scroll@@ -316,22 +312,12 @@ export function MarkdownDocumentContent(props: MarkdownDocumentContentProps) {><div class="relative portal-scope touch:pt-(--mobile-content-inset-top) touch:pb-(--mobile-content-inset-bottom)"><Suspense>- <Show- when={!isInstructions()}- fallback={- <InstructionsNotebook- loroManager={loroManager}- hotkeyScope={props.hotkeyScope}- />- }- >- <Notebook- loroManager={loroManager}- documentId={documentId}- hotkeyScope={props.hotkeyScope}- autoFocus={props.autoFocus ?? false}- />- </Show>+ <Notebook+ loroManager={loroManager}+ documentId={documentId}+ hotkeyScope={props.hotkeyScope}+ autoFocus={props.autoFocus ?? false}+ /></Suspense></div></Scroll>diff --git a/apps/web/src/features/block-md/component/Notebook.tsx b/apps/web/src/features/block-md/component/Notebook.tsxindex e59a7df64e..0d647ac4a9 100644--- a/apps/web/src/features/block-md/component/Notebook.tsx+++ b/apps/web/src/features/block-md/component/Notebook.tsx@@ -35,7 +35,6 @@ import { useMarkdownDocument } from '../context/markdown-document-context';import { DocumentDiscussion } from './DocumentDiscussion';import { InlineTaskGithubPullRequests } from './InlineTaskGithubPullRequests';import { InlineTaskProperties } from './InlineTaskProperties';-import { InstructionsEditor } from './InstructionsEditor';import { MarkdownEditor } from './MarkdownEditor';import { useMarkdownName } from './MarkdownNameProvider';import {@@ -47,10 +46,7 @@ import {} from './MarkdownOutline';import { TaskDuplicateMatchPill } from './TaskDuplicateMatches';import { TitleEditor } from './TitleEditor';-import {- registerLexicalStateDebuggerCommand,- registerMarkdownCommands,-} from './useMarkdownCommands';+import { registerMarkdownCommands } from './useMarkdownCommands';/*** Whether the Lexical state debugger panel is open, persisted across reloads so@@ -414,67 +410,3 @@ export function Notebook(props: {</div>);}--export function InstructionsNotebook(props: {- loroManager: LoroManager;- hotkeyScope: string | undefined;-}) {- const { state } = useMarkdownDocument();- const setMd = state.editor.setMd;- const scopeId = () => props.hotkeyScope;- const canUseLexicalStateDebugger = useCanUseLexicalStateDebugger();- const resolveAppLink = useMacroMentionLinkResolver();-- let notebookRef!: HTMLDivElement;- let contentRef!: HTMLDivElement;-- // Set the refs on the block store.- onMount(() => {- setMd({- notebook: notebookRef,- commentMargin: undefined,- contentRef: contentRef,- });- onCleanup(() => {- setMd({- notebook: undefined,- commentMargin: undefined,- });- });- });-- createEffect(() => {- const currentScopeId = scopeId();- if (!currentScopeId) return;- const group = untrack(() =>- registerLexicalStateDebuggerCommand(currentScopeId, {- canUseStateDebugger: canUseLexicalStateDebugger,- toggleStateDebugger: () => setShowLexicalStateDebugger((prev) => !prev),- })- );- onCleanup(() => group.dispose());- });- createEffect(() => {- if (!canUseLexicalStateDebugger() && showLexicalStateDebugger()) {- setShowLexicalStateDebugger(false);- }- });-- return (- <div- class="flex relative text-ink min-h-full min-w-0 px-6"- ref={notebookRef}- >- <div class="grow max-w-3xl pt-12 min-w-0 mx-auto" ref={contentRef}>- <InstructionsEditor- resolveAppLink={resolveAppLink}- loroManager={props.loroManager}- showLexicalStateDebugger={- canUseLexicalStateDebugger() && showLexicalStateDebugger()- }- onLexicalStateDebuggerClose={() => setShowLexicalStateDebugger(false)}- />- </div>- </div>- );-}diff --git a/apps/web/src/features/block-md/component/TopBar.tsx b/apps/web/src/features/block-md/component/TopBar.tsxindex 47172f9dbc..edd9662566 100644--- a/apps/web/src/features/block-md/component/TopBar.tsx+++ b/apps/web/src/features/block-md/component/TopBar.tsx@@ -6,10 +6,7 @@ import {SplitHeaderLeft,SplitHeaderRight,} from '@components/app/split-layout/components/SplitHeader';-import {- BlockItemSplitLabel,- StaticSplitLabel,-} from '@components/app/split-layout/components/SplitLabel';+import { BlockItemSplitLabel } from '@components/app/split-layout/components/SplitLabel';import { useBlockAliasedName, useBlockId, useBlockName } from '@core/block';import { BlockLiveIndicators } from '@core/component/LiveIndicators';import { useBlockDocumentName } from '@core/util/currentBlockDocumentName';@@ -61,11 +58,3 @@ export function TopBar(props: { name?: Accessor<string | undefined> } = {}) {</>);}--export function InstructionsTopBar() {- return (- <SplitHeaderLeft>- <StaticSplitLabel label="AI Instructions" iconType="md" />- </SplitHeaderLeft>- );-}diff --git a/apps/web/src/features/block-md/component/useMarkdownCommands.ts b/apps/web/src/features/block-md/component/useMarkdownCommands.tsindex 21d3e366a8..9a0636cf0e 100644--- a/apps/web/src/features/block-md/component/useMarkdownCommands.ts+++ b/apps/web/src/features/block-md/component/useMarkdownCommands.ts@@ -130,15 +130,6 @@ function registerLexicalStateDebuggerHotkey(}).withGroup(group);}-export function registerLexicalStateDebuggerCommand(- scopeId: string,- options: LexicalStateDebuggerCommandOptions-) {- const group = createHotkeyGroup();- registerLexicalStateDebuggerHotkey(scopeId, options, group);- return group;-}-/*** Registers markdown formatting commands on the block hotkey scope so they* appear in the command menu (Cmd+K). Inline formats that already havediff --git a/apps/web/src/lib/core/component/AI/constant/prompts.ts b/apps/web/src/lib/core/component/AI/constant/prompts.tsindex b9f3383d19..8318504ed9 100644--- a/apps/web/src/lib/core/component/AI/constant/prompts.ts+++ b/apps/web/src/lib/core/component/AI/constant/prompts.ts@@ -1,5 +1,4 @@import { useUserContext } from '@core/context/user';-import { useInstructionsMdTextQuery } from '@queries/storage/instructions-md';import { authServiceClient } from '@service-auth/client';import { createResource } from 'solid-js';import { getOpenEntitiesPrompt } from './openEntitiesPrompt';@@ -28,7 +27,6 @@ Internal terminology and knowledge`;export function useAdditionalInstructions() {- const userInstructionsQuery = useInstructionsMdTextQuery();const { email } = useUserContext();const [userName] = createResource(async () => {const response = await authServiceClient.getUserName();@@ -47,13 +45,6 @@ export function useAdditionalInstructions() {prompt += `\nEmail: ${email()}`;}}- const userInstructions =- userInstructionsQuery.isSuccess && userInstructionsQuery.data;- if (userInstructions) {- prompt +=- '\nThese are system instructions provided by the user. Follow them\n';- prompt += userInstructions;- }const openEntities = getOpenEntitiesPrompt(currentChatId);if (openEntities) {prompt += openEntities;diff --git a/apps/web/src/lib/core/component/AI/util/instructions.ts b/apps/web/src/lib/core/component/AI/util/instructions.tsdeleted file mode 100644index 22d41bc5d0..0000000000--- a/apps/web/src/lib/core/component/AI/util/instructions.ts+++ /dev/null@@ -1,52 +0,0 @@-import { useSplitLayout } from '@components/app/split-layout/layout';-import { toast } from '@core/component/Toast/Toast';-import { Telemetry } from '@macro-inc/observability';-import {- useCreateInstructionsMd,- useInstructionsMdIdQuery,-} from '@queries/storage/instructions-md';--const showFailToast = () => {- toast.failure('Failed to open AI instructions document');-};--export function useOpenInstructionsMd() {- const maybeId = useInstructionsMdIdQuery();- const createInstructionsMd = useCreateInstructionsMd();- const { insertSplit } = useSplitLayout();-- // returns true if the document was opened (or already open)- const open = (id: string | null | undefined): boolean => {- if (id) {- insertSplit({- id,- type: 'md',- });- return true;- }- return false;- };-- return () => {- const id = maybeId.data;- const success = open(id);- if (success) return;-- // needs to be created- if (id === null) {- createInstructionsMd()- .then((id) => {- const success = open(id);- if (success) return;- showFailToast();- })- .catch((error) => {- Telemetry.error(error, { surface: 'ai-instructions' });- showFailToast();- });- return;- }-- showFailToast();- };-}diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/userPrompt/index.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/userPrompt/index.tsdeleted file mode 100644index 5128efcfc6..0000000000--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/userPrompt/index.ts+++ /dev/null@@ -1 +0,0 @@-export { useUserPromptPlugin } from './userPromptPlugin';diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/userPrompt/userPromptPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/userPrompt/userPromptPlugin.tsdeleted file mode 100644index 8c495af78f..0000000000--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/userPrompt/userPromptPlugin.ts+++ /dev/null@@ -1,44 +0,0 @@-import { $convertToMarkdownString } from '@lexical/markdown';-import { ALL_TRANSFORMERS } from '@macro-inc/lexical-core';-import { useUpdateInstructionsMdTextCache } from '@queries/storage/instructions-md';-import { debounce } from '@solid-primitives/scheduled';-import { $getRoot, type LexicalEditor, type UpdateListener } from 'lexical';--const DEFAULT_DEBOUNCE_TIME = 300;--type UserPromptPluginProps = {- documentId: string;- debounceTime?: number;- storageKey?: string;-};--function registerUserPromptPlugin(- editor: LexicalEditor,- props: UserPromptPluginProps,- updateCache: (text: string) => void-) {- const debounceTime = props.debounceTime || DEFAULT_DEBOUNCE_TIME;-- const updateQueryCache: UpdateListener = ({ editorState }) => {- const markdownText = editorState.read(() => {- const root = $getRoot();- return $convertToMarkdownString(ALL_TRANSFORMERS, root);- });-- try {- // Update the query cache directly with the new text- updateCache(markdownText);- } catch (error) {- console.warn('Failed to update instructions query cache:', error);- }- };-- const debouncedSave = debounce(updateQueryCache, debounceTime);- return editor.registerUpdateListener(debouncedSave);-}--export function useUserPromptPlugin(props: UserPromptPluginProps) {- const updateCache = useUpdateInstructionsMdTextCache();- return (editor: LexicalEditor) =>- registerUserPromptPlugin(editor, props, updateCache);-}diff --git a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.test.ts b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.test.tsindex 94dfc15275..49ed3472ee 100644--- a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.test.ts+++ b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.test.ts@@ -184,9 +184,6 @@ vi.mock('@queries/soup/recently-viewed', () => ({useRecentlyViewedSoupQuery: () =>mocks.queries['recently-viewed']?.() ?? { data: [], isSuccess: true },}));-vi.mock('@queries/storage/instructions-md', () => ({- useInstructionsMdIdQuery: () => ({ data: undefined }),-}));vi.mock('@queries/storage/databases', () => ({useDatabasesQuery: () => ({ data: mocks.databases, isSuccess: true }),}));diff --git a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsxindex a012bc70ab..f62caa39c9 100644--- a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx+++ b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx@@ -50,7 +50,6 @@ import { useQuickAccessSnippetsQuery } from '@queries/soup/quick-access-snippetsimport { useRecentlyViewedSoupQuery } from '@queries/soup/recently-viewed';import { useDatabasesQuery } from '@queries/storage/databases';import { useFormsQuery } from '@queries/storage/forms';-import { useInstructionsMdIdQuery } from '@queries/storage/instructions-md';import { subscribeToVisibleCacheChanges } from '@queries/subscribe-to-visible-cache-changes';import type { ApiChannelWithLatest } from '@service-storage/channel-list-types';import { getGraphqlSoupCacheHost } from '@service-storage/graphql-soup';@@ -414,7 +413,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {));});- const instructionsIdQuery = useInstructionsMdIdQuery();const { query: crmCompaniesQuery, companies: crmCompaniesAccessor } =useQuickAccessCrmCompaniesQuery();const { query: crmContactsQuery, contacts: crmContactsAccessor } =@@ -433,26 +431,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {const { query: initiativesQuery, initiatives: initiativesAccessor } =useQuickAccessInitiativesQuery();- // globally hidden ids- const [hiddenIds, setHiddenIds] = createSignal<Set<string>>(new Set());-- const hideId = (id: string) => {- setHiddenIds((prev) => {- const next = new Set(prev);- next.add(id);- return next;- });- };-- // instructions.md effect- createEffect(() => {- const instructionsReady = queryReadyGate(instructionsIdQuery);- if (!instructionsReady) return;- const instructionsId = instructionsIdQuery.data;- if (!instructionsId) return;- hideId(instructionsId);- });-// stable cache for transformed itemsconst itemCache = new Map<string, CacheEntry>();@@ -477,7 +455,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {// Process history itemsconst historyData = queryReadyGate(historyQuery) ? historyQuery.data : [];- const hidden = hiddenIds();for (const item of historyData) {if (item.deletedAt) continue;if (@@ -485,7 +462,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {item.subType?.type === 'initiative_description')continue;- if (hidden.has(item.id)) continue;seenIds.add(item.id);const viewedAt = latestDate(viewedAtMap.get(item.id), item.viewedAt);@@ -623,7 +599,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {const crmCompanyEntries = createLazyMemo(() => {const viewedAtMap = soupViewedAtMap();const allEntries: IndexEntry[] = [];- const hidden = hiddenIds();// Process CRM companies (live soup list, complements the// recently-viewed feed which only has companies the user has@@ -631,8 +606,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {// updated_at for unviewed companies — same shape as channels.const crmCompanyData = crmCompaniesAccessor();for (const company of crmCompanyData) {- if (hidden.has(company.id)) continue;-const viewedAt =viewedAtMap.get(company.id) ?? company.viewedAt ?? undefined;@@ -687,9 +660,8 @@ export function createQuickAccessValue(): QuickAccessContextValue {// not Macro users, so they stay out of the 'person' bucket.const crmContactEntries = createLazyMemo(() => {const allEntries: IndexEntry[] = [];- const hidden = hiddenIds();for (const contact of crmContactsAccessor()) {- if (contact.hidden || hidden.has(contact.id)) continue;+ if (contact.hidden) continue;const version = getCrmContactVersion(contact);const cached = itemCache.get(contact.id);const item =@@ -710,7 +682,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {const viewedAtMap = soupViewedAtMap();const seenIds = new Set(historyEntries().ids);const allEntries: IndexEntry[] = [];- const hidden = hiddenIds();// Process snippets (live soup list, complements the history feed// which only has snippets the user has opened). Widens the pool to@@ -719,7 +690,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {// already opened.const snippetData = snippetsAccessor();for (const snippet of snippetData) {- if (hidden.has(snippet.id)) continue;if (seenIds.has(snippet.id)) continue;seenIds.add(snippet.id);@@ -777,7 +747,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {const viewedAtMap = soupViewedAtMap();const seenIds = new Set(historyEntries().ids);const allEntries: IndexEntry[] = [];- const hidden = hiddenIds();// Process skills (live soup list, complements the history feed which// only has skills the user has opened). Widens the pool to shared@@ -785,7 +754,6 @@ export function createQuickAccessValue(): QuickAccessContextValue {// History-fed entries win for skills the user has already opened.const skillData = skillsAccessor();for (const skill of skillData) {- if (hidden.has(skill.id)) continue;if (seenIds.has(skill.id)) continue;seenIds.add(skill.id);@@ -837,10 +805,8 @@ export function createQuickAccessValue(): QuickAccessContextValue {const agentSessionEntries = createLazyMemo(() => {const viewedAtMap = soupViewedAtMap();- const hidden = hiddenIds();const entries: IndexEntry[] = [];for (const session of agentSessionsAccessor()) {- if (hidden.has(session.id)) continue;const viewedAt = viewedAtMap.get(session.id) ?? session.viewedAt;const sortTimestamp =toTimestamp(viewedAt) || toTimestamp(session.updatedAt);@@ -874,11 +840,10 @@ export function createQuickAccessValue(): QuickAccessContextValue {// time is the only timestamp to sort on.const databaseEntries = createLazyMemo(() => {if (!databasesFlag().enabled) return [];- const hidden = hiddenIds();const entries: IndexEntry[] = [];const listed = databasesQuery.isSuccess ? databasesQuery.data : [];for (const { database, grant } of listed) {- if (database.trashed_at || hidden.has(database.id)) continue;+ if (database.trashed_at) continue;const sortTimestamp = toTimestamp(database.created_at);const entity: DatabaseEntity = {type: 'database',@@ -912,11 +877,9 @@ export function createQuickAccessValue(): QuickAccessContextValue {// Forms, like databases, have only a creation time to sort on.const formEntries = createLazyMemo(() => {if (!formsFlag().enabled) return [];- const hidden = hiddenIds();const entries: IndexEntry[] = [];const listed = formsQuery.isSuccess ? formsQuery.data : [];for (const { form, access } of listed) {- if (hidden.has(form.id)) continue;const sortTimestamp = toTimestamp(form.createdAt);const entity: FormEntity = {type: 'form',@@ -949,10 +912,8 @@ export function createQuickAccessValue(): QuickAccessContextValue {const initiativeEntries = createLazyMemo(() => {const viewedAtMap = soupViewedAtMap();- const hidden = hiddenIds();const entries: IndexEntry[] = [];for (const initiative of initiativesAccessor()) {- if (hidden.has(initiative.id)) continue;const viewedAt = viewedAtMap.get(initiative.id) ?? initiative.viewedAt;const sortTimestamp =toTimestamp(viewedAt) || toTimestamp(initiative.updatedAt);diff --git a/apps/web/src/lib/core/hotkey/tokens.ts b/apps/web/src/lib/core/hotkey/tokens.tsindex 1060882b00..4035042a45 100644--- a/apps/web/src/lib/core/hotkey/tokens.ts+++ b/apps/web/src/lib/core/hotkey/tokens.ts@@ -104,7 +104,6 @@ export const TOKENS = {commandMenu: 'global.commandMenu',toggleBigChat: 'global.toggleBigChat',toggleSidebar: 'global.toggleSidebar',- instructions: 'global.instructions',searchMenu: 'global.searchMenu',toggleSettings: 'global.toggleSettings',createNewSplit: 'global.createNewSplit',diff --git a/apps/web/src/lib/queries/soup/graphql/grouped-items-offline.test.ts b/apps/web/src/lib/queries/soup/graphql/grouped-items-offline.test.tsindex 2038f1d436..d014a72f88 100644--- a/apps/web/src/lib/queries/soup/graphql/grouped-items-offline.test.ts+++ b/apps/web/src/lib/queries/soup/graphql/grouped-items-offline.test.ts@@ -17,9 +17,6 @@ vi.mock('@macro-inc/observability', () => ({vi.mock('@app/lib/graphql-cache', () => ({normalizedCacheResultMetadata: () => undefined,}));-vi.mock('@queries/storage/instructions-md', () => ({- useInstructionsMdIdQuery: () => ({}),-}));vi.mock('@queries/client', async () => {const { QueryClient } = await import('@tanstack/solid-query');return { queryClient: new QueryClient() };diff --git a/apps/web/src/lib/queries/soup/graphql/grouped-items.test.ts b/apps/web/src/lib/queries/soup/graphql/grouped-items.test.tsindex 4e5446f0ad..ab26603b68 100644--- a/apps/web/src/lib/queries/soup/graphql/grouped-items.test.ts+++ b/apps/web/src/lib/queries/soup/graphql/grouped-items.test.ts@@ -12,9 +12,6 @@ vi.mock('@app/lib/graphql-cache', () => ({normalizedCacheResultMetadata: (result: { metadata: unknown }) =>result.metadata,}));-vi.mock('@queries/storage/instructions-md', () => ({- useInstructionsMdIdQuery: () => ({}),-}));vi.mock('@service-storage/graphql-soup', () => ({getGraphqlSoupClient: () => ({}),getGraphqlSoupCacheHost: () => undefined,diff --git a/apps/web/src/lib/queries/soup/graphql/grouped-items.ts b/apps/web/src/lib/queries/soup/graphql/grouped-items.tsindex 69c0388658..8cce81f59d 100644--- a/apps/web/src/lib/queries/soup/graphql/grouped-items.ts+++ b/apps/web/src/lib/queries/soup/graphql/grouped-items.ts@@ -13,7 +13,6 @@ import { fireAndForget } from '@core/util/fireAndForget';import { isTransientRequestError } from '@core/util/request-error';import { Telemetry } from '@macro-inc/observability';import type { GroupByField } from '@queries/soup/grouped/types';-import { useInstructionsMdIdQuery } from '@queries/storage/instructions-md';import { GroupSoupDocument } from '@service-storage/graphql/generated/graphql';import type { CombinedError } from '@urql/core';import {@@ -57,7 +56,6 @@ export function createGraphqlGroupedSoupAstItemsQuery(args: Accessor<GraphqlGroupedSoupAstItemsQueryArgs>,options: Accessor<GraphqlGroupedSoupAstItemsQueryOptions>): GraphqlSoupAstItemsQuery {- const instructionsIdQuery = useInstructionsMdIdQuery();const pendingDeleteIds = usePendingGraphqlSoupDeleteIds();const pendingDone = usePendingGraphqlSoupDone();const projectDone = createGraphqlSoupDoneProjection();@@ -148,7 +146,6 @@ export function createGraphqlGroupedSoupAstItemsQuery(grouped.data,() => args().groupBy,() => ({- instructionsIdQuery,showSupportedForeignEntities: options().showSupportedForeignEntities,}));diff --git a/apps/web/src/lib/queries/soup/graphql/grouped-projection.test.ts b/apps/web/src/lib/queries/soup/graphql/grouped-projection.test.tsindex c2a719dd53..893301d068 100644--- a/apps/web/src/lib/queries/soup/graphql/grouped-projection.test.ts+++ b/apps/web/src/lib/queries/soup/graphql/grouped-projection.test.ts@@ -103,7 +103,7 @@ describe('grouped Soup projections', () => {const projected = createGraphqlGroupedSoupProjection(() => view.data as GroupSoupQuery,() => ({ type: 'property', propertyDefinitionId: 'status' }),- () => ({ instructionsIdQuery: { isSuccess: false, data: undefined } })+ () => ({}));const before = projected()!;const held = [...before.entities];@@ -171,7 +171,7 @@ describe('grouped Soup projections', () => {const projected = createGraphqlGroupedSoupProjection(source,() => ({ type: 'property', propertyDefinitionId: 'status' }),- () => ({ instructionsIdQuery: { isSuccess: false, data: undefined } })+ () => ({}));const first = projected()!.entities[0];const next = page(2);diff --git a/apps/web/src/lib/queries/soup/graphql/items.test.ts b/apps/web/src/lib/queries/soup/graphql/items.test.tsindex a06a802882..9a810f7ccf 100644--- a/apps/web/src/lib/queries/soup/graphql/items.test.ts+++ b/apps/web/src/lib/queries/soup/graphql/items.test.ts@@ -15,19 +15,13 @@ const getGraphqlSoupClientMock = vi.hoisted(() => vi.fn());const getGraphqlSoupCacheHostMock = vi.hoisted(() => vi.fn());const entityFilterMock = vi.hoisted(() => vi.fn());const readRecordsByKeysMock = vi.hoisted(() => vi.fn());-const useInstructionsMdIdQueryMock = vi.hoisted(() => vi.fn());const REVISION_0 = '0';const REVISION_1 = '1';const REVISION_2 = '2';const mapGraphqlSoupItemMock = vi.hoisted(() => vi.fn((item) => item));const mapSoupPageToEntityListMock = vi.hoisted(() =>vi.fn(- (- page,- _options?: {- instructionsIdQuery: { isSuccess: boolean; data?: string | null };- }- ) => page.items+ (page, _options?: { showSupportedForeignEntities?: boolean }) => page.items));const makeGraphqlSoupInputMock = vi.hoisted(() => vi.fn());@@ -39,10 +33,6 @@ vi.mock('@macro-inc/observability', () => ({},}));-vi.mock('@queries/storage/instructions-md', () => ({- useInstructionsMdIdQuery: useInstructionsMdIdQueryMock,-}));-vi.mock('../../../graphql-cache/exchange/record-selection', () => ({selectRecords: vi.fn((document) => ({ document })),readRecordsByKeys: readRecordsByKeysMock,@@ -182,7 +172,6 @@ describe('createGraphqlSoupAstItemsQuery', () => {beforeEach(() => {queryClient.clear();vi.clearAllMocks();- useInstructionsMdIdQueryMock.mockReturnValue({ isSuccess: false });mapSoupPageToEntityListMock.mockImplementation((page) => page.items);getGraphqlSoupCacheHostMock.mockReturnValue(undefined);makeGraphqlSoupInputMock.mockReturnValue({@@ -281,7 +270,6 @@ describe('createGraphqlSoupAstItemsQuery', () => {await refresh;expect(query.data()?.map((row) => row.id)).toEqual(['fresh']);expect(mapGraphqlSoupItemMock).not.toHaveBeenCalled();- expect(useInstructionsMdIdQueryMock).not.toHaveBeenCalled();} finally {dispose();}@@ -1351,85 +1339,6 @@ describe('createGraphqlSoupAstItemsQuery', () => {}});- it('reprojects cached pages when the instructions document resolves without reading pending data', () => {- const fake = makeFakeClient();- getGraphqlSoupClientMock.mockReturnValue(fake.client);- const [instructions, setInstructions] = createSignal<- { isSuccess: false } | { isSuccess: true; data: string | null }- >({ isSuccess: false });- const [enabled, setEnabled] = createSignal(true);- const readInstructionsData = vi.fn(() => {- const result = instructions();- if (!result.isSuccess) throw new Error('Pending data read');- return result.data;- });- const instructionsQuery = {- get isSuccess() {- return instructions().isSuccess;- },- get data() {- return readInstructionsData();- },- };- useInstructionsMdIdQueryMock.mockReturnValue(instructionsQuery);- mapSoupPageToEntityListMock.mockImplementation((page, options) =>- page.items.filter(- (item: { id: string }) =>- !options?.instructionsIdQuery.isSuccess ||- item.id !== options.instructionsIdQuery.data- )- );- const { query, dispose } = createRoot((dispose) => ({- dispose,- query: createGraphqlSoupAstItemsQuery(- () => ({ params: { sort_method: 'updated_at' }, body: {} }),- () => ({ enabled: enabled() })- ),- }));- const ids = () => query.data()?.entities.map((entity) => entity.id);- try {- fake.executions[0].next(- graphqlSoupPage({- items: [- { id: 'visible', updatedAt: '2026-09-10T00:00:00Z' },- { id: 'instructions', updatedAt: '2026-09-08T00:00:00Z' },- ],- next_cursor: 'next-page',- })- );- expect(ids()).toEqual(['visible', 'instructions']);- expect(readInstructionsData).not.toHaveBeenCalled();- expect(mapGraphqlSoupItemMock).toHaveBeenCalledTimes(2);-- setInstructions({ isSuccess: true, data: 'instructions' });- expect(ids()).toEqual(['visible']);- expect(query.data()?.oldestFetchedTimestamp).toBe(- Date.parse('2026-09-08T00:00:00Z')- );- expect(query.hasNextPage()).toBe(true);- expect(fake.executions).toHaveLength(1);- expect(mapGraphqlSoupItemMock).toHaveBeenCalledTimes(4);-- // An identical id and activity-only changes must keep the cached selector.- setInstructions({ isSuccess: true, data: 'instructions' });- setEnabled(false);- setEnabled(true);- query.resetToInitialPage();- expect(ids()).toEqual(['visible']);- expect(mapGraphqlSoupItemMock).toHaveBeenCalledTimes(4);-- setInstructions({ isSuccess: true, data: 'visible' });- expect(ids()).toEqual(['instructions']);- expect(mapGraphqlSoupItemMock).toHaveBeenCalledTimes(6);-- setInstructions({ isSuccess: true, data: null });- expect(ids()).toEqual(['visible', 'instructions']);- expect(mapGraphqlSoupItemMock).toHaveBeenCalledTimes(8);- } finally {- dispose();- }- });-it('keeps raw wire payloads outside deep store reconciliation', () => {mapSoupPageToEntityListMock.mockImplementation((page) =>page.items.map((item: { id: string }) => ({ id: item.id }))diff --git a/apps/web/src/lib/queries/soup/graphql/items.ts b/apps/web/src/lib/queries/soup/graphql/items.tsindex f2e3a57511..eb139e5e55 100644--- a/apps/web/src/lib/queries/soup/graphql/items.ts+++ b/apps/web/src/lib/queries/soup/graphql/items.ts@@ -6,7 +6,6 @@ import {type GraphqlSoupItem,mapGraphqlSoupItem,} from '../../../service-clients/service-storage/graphql-soup';-import { useInstructionsMdIdQuery } from '../../storage/instructions-md';import { createKeyedProjection } from '../create-keyed-projection';import { soupQueryExcludesDone } from '../excludes-done';import type { SoupAstBody, SoupAstItemsData, SoupAstParams } from '../items';@@ -74,10 +73,6 @@ export function createGraphqlSoupAstItemsQuery(}});const source = createSoupLiveQuery(input, options);- const instructions = useInstructionsMdIdQuery();- const instructionsId = createMemo(() =>- instructions.isSuccess ? instructions.data : undefined- );const sortMethod = createMemo(() => args().params.sort_method);const showForeign = createMemo(() => options().showSupportedForeignEntities);const pendingDeleteIds = usePendingGraphqlSoupDeleteIds();@@ -112,7 +107,6 @@ export function createGraphqlSoupAstItemsQuery(records,(row) => row.key,({ record, fetched }) => {- const id = instructionsId();const sort = sortMethod();const showSupportedForeignEntities = showForeign();const view = { emailView: input()?.emailView };@@ -129,10 +123,7 @@ export function createGraphqlSoupAstItemsQuery(entity: item? mapSoupPageToEntityList({ items: [item], next_cursor: undefined },- {- instructionsIdQuery: { isSuccess: id !== undefined, data: id },- showSupportedForeignEntities,- }+ { showSupportedForeignEntities })[0]: undefined,timestamp: fetchedItemdiff --git a/apps/web/src/lib/queries/soup/grouped/create-grouped-soup-queries.ts b/apps/web/src/lib/queries/soup/grouped/create-grouped-soup-queries.tsindex 77c314d5dc..158bdef3a6 100644--- a/apps/web/src/lib/queries/soup/grouped/create-grouped-soup-queries.ts+++ b/apps/web/src/lib/queries/soup/grouped/create-grouped-soup-queries.ts@@ -19,10 +19,8 @@ import type {import { soupKeys } from '@queries/soup/keys';import {isDisplayableSoupItem,- isInstructionsMdDoc,mapApiSoupItemToEntity,} from '@queries/soup/transform-utils';-import { useInstructionsMdIdQuery } from '@queries/storage/instructions-md';import { storageServiceClient } from '@service-storage/client';import type { SoupApiItem } from '@service-storage/generated/schemas';import type { InfiniteData } from '@tanstack/solid-query';@@ -113,12 +111,10 @@ function getNextGroupPageParam(lastPage: GroupQueryPage): string | null {export function createGroupedSoupQueries(args: CreateGroupedSoupQueriesArgs) {const usesGraphql = () => args.transport() === 'graphql';- const instructionsIdQuery = useInstructionsMdIdQuery();const queryClient = useQueryClient();const mapItemToEntity = (item: SoupApiItem) => {if (!isDisplayableSoupItem(item)) return;- if (isInstructionsMdDoc(item, instructionsIdQuery)) return;return mapApiSoupItemToEntity(item);};diff --git a/apps/web/src/lib/queries/soup/grouped/graphql/create-graphql-grouped-soup-queries.test.ts b/apps/web/src/lib/queries/soup/grouped/graphql/create-graphql-grouped-soup-queries.test.tsindex a58fc950a6..21f1952715 100644--- a/apps/web/src/lib/queries/soup/grouped/graphql/create-graphql-grouped-soup-queries.test.ts+++ b/apps/web/src/lib/queries/soup/grouped/graphql/create-graphql-grouped-soup-queries.test.ts@@ -29,13 +29,8 @@ vi.mock('@queries/soup/grouped/api', () => ({}),}));-vi.mock('@queries/storage/instructions-md', () => ({- useInstructionsMdIdQuery: vi.fn(() => ({})),-}));-vi.mock('@queries/soup/transform-utils', () => ({isDisplayableSoupItem: () => true,- isInstructionsMdDoc: () => false,mapApiSoupItemToEntity: (item: unknown) => item,mapSoupPageToEntityList: (page: { items: unknown[] }) => page.items,}));diff --git a/apps/web/src/lib/queries/soup/grouped/graphql/create-graphql-grouped-soup-queries.ts b/apps/web/src/lib/queries/soup/grouped/graphql/create-graphql-grouped-soup-queries.tsindex 1a1a99050f..820fb19083 100644--- a/apps/web/src/lib/queries/soup/grouped/graphql/create-graphql-grouped-soup-queries.ts+++ b/apps/web/src/lib/queries/soup/grouped/graphql/create-graphql-grouped-soup-queries.ts@@ -1,7 +1,6 @@import type { EntityData } from '@entity';import { keyArray } from '@solid-primitives/keyed';import { type Accessor, createMemo } from 'solid-js';-import { useInstructionsMdIdQuery } from '../../../storage/instructions-md';import { createKeyedProjection } from '../../create-keyed-projection';import type { GroupedSoupPaging } from '../../graphql/create-grouped-soup-live-query';import {@@ -11,7 +10,6 @@ import {import type { SoupApiItemFilter, SoupAstItemsGroupedPage } from '../../items';import {isDisplayableSoupItem,- isInstructionsMdDoc,mapApiSoupItemToEntity,} from '../../transform-utils';import type { GroupMeta } from '../types';@@ -35,7 +33,6 @@ type CreateGraphqlGroupedSoupQueriesArgs = {export function createGraphqlGroupedSoupQueries(args: CreateGraphqlGroupedSoupQueriesArgs) {- const instructions = useInstructionsMdIdQuery();const pendingDeleteIds = usePendingGraphqlSoupDeleteIds();const rows = createKeyedProjection(() => Object.entries(args.initialPage()?.items ?? {}),@@ -43,9 +40,7 @@ export function createGraphqlGroupedSoupQueries(([id, item]) => {const filter = args.itemFilter();const entity =- isDisplayableSoupItem(item) &&- (!filter || filter(item)) &&- !isInstructionsMdDoc(item, instructions)+ isDisplayableSoupItem(item) && (!filter || filter(item))? mapApiSoupItemToEntity(item): undefined;return { id, entity };diff --git a/apps/web/src/lib/queries/soup/items.transport-refetch.test.ts b/apps/web/src/lib/queries/soup/items.transport-refetch.test.tsindex fe1ee8a3ab..68eea9eea6 100644--- a/apps/web/src/lib/queries/soup/items.transport-refetch.test.ts+++ b/apps/web/src/lib/queries/soup/items.transport-refetch.test.ts@@ -55,7 +55,6 @@ vi.mock('@queries/soup/keys', () => ({}));vi.mock('@queries/soup/transform-utils', () => ({isDisplayableSoupItem: vi.fn(() => true),- isInstructionsMdDoc: vi.fn(() => false),mapApiSoupItemToEntity: vi.fn((item) => ({...item.data,touchedAt: item.touched_at,@@ -64,9 +63,6 @@ vi.mock('@queries/soup/transform-utils', () => ({page.items.map((item: { data: unknown }) => item.data)),}));-vi.mock('@queries/storage/instructions-md', () => ({- useInstructionsMdIdQuery: vi.fn(() => ({})),-}));vi.mock('@service-storage/client', () => ({storageServiceClient: { getSoupItems: vi.fn(), getSoupAstItems: fetchSoup },}));diff --git a/apps/web/src/lib/queries/soup/items.ts b/apps/web/src/lib/queries/soup/items.tsindex 25c8ffb3f9..5605cf4a33 100644--- a/apps/web/src/lib/queries/soup/items.ts+++ b/apps/web/src/lib/queries/soup/items.ts@@ -13,11 +13,9 @@ import type { GroupByField, GroupMeta } from '@queries/soup/grouped/types';import { soupKeys } from '@queries/soup/keys';import {isDisplayableSoupItem,- isInstructionsMdDoc,mapApiSoupItemToEntity,mapSoupPageToEntityList,} from '@queries/soup/transform-utils';-import { useInstructionsMdIdQuery } from '@queries/storage/instructions-md';import { storageServiceClient } from '@service-storage/client';import type { SoupApiItem } from '@service-storage/generated/schemas';import type { ApiEntityFilterAst } from '@service-storage/generated/schemas/apiEntityFilterAst';@@ -126,7 +124,6 @@ function soupItemsQueryOptions(args: SoupItemsQueryArgs,enabled: boolean | undefined,staleTime: StaleTime | undefined,- instructionsId: string | null | undefined,showSupportedForeignEntities: boolean | undefined) {const { params, body } = args;@@ -143,10 +140,7 @@ function soupItemsQueryOptions(getNextPageParam: (lastPage) => lastPage.next_cursor,select: (data) =>data.pages.flatMap((page) =>- mapSoupPageToEntityList(page, {- instructionsIdQuery: { isSuccess: true, data: instructionsId },- showSupportedForeignEntities,- })+ mapSoupPageToEntityList(page, { showSupportedForeignEntities })),enabled,staleTime,@@ -163,13 +157,11 @@ export const useSoupItemsQuery = (args: Accessor<SoupItemsQueryArgs>,options?: Accessor<SoupItemsQueryOptions>) => {- const instructionsIdQuery = useInstructionsMdIdQuery();return useInfiniteQuery(() =>soupItemsQueryOptions(args(),options?.().enabled,options?.().staleTime,- instructionsIdQuery.isSuccess ? instructionsIdQuery.data : undefined,options?.().showSupportedForeignEntities));@@ -245,11 +237,9 @@ function restSoupAstItemsQueryOptions(enabled: boolean | undefined,staleTime: StaleTime | undefined,meta: RestSoupAstItemsMeta,- instructionsId: string | null | undefined,showSupportedForeignEntities: boolean | undefined) {const { params, body, groupBy, transport } = args;- const instructionsIdQuery = { isSuccess: true, data: instructionsId };return infiniteQueryOptions({queryKey: soupKeys.astItems({ params, body, groupBy, transport }).queryKey,@@ -272,16 +262,10 @@ function restSoupAstItemsQueryOptions(for (const id of g.itemIds) {const item = itemsById[id];- let displayable = false;-- if (item.tag === 'foreignEntity') {- displayable =- showSupportedForeignEntities === true &&- item.data.foreignEntitySource === 'github_pull_request';- } else {- displayable =- item && !isInstructionsMdDoc(item, instructionsIdQuery);- }+ const displayable =+ item.tag !== 'foreignEntity' ||+ (showSupportedForeignEntities === true &&+ item.data.foreignEntitySource === 'github_pull_request');if (displayable && isDisplayableSoupItem(item)) {const mapped = mapApiSoupItemToEntity(item);entities.push(mapped);@@ -297,7 +281,7 @@ function restSoupAstItemsQueryOptions(return mapSoupPageToEntityList({ items: page.items, next_cursor: null },- { instructionsIdQuery, showSupportedForeignEntities }+ { showSupportedForeignEntities });});@@ -348,15 +332,12 @@ const useRestSoupAstItemsQuery = (args: Accessor<SoupAstItemsQueryArgs>,options?: Accessor<SoupItemsQueryOptions>) => {- const instructionsIdQuery = useInstructionsMdIdQuery();-return useInfiniteQuery(() =>restSoupAstItemsQueryOptions(args(),options?.().enabled !== false && !options?.().networkPaused,options?.().staleTime,options?.().meta,- instructionsIdQuery.isSuccess ? instructionsIdQuery.data : undefined,options?.().showSupportedForeignEntities));diff --git a/apps/web/src/lib/queries/soup/transform-utils.ts b/apps/web/src/lib/queries/soup/transform-utils.tsindex e86af2d46f..e4c8f1eb57 100644--- a/apps/web/src/lib/queries/soup/transform-utils.ts+++ b/apps/web/src/lib/queries/soup/transform-utils.ts@@ -47,7 +47,6 @@ import type {} from '@service-search/generated/models';import type {GithubPullRequest,- SoupApiItem,SoupAttachment,SoupCalendarEventTime,SoupPage,@@ -55,7 +54,6 @@ import type {} from '@service-storage/generated/schemas';import type { ChannelType } from '@service-storage/generated/schemas/channelType';import { formatDocumentName } from '@service-storage/util/filename';-import type { UseQueryResult } from '@tanstack/solid-query';import { differenceInMilliseconds } from 'date-fns';import { match } from 'ts-pattern';import { mapAgentSessionSearchResult } from './agent-session-search';@@ -1073,27 +1071,9 @@ const toCalendarEventTime = (? { kind: 'timed', startsAt: time.startsAt, endsAt: time.endsAt }: { kind: 'allDay', startDate: time.startDate, endDate: time.endDate };-export const isInstructionsMdDoc = (- item: SoupApiItem,- instructionsIdQuery: Pick<- UseQueryResult<string | null | undefined, Error>,- 'data' | 'isSuccess'- >-) => {- if (item.tag !== 'document') return false;-- if (!instructionsIdQuery.isSuccess) return false;-- return item.data.id === instructionsIdQuery.data;-};-export const mapSoupPageToEntityList: (data: SoupPage,options: {- instructionsIdQuery: Pick<- UseQueryResult<string | null | undefined, Error>,- 'data' | 'isSuccess'- >;showSupportedForeignEntities?: boolean;}) => SoupEntity[] = (data, options) => {@@ -1101,16 +1081,10 @@ export const mapSoupPageToEntityList: (.filter((item): item is DisplayableSoupItem => {if (!isDisplayableSoupItem(item)) return false;- if (item.tag === 'foreignEntity') {- return (- options.showSupportedForeignEntities === true &&- item.data.foreignEntitySource === 'github_pull_request'- );- }-return (- item.tag !== 'document' ||- !isInstructionsMdDoc(item, options.instructionsIdQuery)+ item.tag !== 'foreignEntity' ||+ (options.showSupportedForeignEntities === true &&+ item.data.foreignEntitySource === 'github_pull_request'));}).map(mapApiSoupItemToEntity);diff --git a/apps/web/src/lib/queries/storage/instructions-md.ts b/apps/web/src/lib/queries/storage/instructions-md.tsdeleted file mode 100644index 899f9324fd..0000000000--- a/apps/web/src/lib/queries/storage/instructions-md.ts+++ /dev/null@@ -1,137 +0,0 @@-import { createLexicalWrapper } from '@core/component/LexicalMarkdown/context/LexicalWrapperContext';-import {- getTextContent,- initializeEditorWithState,-} from '@core/component/LexicalMarkdown/utils';--import { useIsAuthenticated } from '@core/context/user';-import { storageServiceClient } from '@service-storage/client';-import { syncServiceClient } from '@service-sync/client';-import { useQuery } from '@tanstack/solid-query';-import { queryClient } from '../client';-import { instructionsMdKeys } from './keys';--export { default as AiInstructionsIcon } from '@phosphor/notepad.svg';--/**- * Returns the instructions md document id for the current user.- * Returns null if not yet created, throws otherwise.- */-const getInstructionsMdId = async (): Promise<string | null | undefined> => {- const getResult = await storageServiceClient.instructions.get();-- if (getResult.isOk()) {- const { documentId } = getResult.value;- return documentId;- }-- const error = getResult.error;- const [{ code }] = error;- if (code === 'NOT_FOUND') {- return null;- }-- console.error('Error getting instructionsMdId', error);- throw new Error('Error getting instructionsMdId');-};--function instructionsMdIdQueryOptions() {- return {- queryKey: instructionsMdKeys.id.queryKey,- queryFn: getInstructionsMdId,- staleTime: Infinity,- throwOnError: false,- retry: false,- retryOnMount: false,- };-}--/**- * useQuery hook for retrieving the instructions md document id.- * Returns null if not yet created, throws otherwise.- */-export function useInstructionsMdIdQuery() {- const authenticated = useIsAuthenticated();- return useQuery(() => ({- ...instructionsMdIdQueryOptions(),- enabled: authenticated() === true,- }));-}--const getInstructionsMdText = async (id: string | null | undefined) => {- if (!id) {- return null;- }-- const rawState = await syncServiceClient.getRaw({- documentId: id,- });-- const { editor } = createLexicalWrapper({- type: 'markdown',- namespace: 'instructions-md-text-extractor',- isInteractable: () => false,- });-- initializeEditorWithState(editor, rawState);-- const plaintext = getTextContent(editor);-- return plaintext;-};--// Cached callbacks outlive the caller; only the resolved id enters them.-function instructionsMdTextQueryOptions(- id: string | null | undefined,- enabled: boolean-) {- return {- // Use a placeholder key when id is null/undefined - query is disabled anyway- queryKey: id- ? instructionsMdKeys.text(id).queryKey- : ['instructionsMd', 'text', null],- queryFn: () => getInstructionsMdText(id),- enabled: enabled && !!id,- staleTime: Infinity,- throwOnError: false,- retry: false,- retryOnMount: false,- };-}--/** useQuery hook for retrieving the instructions md document text content */-export function useInstructionsMdTextQuery() {- const authenticated = useIsAuthenticated();- const idQuery = useInstructionsMdIdQuery();-- return useQuery(() =>- instructionsMdTextQueryOptions(- authenticated() === true && idQuery.isSuccess ? idQuery.data : undefined,- authenticated() === true && idQuery.isSuccess- )- );-}--/** Creates the instructions md document. Backend prevents duplicates */-export function useCreateInstructionsMd() {- return async () => {- const createResult = await storageServiceClient.instructions.create();- if (createResult.isOk()) {- const { documentId } = createResult.value;- queryClient.setQueryData(instructionsMdKeys.id.queryKey, documentId);- return documentId;- }- };-}--/** Hook to get a function that updates the instructions text in the query cache */-export function useUpdateInstructionsMdTextCache() {- const idQuery = useInstructionsMdIdQuery();-- return (text: string) => {- const id = idQuery.data;- if (id) {- queryClient.setQueryData(instructionsMdKeys.text(id).queryKey, text);- }- };-}diff --git a/apps/web/src/lib/queries/storage/keys.ts b/apps/web/src/lib/queries/storage/keys.tsindex 348f981d18..6a7af172a7 100644--- a/apps/web/src/lib/queries/storage/keys.ts+++ b/apps/web/src/lib/queries/storage/keys.ts@@ -146,13 +146,6 @@ export const savedDatabaseQueryKeys = createQueryKeys('saved-database-query', {definition: (queryId: string) => ({ queryKey: [queryId] }),});-export const instructionsMdKeys = createQueryKeys('instructionsMd', {- id: null,- text: (id: string) => ({- queryKey: [id],- }),-});-/*** @deprecated Use the specific key exports directly.*/diff --git a/apps/web/src/lib/service-clients/service-storage/client.ts b/apps/web/src/lib/service-clients/service-storage/client.tsindex 6ccce7cd65..8a017af30f 100644--- a/apps/web/src/lib/service-clients/service-storage/client.ts+++ b/apps/web/src/lib/service-clients/service-storage/client.ts@@ -73,7 +73,6 @@ import type { CreateDocumentRequest } from './generated/schemas/createDocumentReimport type { CreatedUserApiKey } from './generated/schemas/createdUserApiKey';import type { CreateEntityMentionRequest } from './generated/schemas/createEntityMentionRequest';import type { CreateEntityMentionResponse } from './generated/schemas/createEntityMentionResponse';-import type { CreateInstructionsDocumentResponse } from './generated/schemas/createInstructionsDocumentResponse';import type { CreateMarkdownDocumentRequest } from './generated/schemas/createMarkdownDocumentRequest';import type { CreateMarkdownHandler200 } from './generated/schemas/createMarkdownHandler200';import type { CreateProjectResponse } from './generated/schemas/createProjectResponse';@@ -112,7 +111,6 @@ import type { GetDocumentPermissionsResponseDataV2 } from './generated/schemas/gimport type { GetDocumentProcessingResultResponse } from './generated/schemas/getDocumentProcessingResultResponse';import type { GetDocumentResponseData } from './generated/schemas/getDocumentResponseData';import type { GetDocumentSearchResponse } from './generated/schemas/getDocumentSearchResponse';-import type { GetInstructionsDocumentResponse } from './generated/schemas/getInstructionsDocumentResponse';import type { GetOrCreateChannelResponse } from './generated/schemas/getOrCreateChannelResponse';import type { GetOrCreateDmRequest } from './generated/schemas/getOrCreateDmRequest';import type { GetOrCreatePrivateRequest } from './generated/schemas/getOrCreatePrivateRequest';@@ -2572,20 +2570,6 @@ export const storageServiceClient = {).map((result) => result.data);},- instructions: {- async create() {- return await dssFetch<CreateInstructionsDocumentResponse>(- '/instructions',- {- method: 'POST',- }- );- },- get: async () => {- return await dssFetch<GetInstructionsDocumentResponse>('/instructions');- },- },-views: {async getSavedViews() {return (await dssFetch<ViewsResponse>('/saved_views')).map(diff --git a/apps/web/src/lib/service-clients/service-storage/service.ts b/apps/web/src/lib/service-clients/service-storage/service.tsindex 9787ca9b98..cfaace699b 100644--- a/apps/web/src/lib/service-clients/service-storage/service.ts+++ b/apps/web/src/lib/service-clients/service-storage/service.ts@@ -283,22 +283,6 @@ const CollabSurfacesSvc = new Svc('Collab Surfaces Service')throws: withFetchErrors(),});-const InstructionsSvc = new Svc('Instructions Service')- .use('fetchErrors', fetchErrorsSvc)- .fn('create', {- description: schemas.createInstructionsHandlerResponse.description!,- args: {},- result: schemas.createInstructionsHandlerResponse.shape,- modifies: true,- throws: withFetchErrors(),- })- .fn('get', {- description: schemas.getInstructionsHandlerResponse.description!,- args: {},- result: schemas.getInstructionsHandlerResponse.shape,- throws: withFetchErrors(),- });-export type GetDocumentPermissionsTokenResponse = z.infer<typeof schemas.getDocumentPermissionsTokenResponse>;@@ -740,7 +724,6 @@ export const StorageService = new Svc('Document++ Storage Service API').use('projects', ProjectsSvc).use('permissionsTokens', PermissionsTokensSvc).use('collabSurfaces', CollabSurfacesSvc)- .use('instructions', InstructionsSvc).use('views', ViewsSvc).use('favorites', FavoritesSvc);