Skip to content

ui: turn the Hugging Face sharing into a connector for tools and gated models too - #134

Draft
allozaur wants to merge 2 commits into
allozaur/refactor/ui-mcp-extension-v2from
allozaur/feat/ui-huggingface-connector
Draft

allozaur wants to merge 2 commits into
allozaur/refactor/ui-mcp-extension-v2from
allozaur/feat/ui-huggingface-connector

Conversation

@allozaur

@allozaur allozaur commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Overview

The Hugging Face account becomes a connector: the sign-in that sharing uses also signs in the Hugging Face MCP server's tools and downloads gated models. Settings has a new Connectors section where the account shows.

Additional information

Third in the stack on this fork: on the MCP extension (#133), which sits on the sharing PR (#136). The sign-in, the @ggml-org/llama-huggingface package and the share flow come from #136; this PR moves them into an extension and adds what else the account is used for.

How connectors, the sign-in flows and MCP skills are best presented is still open. This layer keeps what was built before the stack was reordered, carried onto the new base.

Known gaps:

  • Not tried with a real account: the sign-in with the wider scopes, the Hugging Face MCP server accepting it, and a gated download.
  • Someone who signed in through a share (ui: share conversations to Hugging Face datasets as agent traces #136) holds a token without read-mcp and gated-repos. What the connector does with such a token, and how it asks to sign in again, was not looked at.
  • The server change (one commit) is C++ and can go upstream on its own. Without it, a download ignores the token. llama-server was not rebuilt on this base; the commit applied unchanged.
  • The sign-in popup, callback and BroadcastChannel handling in the package mirrors what the MCP sign-in below does; the two do not share code yet.
  • No demo yet. The script below was written before the reorder and has not been run on this base.
How it fits together
  • One account. The account, the sign-in and the Hub calls are the package's, from ui: share conversations to Hugging Face datasets as agent traces #136. This PR widens the scopes from openid profile contribute-repos to openid profile read-mcp gated-repos contribute-repos: the app can also read gated repos the account was given access to, and use the account's MCP settings.
  • A connector. Settings > Connectors lists accounts and services the app is connected to, one card each, in the settings dialog and in a phone's settings sheet. The Hugging Face card shows the account and what the sign-in covers, and takes the place of the account's row in Settings > General. The extension itself is switched under Settings > Extensions.
  • Sharing. The Share actions, the share dialog and the account move out of the core into the extension and reach it through extension points. For the user it is the share of ui: share conversations to Hugging Face datasets as agent traces #136: the dialog still asks for the sign-in when there is none.
  • Hugging Face tools. The Hugging Face MCP server uses the same authorization server and lists contribute-repos among its scopes, so the connector's token signs it in. The MCP extension asks connectors for headers on every request to a server one of them covers, so a renewed token is always used, and it leaves its own sign-in out for that server. A switch on the card adds the server to the MCP servers. When the account changes, MCP connects its servers again, unless Enable MCP is off.
  • Gated models. A model download passes the account's token to llama-server, which uses it for that download in place of its own. A gated model in Discover Models says what it takes.
What changed

One commit each:

  • server: take a Hugging Face token with a model download request. POST /models accepts an optional hf_token. The check of the repo uses it, and the download worker gets it through its environment, never its arguments, so it is neither logged nor listed; it is not stored. The token check also accepts an OAuth access token (hf_oauth_ and a JWS), which it used to drop as invalid.
  • ui: turn the Hugging Face sharing into a connector.
    • Seven extension points: conversationActions, messageActions, overlays, connectors, serverAuth, modelDownloadAuth and modelNotices. The MCP extension reads serverAuth.
    • The extension, in src/lib/extensions/huggingface/: who the app is, what a conversation is as a trace, and its contributions to the points above. What ui: share conversations to Hugging Face datasets as agent traces #136 wired into the core directly (the store, the share dialog's wrapper, the row in Settings > General, uiStore.conversationShare) is removed from the core.
    • The package gets HfAccountDialog, and a line on its sign-in form saying where else the token goes (a model download passes it to llama-server).
    • A build not made with VITE_PUBLIC_HUGGING_FACE=true leaves the extension out, and the package's sign-in, upload and dialogs with it (the sharing PR below explains the stand-in, -DLLAMA_UI_HUGGING_FACE=ON for llama-server and the image build argument). The stand-in now also covers HfAccountDialog and freshToken, which the extension reads.
Testing

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

  • npm run check: no errors. npm run lint: clean.
  • Unit tests: 1,061 pass. Client tests: 80 files, 422 tests pass, in one complete run.
  • Not run on this base: the package's own tests (they pass on ui: share conversations to Hugging Face datasets as agent traces #136, 32 tests, before this PR's two additions to it), the llama-server build, and anything by hand in a browser.

Before the reorder, on the older base: Extensions listed MCP and Hugging Face as active, Connectors showed the card, Share was contributed to conversations and messages, and made-up tokens showed that a request's token replaces the server's own in the check and in the download worker without reaching the log.

Not run: the E2E suite, Storybook, a production build and the CMake embed.

Demo script

Not recorded yet. It needs a visible browser window and a person signing in: demo.manual waits for that step and cuts it from the video (#130). The share is real: it creates a public dataset on the account that signs in.

test.describe(() => {
	test.use({ traces: ['agentic-debugging'] });

	test('Connect Hugging Face once, then share a conversation', async ({ demo, page }) => {
		// a dataset of its own per recording: the sign-in may only write to datasets it created
		const name = `llama-chat-demo-${Date.now().toString(36)}`;

		await demo.click(page.getByLabel('Expand navigation'));
		await demo.click(page.getByRole('button', { name: /^Settings/ }).first());

		const settings = page.getByRole('dialog', { name: 'Settings' });

		await demo.click(settings.getByRole('button', { exact: true, name: 'Connectors' }));
		await demo.caption('Connect a Hugging Face account, once');
		await demo.click(settings.getByRole('button', { name: 'Sign in with Hugging Face' }));
		// a refused sign-in shows why in place of the account: stop there instead of waiting it out
		await demo.manual(
			'sign in to Hugging Face and authorize Llama Chat in the popup',
			settings.getByText('Signed in as').or(settings.locator('.text-destructive'))
		);
		await expect(settings.getByText('Signed in as')).toBeVisible();
		await demo.caption('One sign-in for tools, sharing and gated models');
		await demo.hover(settings.getByText('Share conversations'), 1200);
		await demo.click(settings.getByRole('button', { name: 'Close' }));

		await demo.click(page.getByRole('button', { exact: true, name: 'Fix the flaky cache tests' }));
		await expect(page.getByRole('main')).toContainText('All 48 cache tests pass now');
		await demo.click(page.getByRole('button', { name: 'Share' }).last());

		const dialog = page.getByRole('alertdialog');

		await expect(dialog.getByText('Signed in as')).toBeVisible();
		await demo.caption('Sharing needs no second sign-in');
		await demo.click(dialog.getByLabel('Whole conversation'));

		// nothing was shared from this browser yet, so the dialog asks for the name of a new dataset;
		// the field suggests one: replace it, keeping the account it starts with
		const field = dialog.getByLabel('New dataset name');
		const owner = (await field.inputValue()).split('/')[0];

		await demo.click(field, 200);
		await field.press('ControlOrMeta+a');
		await field.pressSequentially(`${owner}/${name}`, { delay: 35 });
		await demo.pause(500);
		await demo.click(dialog.getByRole('button', { exact: true, name: 'Share' }), 1200);

		const link = dialog.getByRole('link', { name: 'Open on Hugging Face' });

		// the Hub answers within seconds; the long wait is for a slow day
		await expect(link).toBeVisible({ timeout: 90000 });
		await demo.hover(link, 900);

		const href = await link.getAttribute('href');

		await demo.visit(href!, page.getByText(name).first(), 3000);
		await demo.caption('The trace, in the trace viewer on the Hub');
	});
});

Requirements

@allozaur
allozaur added this pull request to stack #135 November 25, 2026 18:38
@github-actions github-actions Bot added documentation Improvements or additions to documentation devops server server/ui labels Nov 25, 2026
@allozaur
allozaur force-pushed the allozaur/feat/ui-huggingface-connector branch from dd2028b to c838ac3 Compare November 25, 2026 19:05
@allozaur
allozaur removed this pull request from stack #135 November 26, 2026 14:37
@allozaur
allozaur force-pushed the allozaur/feat/ui-huggingface-connector branch from c838ac3 to f939c98 Compare November 26, 2026 14:37
@allozaur
allozaur added this pull request to stack #138 November 26, 2026 14:37
@allozaur allozaur changed the title ui: add the Hugging Face connector: one sign-in for sharing, Hugging Face tools and gated models ui: turn the Hugging Face sharing into a connector for tools and gated models too Nov 26, 2026
@allozaur
allozaur force-pushed the allozaur/feat/ui-huggingface-connector branch from f939c98 to fc0f7c0 Compare November 26, 2026 15:24
@allozaur
allozaur force-pushed the allozaur/feat/ui-huggingface-connector branch from fc0f7c0 to cc9c93e Compare November 26, 2026 16:08
@allozaur
allozaur force-pushed the allozaur/feat/ui-huggingface-connector branch from cc9c93e to 01ad8a2 Compare November 26, 2026 16:18
@allozaur
allozaur force-pushed the allozaur/feat/ui-huggingface-connector branch 3 times, most recently from 31980ff to 3d2de35 Compare November 27, 2026 09:04
POST /models accepts an optional hf_token, used for that download in
place of the server's own (--hf-token): the check of the repo uses it,
and the download worker gets it through its environment, never its
arguments, so it is neither logged nor listed. It is not stored.

A client that knows who is asking, such as Llama Chat with a Hugging Face
sign-in, can so download a gated model the server's own token cannot
reach.

The token check also accepts the access token of an OAuth sign-in
(hf_oauth_ and a JWS), which it used to drop as invalid.

Assisted-by: Claude (Opus 5.5 Medium)
The Hugging Face account becomes a connector, an extension built on
@ggml-org/llama-huggingface: one sign-in ("Sign in with Hugging Face", or a
pasted access token) and what it is used for.

- Share: the Share actions, the share dialog and the account move out of
  the core into the extension, and reach it through new extension points
  (conversationActions, messageActions, overlays). The account's row in
  Settings > General gives way to the connector's card.
- Connectors: Settings gets a Connectors section with one card per
  connector (the connectors point), in the dialog and in a phone's sheet.
- Hugging Face tools: the Hugging Face MCP server is signed in with the
  same account (the serverAuth point, which MCP reads in place of its own
  sign-in for a covered server), and a switch on the card adds it to the
  MCP servers. The sign-in asks for read-mcp too.
- Gated models: a model download passes the account's token to
  llama-server (modelDownloadAuth), and a gated model in Discover Models
  says what it takes (modelNotices). The sign-in asks for gated-repos too.

A build made with VITE_PUBLIC_HUGGING_FACE=false leaves the extension out.

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-huggingface-connector branch from 3d2de35 to 4aa271b 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

devops documentation Improvements or additions to documentation server/ui server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant