Skip to content

ui: add the Library, with prompts to send in a chat or use as a system message - #139

Draft
allozaur wants to merge 2 commits into
allozaur/feat/ui-mcp-skillsfrom
allozaur/feat/ui-library-prompts
Draft

allozaur wants to merge 2 commits into
allozaur/feat/ui-mcp-skillsfrom
allozaur/feat/ui-library-prompts

Conversation

@allozaur

@allozaur allozaur commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Overview

Llama Chat gets a Library page that keeps the prompts you reuse. A saved prompt is used the same way as an MCP prompt: /prompt lists both and sends the picked one with a message, and the System Message list of the + menu makes either one the chat's system message.

Additional information

Stacked on the MCP skills PR (#137). First of three Library PRs: the attachments of existing chats (#140) and a Skills tab (#141) follow on top.

A fresh take on the Library draft #29, rebuilt on this stack (MCP as an extension on SDK v2). #29, its branch and its stack are left as they are. Its Media tab, a mock-up, is not carried over: the next PR lists real attachments.

Choices made here that are still open:

  • A library prompt goes with a message as an attachment that carries its text, the same chip an MCP prompt has. It is not typed into the input.
  • /prompt is now a command of the chat form itself and lists every source. The MCP extension keeps only the form that asks for a prompt's arguments.
  • The Library page lists saved prompts only. MCP prompts show in /prompt and in the System Message list, not on the page.
  • A click on a prompt card starts a chat with the prompt attached. "As system message" is in the card's menu.
  • A phone gets a Library row at the top of its sidebar, which otherwise lists no actions any more.

Known gaps:

  • The prompts table is version 3 of the IndexedDB schema. The projects draft (ui: projects #28) adds its table at version 3 too, so whichever lands second takes the next version.
  • Copying a message does not carry a library prompt attached to it. An MCP prompt is carried.
  • The library has no export or import.
  • The demo script below was run locally. No video is uploaded yet.
How it works
  • Library page. A sidebar entry opens /library: the saved prompts as cards, with search, New prompt, Edit and Delete. A card's menu has "Send in a new chat" and "As system message".
  • One kind of item, several sources. A source lists its prompts, attaches one to the message being written, and gives one's text for a system message. The library is the app's own source. An extension adds another through a new promptSources extension point, and MCP contributes the prompts of its servers that way. The core does not import the MCP extension.
  • /prompt. The picker lists the library's prompts, then MCP's in the order of the servers. Every row names where the prompt comes from: Library, or the server. What is typed after /prompt searches the list.
  • System Message. The + menu's System Message entry is a submenu on a desktop and a page of the sheet on a phone: "Write new", then the prompts of each source under the source's name.
  • Arguments. An MCP prompt that takes arguments opens its form by the chat form, from either list. Filled in, the prompt is attached or becomes the system message. Closed, nothing happens.
  • In the chat. A system message made from a prompt shows as a prompt card. For a library prompt the card says "Modified" when the message and the prompt differ, to update the prompt or sync the message, and "Save as new" when the prompt is gone. A system message written by hand has an "Add to library" link.
  • New chat. A system message picked before the first message waits in the chat form as a chip that names its prompt, and is stored with the conversation on the first send.
What changed

Two commits:

  • ui: give the demo's fixture MCP server prompts. The Notes fixture server of the demo harness offers two prompts, one with an argument.
  • ui: add the Library, with prompts to send in a chat or use as its system message.
    • Data: a prompts table (DatabaseService, schema version 3), promptsStore, and a PROMPT attachment type. On a message it carries the prompt's text. On a system message it is a link: the message holds the text.
    • extensions/points/prompts.ts: PromptSource and PromptEntry, and the promptSources point. promptsStore.sources is the library followed by what extensions contribute.
    • Chat form: ChatFormPickerPrompts and the built-in /prompt command, usePromptList shared by the picker and the two System Message lists, ChatFormActionAddSystemMessageSubmenu, a System Message page in the phone's Add sheet, and the prompt chip.
    • chatStore.saveSystemPrompt takes the prompt a system message is made from, for a new chat and for an open one.
    • ChatMessageSystem: the prompt card, its status and the two dialogs, ported from ui: prompt library, a System message submenu and a Library page #29.
    • MCP extension: prompts.ts (the source), prompt-arguments.svelte.ts and the picker reduced to the arguments form. Its own /prompt command and prompt list are gone.
    • Library: the /library route, LibraryPrompts, LibraryPromptCard, the sidebar action.
    • Docs: the README's extension points, and the Mobile flows page for the sheet's new page.
Testing

In ui/apps/chat, on the tip of this branch:

  • npm run check and npm run lint clean.
  • 1,141 unit tests pass. New: the prompts store and the library as a source, the MCP source (listing in server order, attaching with and without arguments, a closed arguments form, the text for a system message, Enable MCP off), a prompt as an attachment from the chip to what the model reads, prompt drift, MCP prompt ids, the command order.
  • Client tests: all 80 files pass, in batches of ten. The ones that list the chat form's commands and drive /prompt now go through the shared picker, with a new case for the library alone and one for both sources.
  • Storybook tests pass, with stories for the prompt picker and for the arguments form.
  • In the browser, against a llama-server with LFM3-Omni-2B and a local MCP server with prompts: a prompt made on the Library page, a chat started from its card, /prompt listing the library's and the server's prompts, an MCP prompt with an argument attached and used as the system message, a library prompt as the system message of a new chat, and the sent conversation showing the prompt card and the chip. On a phone viewport: the Library row of the sidebar, the page, and the System Message page of the Add sheet.
  • The demo script below records locally.

Not run: the E2E suite, a production build.

Demo script

Uses the demo harness's fixture MCP servers. Needs no model: nothing is sent.

test.use({ settings: { enableMcp: true } });

test('demo', async ({ demo, page }) => {
	const input = page.getByRole('textbox', { name: 'Type a message...' });

	await demo.caption('The Library keeps the prompts you reuse');
	await demo.click(page.getByRole('button', { name: 'Expand navigation' }).first());
	await demo.click(page.getByRole('button', { name: 'Library' }));
	await demo.click(page.getByRole('button', { name: 'New prompt' }).first());
	await demo.type(page.getByLabel('Name'), 'Review a change');
	await demo.type(
		page.getByLabel('Prompt', { exact: true }),
		'Review this change for bugs first, then for style. Be brief.'
	);
	await demo.click(page.getByRole('button', { name: 'Add to library' }));

	await demo.caption('A card starts a chat with the prompt attached to the message');
	await demo.click(page.getByRole('button', { name: /Review a change/ }));
	await expect(page.getByText('Review this change for bugs first')).toBeVisible();
	await demo.pause(1200);

	await demo.caption('/prompt lists saved prompts next to MCP ones, each with its source');
	await demo.type(input, '/prompt');
	await demo.press('Enter');
	await expect(page.getByText('Summarize notes')).toBeVisible();
	await demo.pause(1500);
	await demo.click(page.getByRole('button', { name: /Meeting agenda/ }));
	await demo.type(page.getByLabel('topic'), 'the 1.0 release');
	await demo.click(page.getByRole('button', { name: 'Use Prompt' }));
	await demo.pause(1200);

	await demo.caption('The + menu makes any of them the system message');
	await demo.click(page.locator('.file-upload-button'));
	await demo.click(page.getByRole('menuitem', { name: 'System Message' }));
	await demo.click(page.getByRole('menuitem', { name: /Summarize notes/ }));
	await expect(page.getByText('System message: Summarize notes')).toBeVisible();
	await demo.pause(2000);
});

Requirements

@allozaur
allozaur added this pull request to stack #138 November 26, 2026 14:55
@github-actions github-actions Bot added documentation Improvements or additions to documentation server/ui labels Nov 26, 2026
@allozaur
allozaur force-pushed the allozaur/feat/ui-library-prompts branch from d71076f to 3927572 Compare November 26, 2026 15:29
@allozaur
allozaur force-pushed the allozaur/feat/ui-library-prompts branch from 3927572 to 48076bd Compare November 26, 2026 16:12
@allozaur
allozaur force-pushed the allozaur/feat/ui-library-prompts branch from 48076bd to e68f80c Compare November 26, 2026 16:19
@allozaur
allozaur force-pushed the allozaur/feat/ui-library-prompts branch 2 times, most recently from fc34db7 to 766ad20 Compare November 27, 2026 08:51
@allozaur
allozaur force-pushed the allozaur/feat/ui-library-prompts branch from 766ad20 to 9db2343 Compare November 27, 2026 09:04
The Notes fixture server offers two prompts, one of them with an argument, so a demo can show MCP prompts without a third-party server.

Assisted-by: Claude (Opus 5.5 Medium)
…tem message

Prompts are kept in IndexedDB and listed on a Library page. A prompt is one kind of item whatever its source: the library is the app's own, and an extension adds another through the new promptSources point, which MCP uses for the prompts of its servers. /prompt, now a command of the chat form itself, and the System message list of the + menu show the prompts of every source, each with where it comes from.

Assisted-by: Claude (Opus 5.5 Medium)
@allozaur
allozaur removed this pull request from stack #138 November 27, 2026 09:26
@allozaur
allozaur force-pushed the allozaur/feat/ui-library-prompts branch from 9db2343 to db8eb82 Compare November 27, 2026 09:26
@allozaur
allozaur added this pull request to stack #151 November 27, 2026 09:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation server/ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant