Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 additions & 1 deletion INTERFACE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,9 @@ built, not entries in this inventory. Adding one is not §18 work; adding a
**panel** still is.

**Three panels join the inventory under Stage 10, and are marked as such.**
`ExportPanel` (§22.7) is **Stage 10A**; `ProvidersPanel` + `SignInDialog`
`ExportPanel` (§22.7) is **Stage 10A**; `SourcingPanel` (issue #12) reads
declared manufacturing identity from the existing properties route;
`ProvidersPanel` + `SignInDialog`
(§23.8) are **Stage 10B**, with the panel's discovery affordance **Stage 10C**
(§23.5). They are **not** Stage 4/5 work and do not become so by appearing here. They are
listed because a closed list that silently acquires members is not closed, and
Expand Down Expand Up @@ -4281,6 +4283,15 @@ the header: the header is 44px of the most contested space in the app and alread
renders the word "current" twice in two different closed vocabularies (§4.1) —
adding a third element there is how that defect happened.

**AMENDED (issue #12).** The inspector tab stays — history, drawings, documents,
and the two-step download live there, and every `data-export-*` selector is
unchanged. The operator session also puts a simple **Export** and **BOM**
control in header chrome next to the pin, so egress is not only a buried tab.
Both still send `WorkspaceState.artifact_ref` verbatim (§22.5). BOM/sourcing
reads only manufacturing fields the part already declares (`process`,
`stock_form`, `blank_size`, `material_spec`); there is no `conform_to` on the
`part.*` surface and no live vendor catalog.

**TIGHTENING.** `ExportPanel` is the only Inspector tab containing a control that
writes, so it renders its **subject before its controls**: the pinned ref, its
`pin_mode`, and the part, on the first line, above any format button. There is no
Expand Down
12 changes: 6 additions & 6 deletions server/src/hephaestus/http/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@
_STAGE_TABS: Final[frozenset[str]] = frozenset(
{"viewport", "script", "timeline", "results", "diff"}
)
#: Six, not five: §22.7's DECISION gives the Inspector an ``export`` tab. The
#: envelope's tab tokens are *the client's own* navigation vocabulary, so this
#: set tracks ``web/src/state/workspace.ts::INSPECTOR_TABS`` — a tab the client
#: can open and this route refuses would be a composer that stops working when
#: the operator changes panel.
#: Tracks ``web/src/state/workspace.ts::INSPECTOR_TABS``. §22.7 added
#: ``export``; issue #12 added ``sourcing`` (BOM from declared manufacturing
#: fields). The envelope's tab tokens are *the client's own* navigation
#: vocabulary — a tab the client can open and this route refuses would be a
#: composer that stops working when the operator changes panel.
_INSPECTOR_TABS: Final[frozenset[str]] = frozenset(
{"results", "properties", "provenance", "checks", "dfm", "export"}
{"results", "properties", "provenance", "checks", "dfm", "export", "sourcing"}
)

#: The marker a shortened block carries **in its own text**. The model cannot
Expand Down
83 changes: 83 additions & 0 deletions web/e2e/chrome.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright 2026 The Hephaestus Authors
// SPDX-License-Identifier: Apache-2.0
//
// Export / BOM chrome bound to the on-screen pin (issue #12). Expected values
// come from the server in the same run. No assertion is on UI copy.

import { expect, test } from "@playwright/test";
import { archive } from "./harness/archive";
import { api, open, route } from "./harness/world";

const PART = "tread";

interface PropertiesDocument {
readonly properties: Readonly<Record<string, string>>;
readonly fields: readonly string[];
readonly source: string;
readonly build_artifact_ref: string | null;
}

interface BuildDocument {
readonly status: string;
readonly artifact_ref: string;
}

test("Export and BOM sit in header chrome, not only the inspector", async ({ page }, testInfo) => {
await open(page, route(PART, { tab: "viewport" }));
await expect(page.locator("[data-part-chrome]")).toBeVisible();
await expect(page.locator("[data-chrome-export]")).toBeVisible();
await expect(page.locator("[data-chrome-bom]")).toBeVisible();
// 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();
await archive(page, testInfo, "export-bom-chrome");
});

test("chrome Export is bound to the pin the server named", async ({ page }, testInfo) => {
const build = await api<BuildDocument>(`/parts/${PART}/build`);
expect(build.artifact_ref).toMatch(/^artifact:build:/);

await open(page, route(PART, { tab: "viewport" }));
await page.locator("[data-chrome-export]").click();
await expect(page.locator("[data-panel='export-chrome']")).toBeVisible();

await expect(
page.locator("[data-panel='export-chrome'] [data-source='workspace.artifact_ref']"),
).toHaveAttribute("data-value", build.artifact_ref);

const formats = await page
.locator("[data-panel='export-chrome'] button[data-export-format]")
.evaluateAll((nodes) => nodes.map((node) => node.getAttribute("data-export-format")));
expect(formats).toEqual(["step", "dxf", "svg", "gltf", "3mf", "stl"]);

await archive(page, testInfo, "export-chrome-pin");
});

test("chrome BOM shows declared process / stock / material spec from GET properties", async ({
page,
}, testInfo) => {
const document = await api<PropertiesDocument>(`/parts/${PART}/properties`);
const sourcing = ["process", "stock_form", "blank_size", "material_spec"] as const;
const declared = sourcing.filter((field) => field in document.properties);

await open(page, route(PART, { tab: "viewport" }));
await page.locator("[data-chrome-bom]").click();
await expect(page.locator("[data-chrome-dialog='sourcing'] [data-panel='sourcing']")).toBeVisible();

const fields = await page
.locator("[data-chrome-dialog='sourcing'] [data-field]")
.evaluateAll((nodes) => nodes.map((node) => node.getAttribute("data-field")));
expect([...fields].sort()).toEqual([...declared].sort());
expect(fields).not.toContain("description");
expect(fields).not.toContain("finish");

for (const field of declared) {
const fact = page.locator(
`[data-chrome-dialog='sourcing'] [data-source="properties.${field}"]`,
);
await expect(fact).toHaveAttribute("data-value", document.properties[field] ?? "");
}

await expect(page.locator("[data-sourcing-catalog='none']").first()).toBeVisible();
await archive(page, testInfo, "sourcing-chrome");
});
43 changes: 27 additions & 16 deletions web/e2e/export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,35 +287,46 @@ test("the panel's download is the bytes the route recorded, and carries no token
// panel's back legitimately does not appear until its staleness expires.
await openExportTab(page);

const before = (await api<ExportsDocument>(`/parts/${PART}/exports`)).exports
.length;
// History is oldest-first (`rowid`). A prior test in this file already
// committed a STEP, so `[data-export-download].last()` is that STEP until
// the panel's own invalidation paints the new row. Matching `.last()` to
// `exports[].outputs.find(.stl)` races those two clocks.
const beforeBlobs = new Set(
(await api<ExportsDocument>(`/parts/${PART}/exports`)).exports
.flatMap((entry) => entry.outputs)
.map((entry) => entry.blob),
);
await page
.locator("[data-panel='export'] button[data-export-format='stl']")
.click();
await page.locator("[data-panel='export'] [data-export-run]").click();

// The panel invalidates its own history on a committed export, so the row
// arrives without a reload — §22.7's history is live, not a page the operator
// has to go and fetch.
const row = page
.locator("[data-panel='export'] [data-export-download]")
.last();
await expect(row).toBeVisible({ timeout: 120_000 });
// has to go and fetch. Wait for the *new* STL the route just recorded, then
// for that blob's Download button — not "any last button".
let output: ExportOutput | undefined;
await expect
.poll(
async () =>
(await api<ExportsDocument>(`/parts/${PART}/exports`)).exports.length,
async () => {
const listed = await api<ExportsDocument>(`/parts/${PART}/exports`);
output = listed.exports
.flatMap((entry) => entry.outputs)
.find(
(entry) =>
entry.filename.endsWith(".stl") && !beforeBlobs.has(entry.blob),
);
return output?.blob ?? null;
},
{ timeout: 120_000 },
)
.toBeGreaterThan(before);

// What the server recorded, read back off the projection the panel renders.
const listed = await api<ExportsDocument>(`/parts/${PART}/exports`);
const output = listed.exports
.flatMap((entry) => entry.outputs)
.find((entry) => entry.filename.endsWith(".stl"));
.not.toBeNull();
expect(output).toBeDefined();
const recordedBlob = output?.blob ?? "";
const row = page.locator(
`[data-panel='export'] [data-export-download="${recordedBlob}"]`,
);
await expect(row).toBeVisible({ timeout: 120_000 });
expect(await row.getAttribute("data-export-download")).toBe(recordedBlob);

const requests: string[] = [];
Expand Down
17 changes: 17 additions & 0 deletions web/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,23 @@ export type MetadataField =
| "assembly_method"
| "joint";

/**
* Manufacturing identity a BOM/sourcing inspector may render.
*
* Closed subset of `MetadataField`. There is no `conform_to` field on the
* `part.*` surface (`script_contract.md` §5.2); stock is `stock_form` +
* `blank_size`, process is `process`, and the material class the part
* declares is `material_spec`. The client does not invent a tenth name, and
* it does not look any of these up in a vendor catalog.
*/
export const SOURCING_FIELDS = [
"process",
"stock_form",
"blank_size",
"material_spec",
] as const satisfies readonly MetadataField[];
export type SourcingField = (typeof SOURCING_FIELDS)[number];

/** Which read answered a properties projection. Closed (`http/projections.py`). */
export type PropertySource = "build_record" | "script_literals";

Expand Down
9 changes: 9 additions & 0 deletions web/src/components/Header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
color: var(--ink-muted);
}

/* Pin + Export/BOM chrome, left-aligned on the same baseline as the pin. */
.subject {
display: flex;
align-items: center;
gap: var(--gap-inline);
min-width: 0;
justify-self: start;
}

.right {
display: flex;
align-items: center;
Expand Down
8 changes: 6 additions & 2 deletions web/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2026 The Hephaestus Authors
// SPDX-License-Identifier: Apache-2.0
//
// §4.1's HEADER: `identity → pin → build state → token`.
// §4.1's HEADER: `identity → pin → Export/BOM chrome → build state → token`.
//
// 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 @@ -29,6 +29,7 @@ import { useWorkspace } from "../state/react";
import { Chip, formatRef } from "../system";
import { ArtifactPin } from "./ArtifactPin";
import { BuildStateChip } from "./BuildStateChip";
import { PartChrome } from "./chrome/PartChrome";
import { Fact } from "./Fact";
import styles from "./Header.module.css";

Expand Down Expand Up @@ -77,7 +78,10 @@ export function Header({ railToggle }: HeaderProps): React.JSX.Element {
)}
</div>

<ArtifactPin currentRef={build.data?.artifact_ref ?? null} />
<div className={styles["subject"]}>
<ArtifactPin currentRef={build.data?.artifact_ref ?? null} />
<PartChrome />
</div>

<div className={styles["right"]}>
<BuildStateChip build={build.data} />
Expand Down
Loading
Loading