@bevel-software/platform-core-frontend 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +2 -2
  2. package/src/{modules/access/__tests__ → __tests__}/tailwindDeclarations.ts +1 -1
  3. package/src/__tests__/title-ink-room.ts +30 -0
  4. package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +1 -1
  5. package/src/modules/audit/__tests__/AuditLogPage.test.tsx +35 -2
  6. package/src/modules/audit/components/AuditEventsPanel.tsx +2 -1
  7. package/src/modules/audit/components/AuditLogPage.tsx +20 -12
  8. package/src/modules/audit/services/audit.api.ts +6 -4
  9. package/src/modules/embed/__tests__/EmbedView.test.tsx +20 -0
  10. package/src/modules/embed/components/EmbedView.tsx +2 -0
  11. package/src/modules/git/index.ts +3 -0
  12. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +50 -0
  13. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +37 -0
  14. package/src/modules/library/__tests__/SkillPage.test.tsx +44 -1
  15. package/src/modules/library/__tests__/ToolPage.test.tsx +8 -0
  16. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +25 -0
  17. package/src/modules/library/components/LibraryPage.tsx +2 -2
  18. package/src/modules/library/components/LockedPluginView.tsx +2 -2
  19. package/src/modules/library/components/PersonalPluginPage.tsx +5 -4
  20. package/src/modules/library/components/PluginPage.tsx +7 -4
  21. package/src/modules/library/components/skill-page/SkillFilePane.tsx +11 -1
  22. package/src/modules/library/components/skill-page/SkillPage.tsx +12 -2
  23. package/src/modules/library/components/tool-page/ToolPage.tsx +8 -4
  24. package/src/modules/library/routes/WorkspaceItemRoute.tsx +8 -2
  25. package/src/modules/workspace/components/FileViewer.tsx +6 -1
  26. package/src/modules/workspace/components/KbPageHeader.tsx +7 -4
  27. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +7 -0
  28. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +164 -4
  29. package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.test.tsx +1 -0
  30. package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.tools.test.tsx +272 -0
  31. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +1 -0
  32. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +44 -3
  33. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +62 -0
  34. package/src/modules/workspace/components/renderers/__tests__/htmlToolBridge.test.ts +232 -0
  35. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +29 -1
  36. package/src/modules/workspace/components/renderers/__tests__/kbGraphLoader.test.tsx +1 -0
  37. package/src/modules/workspace/components/renderers/htmlSandbox.ts +92 -1
  38. package/src/modules/workspace/components/renderers/htmlToolBridge.ts +383 -0
  39. package/src/modules/workspace/components/renderers/rendererSurface.ts +6 -0
  40. package/src/modules/workspace/index.ts +9 -2
  41. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +7 -0
  42. package/src/modules/workspace/routing/kb-routes.ts +33 -1
  43. package/src/shared/theme/header.ts +20 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bevel-software/platform-core-frontend",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "Open-source core UI of the Bevel platform (raw TS/TSX source): workspace explorer/viewer, branches & change requests, Library, secrets, tools, access control.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -45,7 +45,7 @@
45
45
  "tailwind-merge": "^3.5.0",
46
46
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
47
47
  "yaml": "^2.9.0",
48
- "@bevel-software/platform-shared": "0.30.0"
48
+ "@bevel-software/platform-shared": "0.31.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@modelcontextprotocol/client": "^2.3.1",
@@ -30,7 +30,7 @@ const require = createRequire(import.meta.url);
30
30
  * that exact form into an asset URL (`http://localhost/src/index.css`), which
31
31
  * is not a path this can read.
32
32
  */
33
- const APP_STYLESHEET = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../index.css');
33
+ const APP_STYLESHEET = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../index.css');
34
34
  const TAILWIND_ROOT = path.dirname(require.resolve('tailwindcss/package.json'));
35
35
 
36
36
  /** A rule's declarations, keyed by CSS property: `{ 'max-width': '100%' }`. */
@@ -0,0 +1,30 @@
1
+ import { expect } from 'vitest';
2
+ import { TITLE_INK_ROOM } from '../shared/theme/header';
3
+
4
+ /**
5
+ * The page-title contract every header band's test asserts: the title keeps
6
+ * the tails of its g, y and p while still truncating with an ellipsis.
7
+ *
8
+ * happy-dom lays nothing out, so clipping cannot be measured here. What can
9
+ * be checked is the shape that makes it impossible: the title truncates
10
+ * (`truncate` — `overflow: hidden`, which is what clips), and EVERY box that
11
+ * clips between the title and the band carries `TITLE_INK_ROOM` — the title
12
+ * itself and any `overflow-hidden` wrapper it is grouped in. A wrapper that
13
+ * lacks it clips to the title's line box and cuts the tails off one box
14
+ * further out, which is exactly what this guards against. The geometry of
15
+ * the class (padding that is handed back as margin) is pinned once, against
16
+ * the compiled stylesheet, in `HeaderAlignment.test.tsx`.
17
+ */
18
+ export function expectTitleKeepsItsInk(band: HTMLElement): void {
19
+ const title = band.querySelector('h1');
20
+ expect(title, 'the band holds the page title').not.toBeNull();
21
+ const room = TITLE_INK_ROOM.split(/\s+/);
22
+ expect([...title!.classList], 'the title truncates with an ellipsis').toContain('truncate');
23
+ expect([...title!.classList], 'the title has room for its tails').toEqual(expect.arrayContaining(room));
24
+ for (let box = title!.parentElement; box && box !== band; box = box.parentElement) {
25
+ if (!box.classList.contains('overflow-hidden')) continue;
26
+ expect([...box.classList], `a wrapper that clips the title (${box.className}) has the same room`).toEqual(
27
+ expect.arrayContaining(room),
28
+ );
29
+ }
30
+ }
@@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
  import type { FileTreeEntry } from '@bevel-software/platform-shared';
5
5
  import type { AccessResponse } from '../api';
6
- import { declarationsOf } from './tailwindDeclarations';
6
+ import { declarationsOf } from '../../../__tests__/tailwindDeclarations';
7
7
 
8
8
  // --- Mock the API module ----------------------------------------------------
9
9
  const api = vi.hoisted(() => ({
@@ -163,10 +163,10 @@ describe('AuditLogPage', () => {
163
163
  await waitFor(() => expect(screen.getByText('CI pipeline')).toBeInTheDocument());
164
164
 
165
165
  expect(listPrincipals).toHaveBeenCalledWith('all');
166
- const alice = screen.getByRole('region', { name: 'Agents and keys for alice@example.com' });
166
+ const alice = screen.getByRole('region', { name: 'Agents, keys and pages for alice@example.com' });
167
167
  expect(within(alice).getByText('Alice')).toBeInTheDocument();
168
168
  expect(within(alice).getByText('CI pipeline')).toBeInTheDocument();
169
- const bob = screen.getByRole('region', { name: 'Agents and keys for bob@example.com' });
169
+ const bob = screen.getByRole('region', { name: 'Agents, keys and pages for bob@example.com' });
170
170
  expect(within(bob).getByText('Claude link')).toBeInTheDocument();
171
171
  expect(within(bob).queryByText('Old script')).not.toBeInTheDocument();
172
172
  expect(screen.getByText(/2 accounts · 3 live · 1 revoked/)).toBeInTheDocument();
@@ -187,6 +187,39 @@ describe('AuditLogPage', () => {
187
187
  expect(screen.getByText(/18 events/)).toBeInTheDocument();
188
188
  });
189
189
 
190
+ it("lists a page under its viewer by its path, with its refused calls, and offers nothing to revoke", async () => {
191
+ const page: AuditPrincipal = {
192
+ kind: 'page',
193
+ id: 'cGFnZQ',
194
+ label: 'Dashboards/Roadmap.html',
195
+ createdAt: NOW - DAY,
196
+ lastUsedAt: NOW - 60 * 1000,
197
+ revokedAt: null,
198
+ revokedBy: null,
199
+ eventCount: 2,
200
+ user: ALICE,
201
+ };
202
+ vi.mocked(listPrincipals).mockResolvedValue([page]);
203
+ vi.mocked(listEvents).mockResolvedValue({
204
+ events: [
205
+ { id: 'e1', kind: 'capability', manual: null, name: 'read_file', outcome: 'ok', at: NOW - 2 * 60 * 1000 },
206
+ { id: 'e2', kind: 'capability', manual: null, name: 'edit_file', outcome: 'refused', at: NOW - 60 * 1000 },
207
+ ],
208
+ total: 2,
209
+ nextCursor: null,
210
+ });
211
+ renderPage();
212
+ const row = await screen.findByRole('button', { name: /Dashboards\/Roadmap\.html/, expanded: false });
213
+ expect(within(row).getByText('Page')).toBeInTheDocument();
214
+ // A page is not a live connection: counted apart from them.
215
+ expect(screen.getByText(/0 live · 1 page/)).toBeInTheDocument();
216
+ expect(screen.queryByRole('button', { name: /Revoke/ })).not.toBeInTheDocument();
217
+ await userEvent.click(row);
218
+ await waitFor(() => expect(screen.getByText('refused')).toBeInTheDocument());
219
+ expect(listEvents).toHaveBeenCalledWith('page', 'cGFnZQ', { limit: 50 });
220
+ expect(screen.getByText('edit_file')).toBeInTheDocument();
221
+ });
222
+
190
223
  it('expands a row to its events once, keeps them across a collapse, and filters them', async () => {
191
224
  vi.mocked(listPrincipals).mockResolvedValue([ALICE_CLAUDE]);
192
225
  renderPage();
@@ -31,6 +31,7 @@ const OUTCOME: Record<AgentEventOutcome, { tone: 'ok' | 'danger' | 'wait'; label
31
31
  ok: { tone: 'ok', label: 'ok' },
32
32
  error: { tone: 'danger', label: 'error' },
33
33
  denied: { tone: 'wait', label: 'needs sign-in' },
34
+ refused: { tone: 'danger', label: 'refused' },
34
35
  };
35
36
 
36
37
  type TypeFilter = 'all' | AgentEventKind;
@@ -198,7 +199,7 @@ export function AuditEventsPanel({
198
199
  if (events.length === 0) {
199
200
  return (
200
201
  <div className="text-detail text-ink-muted text-center py-3">
201
- Nothing called yet. Events appear here the first time this {kind === 'agent' ? 'agent' : 'key'} uses a
202
+ Nothing called yet. Events appear here the first time this {kind === 'agent' ? 'agent' : kind === 'page' ? 'page' : 'key'} uses a
202
203
  tool, a skill, or a Hexis capability.
203
204
  </div>
204
205
  );
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
- import { Bot, ChevronRight, KeyRound } from 'lucide-react';
2
+ import { Bot, ChevronRight, FileCode2, KeyRound } from 'lucide-react';
3
3
  import { PageShell } from '../../../shared/components/PageShell';
4
4
  import { Dialog } from '../../../shared/components/Dialog';
5
5
  import { Badge, Banner, Button } from '../../../shared/components';
@@ -27,6 +27,7 @@ function formatAbsolute(ts: number | null): string | undefined {
27
27
  /** What a row is, in the words the page uses: an OAuth agent, a Claude link, or a hand-made key. */
28
28
  function kindLabel(p: AuditPrincipal): string {
29
29
  if (p.kind === 'agent') return 'Agent · OAuth';
30
+ if (p.kind === 'page') return 'Page';
30
31
  return p.keyKind === GITHUB_LINK_KIND ? 'Claude link' : 'Connection key';
31
32
  }
32
33
 
@@ -99,8 +100,12 @@ export function AuditLogPage() {
99
100
  () => (principals ? groupByAccount(principals, { includeRevoked: showRevoked, query: isAdmin ? query : '' }) : []),
100
101
  [principals, showRevoked, query, isAdmin],
101
102
  );
102
- const liveCount = principals?.filter((p) => p.revokedAt === null).length ?? 0;
103
- const revokedCount = (principals?.length ?? 0) - liveCount;
103
+ // A page is never connected or revoked — it is a person's view of a file —
104
+ // so it is counted apart from the agents and keys that are.
105
+ const connections = principals?.filter((p) => p.kind !== 'page') ?? [];
106
+ const liveCount = connections.filter((p) => p.revokedAt === null).length;
107
+ const revokedCount = connections.length - liveCount;
108
+ const pageCount = (principals?.length ?? 0) - connections.length;
104
109
  const accountCount = useMemo(() => new Set(principals?.map((p) => p.user.id)).size, [principals]);
105
110
 
106
111
  const toggle = (key: string) => {
@@ -147,8 +152,8 @@ export function AuditLogPage() {
147
152
  <div className="space-y-4">
148
153
  <p className="text-xs text-ink-muted leading-snug max-w-[65ch]">
149
154
  {isAdmin
150
- ? 'Every agent and connection key on this deployment, per account. Open one to see what it called and when. Revoking cuts the agent off immediately; the row stays so its history remains visible.'
151
- : 'The agents and connection keys connected to your account. Open one to see what it called and when. Revoking cuts the agent off immediately; it can reconnect by signing in again.'}
155
+ ? 'Every agent and connection key on this deployment, and every page whose script called tools, per account. Open one to see what it called and when. Revoking cuts the agent off immediately; the row stays so its history remains visible.'
156
+ : 'The agents and connection keys connected to your account, and the pages whose scripts called tools as you. Open one to see what it called and when. Revoking cuts the agent off immediately; it can reconnect by signing in again.'}
152
157
  </p>
153
158
 
154
159
  {error && (
@@ -163,6 +168,7 @@ export function AuditLogPage() {
163
168
  {isAdmin && `${accountCount} ${accountCount === 1 ? 'account' : 'accounts'} · `}
164
169
  {liveCount} live
165
170
  {revokedCount > 0 && ` · ${revokedCount} revoked`}
171
+ {pageCount > 0 && ` · ${pageCount} ${pageCount === 1 ? 'page' : 'pages'}`}
166
172
  </span>
167
173
  <div className="flex flex-wrap items-center gap-3">
168
174
  {isAdmin && (
@@ -194,18 +200,18 @@ export function AuditLogPage() {
194
200
  <div className="text-xs text-ink-muted">
195
201
  {principals.length === 0
196
202
  ? isAdmin
197
- ? 'No agents or connection keys on this deployment.'
203
+ ? 'No agents, connection keys or pages on this deployment.'
198
204
  : 'Nothing connected to your account yet. Connect an agent from External agent access.'
199
205
  : query.trim()
200
206
  ? 'Nothing matches that filter.'
201
- : 'No live agents or connection keys.'}
207
+ : 'No live agents, connection keys or pages.'}
202
208
  </div>
203
209
  ) : (
204
210
  <div className="space-y-5">
205
211
  {groups.map((group) => {
206
- const live = group.principals.filter((p) => p.revokedAt === null).length;
212
+ const live = group.principals.filter((p) => p.kind !== 'page' && p.revokedAt === null).length;
207
213
  return (
208
- <section key={group.user.id} aria-label={`Agents and keys for ${group.user.email}`}>
214
+ <section key={group.user.id} aria-label={`Agents, keys and pages for ${group.user.email}`}>
209
215
  {isAdmin && (
210
216
  <div className="flex items-baseline gap-2 px-1 pb-1.5">
211
217
  <span className="text-sm font-medium truncate">{group.user.name}</span>
@@ -219,7 +225,7 @@ export function AuditLogPage() {
219
225
  const revoked = p.revokedAt !== null;
220
226
  const open = !!expanded[key];
221
227
  const panelId = `audit-events-${p.kind}-${p.id}`;
222
- const Icon = p.kind === 'agent' ? Bot : KeyRound;
228
+ const Icon = p.kind === 'agent' ? Bot : p.kind === 'page' ? FileCode2 : KeyRound;
223
229
  return (
224
230
  <li key={key}>
225
231
  {/* The WHOLE row opens the events, chevron at its far edge, the
@@ -271,7 +277,8 @@ export function AuditLogPage() {
271
277
  </span>
272
278
  <span className="block text-meta text-ink-muted">
273
279
  <span title={formatAbsolute(p.createdAt)}>
274
- {p.kind === 'agent' ? 'Connected' : 'Created'} {formatRelative(p.createdAt)}
280
+ {p.kind === 'agent' ? 'Connected' : p.kind === 'page' ? 'First call' : 'Created'}{' '}
281
+ {formatRelative(p.createdAt)}
275
282
  </span>
276
283
  {' · '}
277
284
  <span title={formatAbsolute(p.lastUsedAt)}>Last used {formatRelative(p.lastUsedAt)}</span>
@@ -286,7 +293,8 @@ export function AuditLogPage() {
286
293
  </span>
287
294
  </span>
288
295
  </button>
289
- {!revoked && (
296
+ {/* A page has nothing to revoke: it acts only while its viewer has it open. */}
297
+ {!revoked && p.kind !== 'page' && (
290
298
  <Button
291
299
  variant="danger"
292
300
  size="sm"
@@ -7,13 +7,14 @@ import { authFetch } from '../../../lib/api';
7
7
  * rather than shared, like the admin inbox's, because the feature is small.
8
8
  */
9
9
 
10
- export type AuditPrincipalKind = 'key' | 'agent';
10
+ /** `page`: an HTML page of the knowledge base whose script called tools as the person viewing it. */
11
+ export type AuditPrincipalKind = 'key' | 'agent' | 'page';
11
12
 
12
- /** One row of the Audit log: an agent connection or a connection key, with its owner. */
13
+ /** One row of the Audit log: an agent connection, a connection key or a page, with its owner. */
13
14
  export interface AuditPrincipal {
14
15
  kind: AuditPrincipalKind;
15
16
  id: string;
16
- /** The key's label, or the agent's registered name ("Claude"). */
17
+ /** The key's label, the agent's registered name ("Claude"), or the page's knowledge-base path. */
17
18
  label: string;
18
19
  /** For a key: `key` by hand, `github-link` for a Claude link. Absent for an agent. */
19
20
  keyKind?: string;
@@ -31,7 +32,8 @@ export interface AuditPrincipal {
31
32
  }
32
33
 
33
34
  export type AgentEventKind = 'capability' | 'tool' | 'skill';
34
- export type AgentEventOutcome = 'ok' | 'error' | 'denied';
35
+ /** `denied`: the sign-in for the tool was missing. `refused`: the viewer denied a page's request to write. */
36
+ export type AgentEventOutcome = 'ok' | 'error' | 'denied' | 'refused';
35
37
 
36
38
  export interface AgentEvent {
37
39
  id: string;
@@ -550,6 +550,26 @@ describe('the renderer', () => {
550
550
  expect((await screen.findByTestId('sizing-reader')).textContent).toBe('false');
551
551
  });
552
552
 
553
+ it("opens a page on its FILE PAGE in a new tab by an address that asks for it — a skill's page would claim the bare one", async () => {
554
+ api.loadEmbed.mockResolvedValue(
555
+ view({ repoRelative: 'Skills/qa-bridge/view.html', workspacePath: `${KB}/Skills/qa-bridge/view.html`, content: '<p>qa</p>' }),
556
+ );
557
+ const opened = vi.spyOn(window, 'open').mockReturnValue(null);
558
+ const Opener = () => {
559
+ const surface = useRendererSurface();
560
+ return (
561
+ <button type="button" onClick={() => surface?.openFilePage(`${KB}/Skills/qa-bridge/view.html`)}>
562
+ open
563
+ </button>
564
+ );
565
+ };
566
+ mount({ ...EMPTY_REGISTRY, renderers: [{ extensions: ['.html'], Component: Opener }] } as unknown as AppRegistry);
567
+ fireEvent.click(await screen.findByRole('button', { name: 'open' }));
568
+ expect(opened).toHaveBeenCalledTimes(1);
569
+ expect(String(opened.mock.calls[0]![0])).toMatch(/\/workspace\/main\/knowledge-base\/Skills\/qa-bridge\/view\.html\?as=file$/);
570
+ opened.mockRestore();
571
+ });
572
+
553
573
  it('falls back to the built-in renderer for the type when nothing is registered', async () => {
554
574
  api.loadEmbed.mockResolvedValue(view());
555
575
  mount();
@@ -5,6 +5,7 @@ import { useAppRegistry } from '../../../core/registry';
5
5
  import {
6
6
  CanDownloadContext,
7
7
  isViewOnlyFile,
8
+ kbFilePageUrl,
8
9
  kbFileUrl,
9
10
  pickFileRenderer,
10
11
  RendererSurfaceContext,
@@ -409,6 +410,7 @@ export function EmbedView() {
409
410
  // A path from a tree, verbatim — never through the link grammar, which
410
411
  // would read a `#` in a file name as an anchor.
411
412
  openWorkspacePath: (path) => openThroughHost(absolute(kbFileUrl(view.branch, path)), '', null),
413
+ openFilePage: (path) => openThroughHost(absolute(kbFilePageUrl(view.branch, path)), '', null),
412
414
  // A node id is handed to the host as the app's own copy-link address;
413
415
  // the app resolves it with the reader's session, which is the only
414
416
  // place that resolution can be done.
@@ -13,3 +13,6 @@ import { BRANCH_DELETE_CONFIRM_MENU_ITEM } from './branch-delete-menu-item';
13
13
  * branch-delete question is off.
14
14
  */
15
15
  export const GIT_MENU_ITEMS: readonly AdminMenuItem[] = [BRANCH_DELETE_CONFIRM_MENU_ITEM];
16
+
17
+ /** The branch state a page reads (`useGit`), and the context a test provides it through. */
18
+ export { GitContext, useGit, type GitContextValue } from './state/git.context';
@@ -41,7 +41,10 @@ import {
41
41
  HEADER_COLUMN_TOP,
42
42
  PAGE_HEADER_TESTID,
43
43
  SIDEBAR_HEADER_TESTID,
44
+ TITLE_INK_ROOM,
44
45
  } from '../../../shared/theme/header';
46
+ import { expectTitleKeepsItsInk } from '../../../__tests__/title-ink-room';
47
+ import { declarationsOf } from '../../../__tests__/tailwindDeclarations';
45
48
 
46
49
  const HERE = dirname(fileURLToPath(import.meta.url));
47
50
  /** `src/`, three levels up from `modules/layout/__tests__`. */
@@ -501,3 +504,50 @@ describe('the two bands open at the same offset', () => {
501
504
  expect(article.parentElement!.className.split(/\s+/)).toContain(HEADER_COLUMN_TOP);
502
505
  });
503
506
  });
507
+
508
+ /**
509
+ * The title on the band keeps the tails of its g, y and p.
510
+ *
511
+ * `text-display` sets a line height tighter than its glyphs, and `truncate`
512
+ * clips to the line box, so the tails were cut off. `TITLE_INK_ROOM` widens
513
+ * the clipping box by a padding and hands the same distance back as a
514
+ * negative margin: the title keeps exactly its line box, the band does not
515
+ * move. Two things make that true, and both are pinned here against the
516
+ * stylesheet the build serves rather than against the source of the
517
+ * constant: the padding and the margin are the same distance with opposite
518
+ * signs, and `truncate` still clips (which is why the room is needed at all)
519
+ * and still ends a long title with an ellipsis. The shape of the markup —
520
+ * the room on the title and on every wrapper that clips it — is checked by
521
+ * `expectTitleKeepsItsInk`, here on the knowledge page's header and in each
522
+ * Library page's own test. The declarations are read through
523
+ * `declarationsOf`, the one resolver of a utility class to the CSS the build
524
+ * gives it.
525
+ */
526
+ describe('a page title keeps its ink', () => {
527
+ /** What the build gives an element wearing exactly these classes. */
528
+ const declarationsOfClasses = (className: string) =>
529
+ declarationsOf(Object.assign(document.createElement('div'), { className }));
530
+
531
+ it('hands back as margin exactly the padding it adds, so the band does not move', async () => {
532
+ const room = await declarationsOfClasses(TITLE_INK_ROOM);
533
+ // Tailwind spells the negative utility as the positive one times -1, so the
534
+ // two cannot drift apart by a token change: this reads the sign, not a number.
535
+ expect(room['padding-block']).toBeDefined();
536
+ expect(room['margin-block']).toBe(`calc(${room['padding-block']} * -1)`);
537
+ });
538
+
539
+ it('still truncates with an ellipsis — the clipping the room exists for', async () => {
540
+ expect(await declarationsOfClasses('truncate')).toMatchObject({
541
+ overflow: 'hidden',
542
+ 'text-overflow': 'ellipsis',
543
+ 'white-space': 'nowrap',
544
+ });
545
+ });
546
+
547
+ it("the knowledge page's title has the room, and so does the group that clips it", () => {
548
+ renderSeam();
549
+ expectTitleKeepsItsInk(screen.getByTestId(PAGE_HEADER_TESTID));
550
+ // With the title in it, the band is still exactly the token tall.
551
+ expect(heightOf(PAGE_HEADER_TESTID)).toBe(headerHeight);
552
+ });
553
+ });
@@ -12,6 +12,8 @@ import type { LibraryData } from '../hooks/useLibraryData';
12
12
  import type { PluginSummary } from '../services/plugins.api';
13
13
  import type { ToolPageState } from '../hooks/useToolPage';
14
14
  import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
15
+ import { expectTitleKeepsItsInk } from '../../../__tests__/title-ink-room';
16
+ import { LockedPluginView } from '../components/LockedPluginView';
15
17
 
16
18
  /**
17
19
  * The Library's routes, end to end through the layout: URL in, page + lit
@@ -202,6 +204,41 @@ describe('LibraryRoutes', () => {
202
204
  expect(screen.getByTestId('library-card-skill-outreach')).toBeInTheDocument();
203
205
  });
204
206
 
207
+ /**
208
+ * Every Library page title keeps the tails of its g, y and p: the title
209
+ * truncates, and it and every wrapper that clips it carry the ink room
210
+ * (`expectTitleKeepsItsInk`). The plugin pages are the ones that group the
211
+ * title with its breadcrumb in an `overflow-hidden` wrapper, where a room
212
+ * on the title alone was not enough.
213
+ */
214
+ it.each([
215
+ ['Everything', '/skills-and-tools', 'Everything'],
216
+ ['a group', '/skills-and-tools/teams/GTM%20Team', 'GTM Team'],
217
+ ['a plugin', '/skills-and-tools/plugins/GTM', 'GTM'],
218
+ ['your own space', '/skills-and-tools/yours', TEST_PERSONAL_GROUP],
219
+ ])('the title of %s keeps its ink', async (_what, path, heading) => {
220
+ renderAt(path);
221
+ await screen.findByRole('heading', { name: heading, level: 1 });
222
+ expectTitleKeepsItsInk(screen.getByTestId(PAGE_HEADER_TESTID));
223
+ });
224
+
225
+ it("the title of a plugin you cannot read keeps its ink", () => {
226
+ render(
227
+ <MemoryRouter>
228
+ {wrap(
229
+ <LockedPluginView
230
+ plugin={{ ...PLUGINS[0]!, canRead: false, canWrite: false, isOwner: false }}
231
+ onRequested={() => {}}
232
+ onUnlocked={() => {}}
233
+ onManage={() => {}}
234
+ />,
235
+ )}
236
+ </MemoryRouter>,
237
+ );
238
+ screen.getByRole('heading', { name: 'GTM', level: 1 });
239
+ expectTitleKeepsItsInk(screen.getByTestId(PAGE_HEADER_TESTID));
240
+ });
241
+
205
242
  it('sends the old /everything address to the root, where the same page lives', async () => {
206
243
  renderAt('/skills-and-tools/everything');
207
244
  await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
@@ -28,6 +28,22 @@ const apiMock = vi.hoisted(() => ({
28
28
  writeFile: vi.fn(),
29
29
  listSkillAccessRequests: vi.fn(async (): Promise<unknown[]> => []),
30
30
  }));
31
+ /**
32
+ * The props the page last handed its reading pane — so a test can drive a
33
+ * callback the pane only reaches through an HTML page's frame (Open in the
34
+ * platform). The pane itself renders as it always does.
35
+ */
36
+ const paneProps = vi.hoisted(() => ({ last: null as null | { onOpenInPlatform?: () => void } }));
37
+ vi.mock('../components/skill-page/SkillFilePane', async (importOriginal) => {
38
+ const real = await importOriginal<typeof import('../components/skill-page/SkillFilePane')>();
39
+ return {
40
+ SkillFilePane: (props: Parameters<typeof real.SkillFilePane>[0]) => {
41
+ paneProps.last = props;
42
+ return real.SkillFilePane(props);
43
+ },
44
+ };
45
+ });
46
+
31
47
  vi.mock('../services/library.api', () => ({
32
48
  defaultWorkspaceId: () => 'target-company-state',
33
49
  getSkill: apiMock.getSkill,
@@ -130,6 +146,8 @@ vi.mock('../state/library-data', () => ({
130
146
  import { SkillPage } from '../components/skill-page/SkillPage';
131
147
  import { LibraryToastProvider } from '../state/toast';
132
148
  import { expectTitleRowSpansTheDocumentColumn } from './title-row-actions';
149
+ import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
150
+ import { expectTitleKeepsItsInk } from '../../../__tests__/title-ink-room';
133
151
 
134
152
  const workspace = {
135
153
  workspaceId: 'target-company-state',
@@ -299,7 +317,15 @@ function renderPage(
299
317
 
300
318
  /** Where a link out of the page took the router: the Knowledge app's path. */
301
319
  function NavigatedTo() {
302
- return <div data-testid="navigated-to">{useLocation().pathname}</div>;
320
+ const location = useLocation();
321
+ return (
322
+ <>
323
+ <div data-testid="navigated-to">{location.pathname}</div>
324
+ <div data-testid="navigated-raw-file">
325
+ {String((location.state as { rawFile?: boolean } | null)?.rawFile === true)}
326
+ </div>
327
+ </>
328
+ );
303
329
  }
304
330
 
305
331
  /**
@@ -429,6 +455,17 @@ describe('SkillPage', () => {
429
455
  expect(await screen.findByTestId('navigated-to')).toHaveTextContent(/^\/skills-and-tools\/connect$/);
430
456
  });
431
457
 
458
+ it("opens a page of the skill on the Knowledge file page, not back on this page, for Open in the platform", async () => {
459
+ renderPage(true);
460
+ await settled();
461
+ expect(paneProps.last?.onOpenInPlatform).toBeTypeOf('function');
462
+ act(() => paneProps.last!.onOpenInPlatform!());
463
+ // The file's own address, with the state that makes the item route show
464
+ // the file route rather than this skill page again.
465
+ expect(await screen.findByTestId('navigated-to')).toHaveTextContent(/^\/workspace\/[^/]+\/knowledge-base\/Skills\/newsletter\/SKILL\.md$/);
466
+ expect(screen.getByTestId('navigated-raw-file')).toHaveTextContent('true');
467
+ });
468
+
432
469
  it('loads the skill and shows its name, needed integrations and files', async () => {
433
470
  renderPage(false);
434
471
 
@@ -472,6 +509,12 @@ describe('SkillPage', () => {
472
509
  expectTitleRowSpansTheDocumentColumn();
473
510
  });
474
511
 
512
+ it('keeps the tails of its title: it truncates, with room for its ink', async () => {
513
+ renderPage(false);
514
+ await screen.findByRole('heading', { name: 'newsletter' });
515
+ expectTitleKeepsItsInk(screen.getByTestId(PAGE_HEADER_TESTID));
516
+ });
517
+
475
518
  it('marks the open tab selected and loads a bundled file on click', async () => {
476
519
  renderPage(false);
477
520
  const tab = await screen.findByRole('tab', { name: /sources\.yaml/ });
@@ -62,6 +62,8 @@ vi.mock('../utils/navigate-external', () => ({ navigateExternal: vi.fn() }));
62
62
  import { ToolPage } from '../components/tool-page/ToolPage';
63
63
  import { NAME_MIN_WIDTH } from '../components/NameWithBadges';
64
64
  import { expectMenuAtTheEndOfTheTitleRow, expectTitleRowSpansTheDocumentColumn } from './title-row-actions';
65
+ import { expectTitleKeepsItsInk } from '../../../__tests__/title-ink-room';
66
+ import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
65
67
  import { TOOL_CREDENTIALS_STALE_EVENT } from '../../../core/events';
66
68
 
67
69
  const GITHUB: ToolSecrets = {
@@ -248,6 +250,12 @@ describe('ToolPage: frame', () => {
248
250
  expect(container.querySelector('article')!.className).not.toContain('max-w-');
249
251
  });
250
252
 
253
+ it('keeps the tails of its title\'s g, y and p: the room on the title and on the row that clips it', async () => {
254
+ renderPage();
255
+ await screen.findByRole('heading', { name: 'heyreach', level: 1 });
256
+ expectTitleKeepsItsInk(screen.getByTestId(PAGE_HEADER_TESTID));
257
+ });
258
+
251
259
  it('shows no kicker for a legacy ungrouped path either', async () => {
252
260
  secretsMock.listToolSecrets.mockResolvedValue([
253
261
  { ...GITHUB, slug: 'slack', name: 'slack', path: 'Tools/slack.tool' },
@@ -207,6 +207,31 @@ describe('WorkspaceItemRoute', () => {
207
207
  expect(await screen.findByLabelText('tool-page')).toHaveTextContent('notion');
208
208
  });
209
209
 
210
+ it("a skill's HTML page opens as the file it is with `rawFile` — the skill page's Open in the platform", async () => {
211
+ const url = itemUrl('Skills/qa-bridge/view.html');
212
+ renderAt(url);
213
+ expect(await screen.findByLabelText('skill-page')).toHaveTextContent('qa-bridge::view.html');
214
+ cleanup();
215
+ render(
216
+ <MemoryRouter initialEntries={[{ pathname: url, state: { rawFile: true } }]}>
217
+ {wrap(
218
+ <Routes>
219
+ <Route path="/workspace/*" element={<LibraryRoutes />} />
220
+ </Routes>,
221
+ null,
222
+ )}
223
+ </MemoryRouter>,
224
+ );
225
+ await waitFor(() => expect(screen.getByLabelText('file-view')).toBeInTheDocument());
226
+ expect(screen.queryByLabelText('skill-page')).not.toBeInTheDocument();
227
+ });
228
+
229
+ it("a skill's HTML page opens as the file it is at `?as=file` — the embed's Open in the platform, a new tab with no router state", async () => {
230
+ renderAt(`${itemUrl('Skills/qa-bridge/view.html')}?as=file`);
231
+ await waitFor(() => expect(screen.getByLabelText('file-view')).toBeInTheDocument());
232
+ expect(screen.queryByLabelText('skill-page')).not.toBeInTheDocument();
233
+ });
234
+
210
235
  it('router state `rawFile` renders the file itself at a URL that would otherwise be a page — still inside the library', async () => {
211
236
  // The tool page's "Edit the tool file" and the plugin page's manifest
212
237
  // button ask for the raw editor by state; the app on screen does not
@@ -10,7 +10,7 @@ import { pluginEntriesFor } from '../utils/plugin-entries';
10
10
  import { personalPluginName } from '../utils/personal-plugin';
11
11
  import { Banner, TextField } from '../../../shared/components';
12
12
  import { cn } from '../../../lib/utils';
13
- import { HEADER_BAND, PAGE_HEADER_TESTID } from '../../../shared/theme/header';
13
+ import { HEADER_BAND, PAGE_HEADER_TESTID, TITLE_INK_ROOM } from '../../../shared/theme/header';
14
14
  import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
15
15
  import { offersManageAccess } from '../../access/manage-access-affordance';
16
16
  import { useAdmin } from '../../admin/state/admin.context';
@@ -163,7 +163,7 @@ export function LibraryPage({ filter }: { filter: LibraryFilter }) {
163
163
  carrying — a height no other page could match. They read below it
164
164
  now, where they always looked like they were. */}
165
165
  <div data-testid={PAGE_HEADER_TESTID} className={cn(HEADER_BAND, 'gap-4')}>
166
- <h1 className="min-w-0 truncate text-display font-semibold" title={headingFor(filter)}>
166
+ <h1 className={`min-w-0 truncate text-display font-semibold ${TITLE_INK_ROOM}`} title={headingFor(filter)}>
167
167
  {headingFor(filter)}
168
168
  </h1>
169
169
  <TextField
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
  import { cn } from '../../../lib/utils';
3
- import { HEADER_BAND, PAGE_HEADER_TESTID } from '../../../shared/theme/header';
3
+ import { HEADER_BAND, PAGE_HEADER_TESTID, TITLE_INK_ROOM } from '../../../shared/theme/header';
4
4
  import { Badge, Button, Surface } from '../../../shared/components';
5
5
  import { adminNamesOf, ownersTextOf, primaryFolderOf } from '../utils/plugin-summary';
6
6
  import { AlreadyReadableError, requestPluginAccess, type PluginSummary } from '../services/plugins.api';
@@ -103,7 +103,7 @@ export function LockedPluginView({ plugin, onRequested, onUnlocked, onManage }:
103
103
  <div data-testid={PAGE_HEADER_TESTID} className={cn(HEADER_BAND, 'gap-2.5')}>
104
104
  <PluginBreadcrumb />
105
105
  <h1
106
- className="min-w-0 truncate text-display font-semibold"
106
+ className={`min-w-0 truncate text-display font-semibold ${TITLE_INK_ROOM}`}
107
107
  title={plugin.displayName || plugin.name}
108
108
  >
109
109
  {plugin.displayName || plugin.name}
@@ -13,7 +13,7 @@ import { EmptySkillsNudge, PluginBreadcrumb, PluginItemSections, PageNote,
13
13
  import { PageActions } from './PageActions';
14
14
  import { PendingItemReview } from './PendingItemReview';
15
15
  import { cn } from '../../../lib/utils';
16
- import { HEADER_BAND, PAGE_HEADER_TESTID } from '../../../shared/theme/header';
16
+ import { HEADER_BAND, PAGE_HEADER_TESTID, TITLE_INK_ROOM } from '../../../shared/theme/header';
17
17
  import { PersonalAddDialog } from './PersonalAddDialog';
18
18
  import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
19
19
  import { copyToClipboard } from '../utils/clipboard';
@@ -120,10 +120,11 @@ export function PersonalPluginPage() {
120
120
  {/* Clipped, and allowed to take the row's shortfall, for the reason
121
121
  the plugin page's is — the trail is a fixed width, so a group that
122
122
  could only shrink would run its content across the actions beside
123
- it on a narrow viewport. */}
124
- <div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
123
+ it on a narrow viewport. The ink room is on this group as well as
124
+ on the title, because the group clips to the title's line box too. */}
125
+ <div className={`flex min-w-0 flex-1 items-center gap-2 overflow-hidden ${TITLE_INK_ROOM}`}>
125
126
  <PluginBreadcrumb />
126
- <h1 className="min-w-0 truncate text-display font-semibold" title={name}>
127
+ <h1 className={`min-w-0 truncate text-display font-semibold ${TITLE_INK_ROOM}`} title={name}>
127
128
  {name}
128
129
  </h1>
129
130
  </div>