Skip to content

ui: open the context gauge panel on click as a popover - #32685

Merged
allozaur merged 2 commits into
ggml-org:masterfrom
allozaur:allozaur/fix/context-gauge-popover
Nov 21, 2026
Merged

allozaur merged 2 commits into
ggml-org:masterfrom
allozaur:allozaur/fix/context-gauge-popover

Conversation

@allozaur

@allozaur allozaur commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Overview

The context gauge in the chat form opens its details on click instead of on hover, and closes on a click outside or Escape, so it no longer pops up while the pointer passes over it.

Demo

Demo

Recorded at c4e839e; click the preview for the full video.

Additional information

What changed
  • On wider screens the gauge is a Popover.Trigger from @ggml-org/llama-ui/ui/popover, and the panel is its Popover.Content (side top). bits-ui handles the toggle, outside click, Escape, focus and placement, so the hand-made hover card goes away: the pointer handlers and grace timer in gauge-popup.svelte.ts, the document pointerdown listener, the measured position and context-gauge-popup.constants.ts.
  • The trigger is a real <button> with the accessible name "Context usage". bits-ui gives the content no role, so it gets role="dialog" and aria-label="Context" to match the trigger's aria-haspopup="dialog".
  • ContextGaugePopup.svelte is split into ContextGaugePanel.svelte (the content, unchanged in look) and ContextGaugeDrawer.svelte (the phone's drawer). The chat form renders the drawer only on phones; the phone's corner key toggles it with a tap, as before.
  • gauge-popup.svelte.ts keeps only the shared open state, used by both the popover and the drawer.
Testing

In ui/apps/chat, after npm ci:

  • npm run check and npm run lint pass.
  • tests/client/context-panel.svelte.test.ts (was context-panel-mobile): hover does not open the popover, click does, Escape and a click outside close it; the phone still shows the drawer.
  • The ChatFormContextGauge stories open the panel with a click and find it by its dialog role. Client (332), unit (850) and ChatForm story tests pass.
  • In Storybook: hover does nothing, click opens the panel above the dial with the same content, Tab + Enter opens it with focus inside, Escape closes it and returns focus to the dial. At a phone width a tap opens the drawer.
Demo script
test('Context gauge opens on click', async ({ demo, page }) => {
	const MODEL = 'unsloth/Qwen3.8-Flash-Next-GGUF:IQ4_XS';
	const picker = page
		.locator('form button[aria-haspopup="menu"]')
		.filter({ hasNotText: 'Add files' });
	const gauge = page.getByRole('button', { name: 'Context usage' });
	const panel = page.getByRole('dialog', { name: 'Context' });

	await demo.click(picker);
	await demo.click(page.getByRole('menu').locator(`[title="${MODEL}"]`).first());
	await demo.type(
		page.locator('form .cm-content').first(),
		'Name three uses of a lighthouse, one line each.'
	);
	await demo.press('Enter');
	await expect(page.getByRole('button', { name: /^Stop/ })).toHaveCount(0, { timeout: 60000 });
	await demo.pause(600);

	await demo.caption('Hover highlights the gauge but no longer opens its panel');
	await demo.hover(gauge);
	await demo.zoom(gauge, 3);
	await expect(panel).toHaveCount(0);

	await demo.caption('A click opens it');
	await demo.click(gauge);
	await expect(panel).toBeVisible();
	await demo.pause(2500);

	await demo.caption('A click outside closes it');
	await demo.click(page.getByRole('main').locator('p').first());
	await expect(panel).toHaveCount(0);
	await demo.pause(800);

	await demo.caption('From the keyboard, Enter opens it and Escape closes it');
	await gauge.focus();
	await demo.press('Enter');
	await expect(panel).toBeVisible();
	await demo.pause(2000);
	await demo.press('Escape');
	await expect(panel).toHaveCount(0);
	await demo.pause(1200);
});

Requirements

Assisted-by: Claude (Opus 5.5 Medium)
@github-actions github-actions Bot added server/ui video demo PR features a video demo recorded with the UI demo pipeline labels Nov 20, 2026
Assisted-by: Claude (Opus 5.5 Medium)
@allozaur
allozaur marked this pull request as ready for review November 21, 2026 00:23
@allozaur
allozaur requested a review from a team as a code owner November 21, 2026 00:23
@allozaur
allozaur merged commit 8032582 into ggml-org:master Nov 21, 2026
11 checks passed
Annieren pushed a commit to Annieren/llama.cpp-upstream that referenced this pull request Nov 23, 2026
* ui: open the context gauge panel on click as a popover

Assisted-by: Claude (Opus 5.5 Medium)

* ui: give the context gauge trigger the ghost button hover

Assisted-by: Claude (Opus 5.5 Medium)
Nindaleth pushed a commit to Nindaleth/llama.cpp that referenced this pull request Nov 26, 2026
* ui: open the context gauge panel on click as a popover

Assisted-by: Claude (Opus 5.5 Medium)

* ui: give the context gauge trigger the ghost button hover

Assisted-by: Claude (Opus 5.5 Medium)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server/ui video demo PR features a video demo recorded with the UI demo pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants