diff --git a/packages/patterns/chatbot-note.tsx b/packages/patterns/chatbot-note.tsx index ca0eae139..c96ff8ad1 100644 --- a/packages/patterns/chatbot-note.tsx +++ b/packages/patterns/chatbot-note.tsx @@ -26,10 +26,10 @@ import { import Chat from "./chatbot.tsx"; -type Charm = { +export type MentionableCharm = { [NAME]: string; content?: string; - mentioned?: Charm[]; + mentioned?: MentionableCharm[]; }; type NoteResult = { @@ -38,13 +38,13 @@ type NoteResult = { export type NoteInput = { content: Default; - allCharms: Cell; + allCharms: Cell; }; const handleCharmLinkClick = handler< { detail: { - charm: Cell; + charm: Cell; }; }, Record @@ -72,7 +72,7 @@ export const Note = recipe( ); const handleCharmLinkClicked = handler( - (_: any, { charm }: { charm: Cell }) => { + (_: any, { charm }: { charm: Cell }) => { return navigateTo(charm); }, ); @@ -82,13 +82,13 @@ type LLMTestInput = { messages: Default, []>; expandChat: Default; content: Default; - allCharms: Cell; + allCharms: Cell; }; type LLMTestResult = { messages: Default, []>; - mentioned: Default, []>; - backlinks: Default, []>; + mentioned: Default, []>; + backlinks: Default, []>; content: Default; }; @@ -163,7 +163,7 @@ export default recipe( const chat = Chat({ messages, tools }); const { addMessage, cancelGeneration, pending } = chat; - const mentioned = cell([]); + const mentioned = cell([]); // Must use JSONSchema here, CTS doesn't work correctly. See CT-901 const computeBacklinks = lift( @@ -179,7 +179,7 @@ export default recipe( items: { type: "object" }, } as JSONSchema, ({ allCharms, content }) => { - const cs: Charm[] = allCharms.get(); + const cs: MentionableCharm[] = allCharms.get(); if (!cs) return []; const self = cs.find((c) => c.content === content.get()); @@ -194,7 +194,7 @@ export default recipe( }, ); - const backlinks: OpaqueRef = computeBacklinks({ + const backlinks: OpaqueRef = computeBacklinks({ allCharms, content, }); @@ -230,7 +230,7 @@ export default recipe(
Mentioned Charms - {mentioned.map((charm: Charm) => ( + {mentioned.map((charm: MentionableCharm) => ( {charm[NAME]} @@ -240,7 +240,7 @@ export default recipe(
Backlinks - {backlinks.map((charm: Charm) => ( + {backlinks.map((charm: MentionableCharm) => ( {charm[NAME]} diff --git a/packages/patterns/default-app.tsx b/packages/patterns/default-app.tsx index ee391bb07..0b11573ba 100644 --- a/packages/patterns/default-app.tsx +++ b/packages/patterns/default-app.tsx @@ -7,6 +7,7 @@ import { handler, NAME, navigateTo, + OpaqueRef, recipe, str, UI, @@ -16,8 +17,11 @@ import { import Chatbot from "./chatbot.tsx"; import ChatbotTools from "./chatbot-tools.tsx"; import ChatbotOutliner from "./chatbot-outliner.tsx"; -import ChatbotNote from "./chatbot-note.tsx"; -import Note from "./note.tsx"; +import { + default as ChatbotNote, + type MentionableCharm, +} from "./chatbot-note.tsx"; +import { default as Note } from "./note.tsx"; export type Charm = { [NAME]?: string; @@ -61,11 +65,64 @@ const removeCharm = handler< } }); -const spawnPattern = (recipe: any, params: any) => - handler, Record>((event, state) => { - const charm = recipe(params); - return navigateTo(charm); - }); +const spawnChatbot = handler< + Record, + Record +>((_, state) => { + return navigateTo(Chatbot({ + messages: [], + tools: undefined, + })); +}); + +const spawnChatbotTools = handler< + Record, + Record +>((_, state) => { + return navigateTo(ChatbotTools({ + title: "Chatbot Tools", + messages: [], + list: [], + })); +}); + +const spawnChatbotOutliner = handler< + Record, + { allCharms: Cell } +>((_, state) => { + return navigateTo(ChatbotOutliner({ + title: "Chatbot Outliner", + expandChat: false, + messages: [], + outline: { + root: { body: "", children: [], attachments: [] }, + }, + allCharms: state.allCharms, + })); +}); + +const spawnChatbotNote = handler< + Record, + { allCharms: Cell } +>((_, state) => { + return navigateTo(ChatbotNote({ + title: "New Note", + content: "", + expandChat: false, + messages: [], + allCharms: state.allCharms, + })); +}); + +const spawnNote = handler< + Record, + Record +>((_, state) => { + return navigateTo(Note({ + title: "New Note", + content: "", + })); +}); export default recipe( "DefaultCharmList", @@ -79,47 +136,32 @@ export default recipe(

Quicklaunch:

💬 Chatbot 🔧 Chatbot Tools 📝 Chatbot Outliner , + })} > 🤖 Chatbot Note 📄 Note