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
5 changes: 5 additions & 0 deletions .changeset/ad-hoc-value-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hashintel/petrinaut": patch
---

Improve scenario and experiment forms with keyboard navigation, stacked section headers, overlay scrollbars, default starting-place filtering with a compact toggle beside the section title, and source expressions over selected computed values. Align the Time Step label and info icon, align token totals with place headers, keep select chevrons inside spreadsheet cells, and keep validation errors visible while editing ad-hoc values.
5 changes: 5 additions & 0 deletions .changeset/editable-example-scenarios.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hashintel/petrinaut-core": patch
---

Make bundled example scenarios editable in the ad-hoc scenario form while preserving their parameters and initial states.
9 changes: 6 additions & 3 deletions apps/petrinaut-website/scripts/generate-example-artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ const generateRuntime = async (entry: ExampleCatalogEntry) => {
null,
) as Record<string, ScenarioHir>;
for (const scenario of definition.scenarios ?? []) {
const hir = lowerScenarioToHir({
parameterOverrides: scenario.parameterOverrides,
initialState: scenario.initialState,
const hir = lowerScenarioToHir(scenario, {
adHocContext: {
places: definition.places,
types: definition.types,
netParameters: definition.parameters,
},
});
const outcome = compileScenario(
scenario,
Expand Down
11 changes: 11 additions & 0 deletions apps/petrinaut-website/src/examples/catalog.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { describe, expect, it } from "vitest";

import { compileScenario } from "@hashintel/petrinaut-core";

import {
exampleCatalog,
exampleSlugs,
Expand Down Expand Up @@ -34,7 +36,16 @@ describe("example catalog", () => {
expect(example.catalog).toBe(entry);

for (const scenario of example.definition.scenarios ?? []) {
expect(scenario.initialState.type).toBe("adhoc");
expect(runtime.scenarioHirById).toHaveProperty(scenario.id);
const compiled = compileScenario(
scenario,
runtime.scenarioHirById[scenario.id]!,
example.definition.parameters,
example.definition.places,
example.definition.types,
);
expect(compiled.ok, JSON.stringify(compiled)).toBe(true);

for (const parameter of scenario.scenarioParameters) {
const bounds = entry.parameterBounds[parameter.identifier];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,125 @@
"param__draw_enabled": "scenario.draw_enabled"
},
"initialState": {
"type": "code",
"content": "return {\n IdleTankers: 1,\n LoadsDelivered: 0,\n SteadyNitrogenOrderPlaced: 0,\n SteadyNitrogenOrderPermits: 2,\n SteadyNitrogenOnRoute: 0,\n SteadyNitrogenVented: 0,\n SteadyNitrogenLineRunning: 1,\n SteadyNitrogenLineStopped: 0,\n SteadyNitrogenStockouts: 0,\n SteadyNitrogenConsumed: 0,\n SteadyNitrogenEvaporated: 0,\n SteadyNitrogenContents: 42,\n SteadyNitrogenUllage: 12,\n SteadyNitrogenUnitsDrawnSinceOrder: 0,\n};"
"type": "adhoc",
"content": {
"variables": [
{
"name": "draw_enabled",
"type": "real",
"expression": "1",
"exposed": true,
"optimize": null
}
],
"netParameters": [
{
"parameterId": "param__draw_enabled",
"expression": "scenario.draw_enabled",
"optimize": null
}
],
"places": {
"place__idle_tankers": {
"kind": "uncoloured",
"count": {
"expression": "1",
"optimize": null
}
},
"place__loads_delivered": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_order_placed": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_order_permits": {
"kind": "uncoloured",
"count": {
"expression": "2",
"optimize": null
}
},
"place__s1_on_route": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_vented": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_line_running": {
"kind": "uncoloured",
"count": {
"expression": "1",
"optimize": null
}
},
"place__s1_line_stopped": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_stockouts": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_consumed": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_evaporated": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_contents": {
"kind": "uncoloured",
"count": {
"expression": "42",
"optimize": null
}
},
"place__s1_ullage": {
"kind": "uncoloured",
"count": {
"expression": "12",
"optimize": null
}
},
"place__s1_units_drawn_since_order": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
}
}
}
}
},
{
Expand All @@ -449,8 +566,125 @@
"param__draw_enabled": "scenario.draw_enabled"
},
"initialState": {
"type": "code",
"content": "return {\n IdleTankers: 1,\n LoadsDelivered: 0,\n SteadyNitrogenOrderPlaced: 0,\n SteadyNitrogenOrderPermits: 2,\n SteadyNitrogenOnRoute: 0,\n SteadyNitrogenVented: 0,\n SteadyNitrogenLineRunning: 1,\n SteadyNitrogenLineStopped: 0,\n SteadyNitrogenStockouts: 0,\n SteadyNitrogenConsumed: 0,\n SteadyNitrogenEvaporated: 0,\n SteadyNitrogenContents: 42,\n SteadyNitrogenUllage: 12,\n SteadyNitrogenUnitsDrawnSinceOrder: 0,\n};"
"type": "adhoc",
"content": {
"variables": [
{
"name": "draw_enabled",
"type": "real",
"expression": "0",
"exposed": true,
"optimize": null
}
],
"netParameters": [
{
"parameterId": "param__draw_enabled",
"expression": "scenario.draw_enabled",
"optimize": null
}
],
"places": {
"place__idle_tankers": {
"kind": "uncoloured",
"count": {
"expression": "1",
"optimize": null
}
},
"place__loads_delivered": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_order_placed": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_order_permits": {
"kind": "uncoloured",
"count": {
"expression": "2",
"optimize": null
}
},
"place__s1_on_route": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_vented": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_line_running": {
"kind": "uncoloured",
"count": {
"expression": "1",
"optimize": null
}
},
"place__s1_line_stopped": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_stockouts": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_consumed": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_evaporated": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
},
"place__s1_contents": {
"kind": "uncoloured",
"count": {
"expression": "42",
"optimize": null
}
},
"place__s1_ullage": {
"kind": "uncoloured",
"count": {
"expression": "12",
"optimize": null
}
},
"place__s1_units_drawn_since_order": {
"kind": "uncoloured",
"count": {
"expression": "0",
"optimize": null
}
}
}
}
}
}
],
Expand Down
Loading
Loading