Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web/e2e/chrome.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ test("Export and BOM sit in header chrome, not only the inspector", async ({ pag
await expect(page.locator("[data-part-chrome]")).toBeVisible();
await expect(page.locator("[data-chrome-export]")).toBeVisible();
await expect(page.locator("[data-chrome-bom]")).toBeVisible();
// Signed-in header: the token is the fragment / sessionStorage, not a chip.
await expect(page.locator("header [data-token-state]")).toHaveCount(0);
// The inspector export tab still exists; chrome is in addition to it.
await expect(page.locator('[data-inspector-tab="export"]')).toBeVisible();
await expect(page.locator('[data-inspector-tab="sourcing"]')).toBeVisible();
Expand Down
13 changes: 8 additions & 5 deletions web/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// Copyright 2026 The Hephaestus Authors
// SPDX-License-Identifier: Apache-2.0
//
// §4.1's HEADER: `identity → pin → Export/BOM chrome → build state → token`.
// §4.1's HEADER: `identity → pin → Export/BOM chrome → build state`.
//
// The pin is the one dominant element. Export and BOM sit beside it as quiet
// icon-only controls (issue #12) so they do not crowd the 44px bar. The real
// workspace token is the URL fragment / sessionStorage (§2.2); the header
// does not paint a decorative Token chip. Absence is the full-page NoToken
// screen, not a header state.
//
// The two axes §13.1 insists must never blur are split across the shell on
// purpose: **the header shows the artifact axis** (pin, build state) and **the
Expand Down Expand Up @@ -31,7 +37,7 @@ import type { ReactNode } from "react";
import { useBuild, useGitStatus, useProject } from "../api/queries";
import { copy } from "../copy";
import { useWorkspace } from "../state/react";
import { Chip, formatRef } from "../system";
import { formatRef } from "../system";
import { ArtifactPin } from "./ArtifactPin";
import { BuildStateChip } from "./BuildStateChip";
import { PartChrome } from "./chrome/PartChrome";
Expand Down Expand Up @@ -116,9 +122,6 @@ export function Header({ railToggle }: HeaderProps): React.JSX.Element {

<div className={styles["right"]}>
<BuildStateChip build={build.data} />
<Chip title={copy.header.token} data-token-state="present">
{copy.header.token}
</Chip>
</div>
</header>
);
Expand Down
27 changes: 14 additions & 13 deletions web/src/components/chrome/PartChrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
// Part chrome — Export and BOM next to the on-screen pin (issue #12).
//
// §22.7 put export in an inspector tab and said the header gains nothing.
// The operator session (issue #4 / #12) wants a simple control in chrome,
// bound to the thing on screen, not only a buried tab. This cluster sits
// beside the artifact pin. Both buttons still send the workspace pin; they
// do not resolve "current" at click time.
// Issue #12 amended that: two simple controls sit in chrome, bound to the
// thing on screen, not only a buried tab. They stay two distinct, visible,
// clickable buttons — icon-only so the pin dominates the 44px bar. There is
// no overflow, menu, or extra click in front of them.
//
// Export opens a compact format+run dialog. BOM opens the sourcing inspector
// (declared `process` / stock / material spec only — no vendor catalog).
// The inspector Export tab stays for history, drawings, and documents.
// Both buttons still send the workspace pin; they do not resolve "current"
// at click time. Export opens a compact format+run dialog. BOM opens the
// sourcing inspector (declared `process` / stock / material spec only — no
// vendor catalog). The inspector Export tab stays for history, drawings, and
// documents. There is no third egress surface.

import { useState } from "react";
import { copy } from "../../copy";
Expand Down Expand Up @@ -41,24 +43,23 @@ export function PartChrome(): React.JSX.Element {
<Button
variant="quiet"
icon="download"
iconLabel={copy.chrome.exportTitle}
data-chrome-export=""
title={copy.chrome.exportTitle}
onClick={() => {
setOpen("export");
}}
>
{copy.chrome.export}
</Button>
/>
<Button
variant="quiet"
icon="file"
iconLabel={copy.chrome.bomTitle}
data-chrome-bom=""
title={copy.chrome.bomTitle}
onClick={() => {
setOpen("sourcing");
}}
>
{copy.chrome.bom}
</Button>
/>

<Popover
open={open === "export"}
Expand Down
54 changes: 54 additions & 0 deletions web/test/chrome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import type { ReactElement } from "react";

import { EXPORT_FORMATS } from "../src/api/exports";
import { SOURCING_FIELDS } from "../src/api/types";
import { ExportChrome } from "../src/components/chrome/ExportChrome";
import { PartChrome } from "../src/components/chrome/PartChrome";
import { exportBlocker } from "../src/components/inspector/ExportPanel";
import { INSPECTOR_TABS } from "../src/state/workspace";

Expand Down Expand Up @@ -120,3 +122,55 @@ describe("sourcing field set — declared manufacturing identity only", () => {
}
});
});

describe("header chrome — two visible icon-only controls, pin-bound", () => {
function partChrome(): Document {
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
return render(
<QueryClientProvider client={client}>
<PartChrome />
</QueryClientProvider>,
);
}

it("renders Export and BOM as distinct clickable buttons, not an overflow", () => {
const dom = partChrome();
const host = dom.querySelector("[data-part-chrome]");
const exportBtn = dom.querySelector("[data-chrome-export]");
const bomBtn = dom.querySelector("[data-chrome-bom]");
expect(host).not.toBeNull();
expect(exportBtn?.tagName).toBe("BUTTON");
expect(bomBtn?.tagName).toBe("BUTTON");
expect(exportBtn?.parentElement).toBe(host);
expect(bomBtn?.parentElement).toBe(host);
expect(dom.querySelector("[data-chrome-more]")).toBeNull();
expect(dom.querySelector("[data-chrome-overflow]")).toBeNull();
expect(exportBtn).not.toBe(bomBtn);
});

it("is icon-only: each control has an icon and no printed word", () => {
const dom = partChrome();
const exportBtn = dom.querySelector("[data-chrome-export]");
const bomBtn = dom.querySelector("[data-chrome-bom]");
expect(exportBtn?.querySelector("svg[data-icon]")).not.toBeNull();
expect(bomBtn?.querySelector("svg[data-icon]")).not.toBeNull();
expect(exportBtn?.textContent?.trim()).toBe("");
expect(bomBtn?.textContent?.trim()).toBe("");
expect(exportBtn?.getAttribute("aria-label") ?? "").not.toBe("");
expect(bomBtn?.getAttribute("aria-label") ?? "").not.toBe("");
expect(exportBtn?.getAttribute("title") ?? "").not.toBe("");
expect(bomBtn?.getAttribute("title") ?? "").not.toBe("");
});

it("still sends the workspace pin and does not grow a third egress surface", () => {
const source = readFileSync(resolve(process.cwd(), "src/components/chrome/PartChrome.tsx"), "utf-8");
expect(source).toContain("useExportActions");
expect(source).toContain("pinned={pinned}");
expect(source).toContain("pinMode={pinMode}");
expect(source).toContain("data-chrome-export");
expect(source).toContain("data-chrome-bom");
expect(source).not.toMatch(/data-chrome-overflow|data-chrome-more|overflow menu/);
expect(source).not.toContain("inspector_tab: \"sourcing\"");
expect([...INSPECTOR_TABS]).toEqual(expect.arrayContaining(["export", "sourcing"]));
});
});
16 changes: 16 additions & 0 deletions web/test/operator-chrome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,20 @@ describe("header git identity — no invented branch, no HEAD without a sha", ()
expect(markup).not.toContain('data-source="git.head"');
expect(markup).not.toContain(copy.header.head);
});

it("does not paint a decorative Token chip in the signed-in header", () => {
const markup = headerMarkup(gitDocument());
expect(markup).not.toContain("data-token-state");
const header = readFileSync(join(webSrc, "components/Header.tsx"), "utf8");
expect(header).not.toContain("data-token-state");
expect(header).not.toContain("copy.header.token");
});

it("keeps Export and BOM as two addressable header controls next to the pin", () => {
const markup = headerMarkup(gitDocument());
expect(markup).toContain("data-chrome-export");
expect(markup).toContain("data-chrome-bom");
expect(markup).toContain("data-part-chrome");
expect(markup).toContain("data-testid=\"artifact-pin\"");
});
});
Loading