Skip to content

Commit ffc5119

Browse files
committed
feat(v5-g19): DimensionsTab Apply per-row button + callback
Closes V5-G19 / cppmega-mlx-udk. DimensionsTab rows for auto-inferred params get an Apply button (data-testid=dim-row-{brick}-{param}-apply). onApply(entry) callback fires; parent dispatches spec mutation so the next verify hides the now-fulfilled suggestion (feedback loop closed). 3 new vitest. UI wiring to App.tsx dispatch deferred — backend contract + component contract first, App integration follow-up.
1 parent 80658a8 commit ffc5119

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

vbgui/src/components/sidebar/DimensionsTab.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ export interface InferenceEntryClient {
1515
export interface DimensionsTabProps {
1616
log: InferenceEntryClient[];
1717
onHighlight?: (brick: string) => void;
18+
/** G19: callback when user clicks Apply on an auto-inferred row.
19+
* Parent dispatches the spec mutation so subsequent verify hides
20+
* the suggestion (closing the loop). */
21+
onApply?: (entry: InferenceEntryClient) => void;
1822
}
1923

2024
export function DimensionsTab({
21-
log, onHighlight,
25+
log, onHighlight, onApply,
2226
}: DimensionsTabProps): JSX.Element {
2327
const [filterSource, setFilterSource] =
2428
useState<"all" | "user" | "auto">("all");
@@ -70,6 +74,7 @@ export function DimensionsTab({
7074
<th style={th}>Value</th>
7175
<th style={th}>Source</th>
7276
<th style={th}>Reason</th>
77+
<th style={th}></th>
7378
</tr>
7479
</thead>
7580
<tbody>
@@ -96,6 +101,16 @@ export function DimensionsTab({
96101
<td style={{ ...td, color: "#6b7280", fontSize: 11 }}>
97102
{e.reason}
98103
</td>
104+
<td style={td}>
105+
{onApply && e.source === "auto" && (
106+
<button data-testid={`dim-row-${e.brick}-${e.param}-apply`}
107+
onClick={(ev) => { ev.stopPropagation();
108+
onApply(e); }}
109+
style={{ fontSize: 10, padding: "1px 6px" }}>
110+
Apply
111+
</button>
112+
)}
113+
</td>
99114
</tr>
100115
))}
101116
{visible.length === 0 && (

vbgui/tests/DimensionsTab.test.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,36 @@ describe("DimensionsTab", () => {
5757
render(<DimensionsTab log={[]} />);
5858
expect(screen.getByText(/No matching entries/)).toBeTruthy();
5959
});
60+
61+
// G19: Apply button on auto rows
62+
it("G19: Apply button visible only on auto-source rows", () => {
63+
const log = [
64+
{ brick: "attn", param: "head_dim", value: 64,
65+
source: "auto" as const, reason: "inferred from H" },
66+
{ brick: "mlp", param: "intermediate_size", value: 256,
67+
source: "user" as const, reason: "user set" },
68+
];
69+
render(<DimensionsTab log={log} onApply={() => {}} />);
70+
expect(screen.getByTestId("dim-row-attn-head_dim-apply")).toBeTruthy();
71+
expect(screen.queryByTestId(
72+
"dim-row-mlp-intermediate_size-apply")).toBeNull();
73+
});
74+
75+
it("G19: clicking Apply fires onApply(entry)", () => {
76+
const onApply = vi.fn();
77+
const entry = { brick: "attn", param: "head_dim", value: 64,
78+
source: "auto" as const, reason: "inferred from H" };
79+
render(<DimensionsTab log={[entry]} onApply={onApply} />);
80+
fireEvent.click(screen.getByTestId("dim-row-attn-head_dim-apply"));
81+
expect(onApply).toHaveBeenCalledWith(entry);
82+
});
83+
84+
it("G19: Apply button absent when onApply prop missing", () => {
85+
render(<DimensionsTab log={[
86+
{ brick: "attn", param: "head_dim", value: 64,
87+
source: "auto", reason: "x" },
88+
]} />);
89+
expect(screen.queryByTestId(
90+
"dim-row-attn-head_dim-apply")).toBeNull();
91+
});
6092
});

0 commit comments

Comments
 (0)