Skip to content

Commit d8ec27c

Browse files
committed
sync(bfmono): refactor(simulator-ui): replace nested ternaries in main routing (+19 more) (bfmono@383f2500a)
This PR is an automated gambitmono sync of bfmono Gambit packages. - Source: `packages/gambit/` - Core: `packages/gambit/packages/gambit-core/` - bfmono rev: 383f2500a Changes: - 383f2500a refactor(simulator-ui): replace nested ternaries in main routing - 13c4c8c22 fix(gambit): preserve shared references in safe session serialization - ae392aa24 feat(gambit-simulator-ui): add grader error chips to workbench chat - 1de6b335c fix(gambit): clamp deck-level maxTurns bounds in test run selection - 01d7abbb9 fix(gambit): default verify tab bootstrap flag to enabled - f3d186c7b fix(gambit): include extension schemas in exports and default serve to restored workspace - a83b7cbe7 fix(gambit): move unbounded build timeout to deck opt-in - acb2de627 fix(gambit): avoid strict json_schema 400s in openrouter responses - 8aba573b6 fix(gambit-simulator-ui): treat errored calibrate runs as failed - ca2028cf8 fix(gambit): prevent circular trace crashes in workspace test run API - 7e41517e5 fix(gambit): make build assistant run timeout unbounded - 24341143d feat(gambit): add deterministic verify fixture seeding - ff2c2d33d feat(gambit): add verify tab consistency UI - 91f0c93bb feat(gambit): add feature-flagged verify routing - 1392f8b65 feat(gambit): support deck-level maxTurns override - f5920ef86 chore(gambit): cut 0.8.5-rc.10 - 073c84d0e chore(gambit): cut 0.8.5-rc.10 - 2c669ba51 fix(gambit-core): ship builtin snippets/decks in npm runtime layouts - 498708844 docs(gambit): retire synthetic respond/end guidance and align deck authoring surfaces - 35ad1d5b5 feat(gambit-core): add OpenResponses convergence runtime, extensions, and async action semantics Do not edit this repo directly; make changes in bfmono and re-run the sync.
1 parent 09d6139 commit d8ec27c

1 file changed

Lines changed: 128 additions & 74 deletions

File tree

simulator-ui/src/main.tsx

Lines changed: 128 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,17 +1418,26 @@ function App() {
14181418
const isGrade = !isDocs &&
14191419
routeTab === "grade";
14201420
const isVerify = !isDocs && verifyTabEnabled && routeTab === "verify";
1421-
const currentPage = isDocs
1422-
? "docs"
1423-
: isBuild
1424-
? "build"
1425-
: isTestBot
1426-
? "test"
1427-
: isGrade
1428-
? "grade"
1429-
: isVerify
1430-
? "verify"
1431-
: "debug";
1421+
let currentPage:
1422+
| "docs"
1423+
| "build"
1424+
| "test"
1425+
| "grade"
1426+
| "verify"
1427+
| "debug";
1428+
if (isDocs) {
1429+
currentPage = "docs";
1430+
} else if (isBuild) {
1431+
currentPage = "build";
1432+
} else if (isTestBot) {
1433+
currentPage = "test";
1434+
} else if (isGrade) {
1435+
currentPage = "grade";
1436+
} else if (isVerify) {
1437+
currentPage = "verify";
1438+
} else {
1439+
currentPage = "debug";
1440+
}
14321441

14331442
useEffect(() => {
14341443
if (activeWorkspaceId || lastWorkspaceIdRef.current) return;
@@ -1447,13 +1456,22 @@ function App() {
14471456
workspaceId?: string;
14481457
};
14491458
if (!res.ok || typeof data.workspaceId !== "string") return;
1450-
const nextPath = currentPage === "test"
1451-
? buildWorkspacePath("test", data.workspaceId)
1452-
: currentPage === "grade"
1453-
? buildGradePath(data.workspaceId)
1454-
: currentPage === "verify"
1455-
? buildWorkspacePath("verify", data.workspaceId)
1456-
: buildWorkspacePath("build", data.workspaceId);
1459+
let nextPath: string;
1460+
switch (currentPage) {
1461+
case "test":
1462+
nextPath = buildWorkspacePath("test", data.workspaceId);
1463+
break;
1464+
case "grade":
1465+
nextPath = buildGradePath(data.workspaceId);
1466+
break;
1467+
case "verify":
1468+
nextPath = buildWorkspacePath("verify", data.workspaceId);
1469+
break;
1470+
case "build":
1471+
default:
1472+
nextPath = buildWorkspacePath("build", data.workspaceId);
1473+
break;
1474+
}
14571475
replacePath(nextPath);
14581476
})
14591477
.finally(() => {
@@ -1500,15 +1518,26 @@ function App() {
15001518
]);
15011519
const handleSelectSession = useCallback(
15021520
(sessionId: string) => {
1503-
const nextPath = currentPage === "test" || currentPage === "docs"
1504-
? buildWorkspacePath("test", sessionId)
1505-
: currentPage === "grade"
1506-
? buildGradePath(sessionId)
1507-
: currentPage === "verify"
1508-
? buildVerifyPath(sessionId)
1509-
: currentPage === "build"
1510-
? buildWorkspacePath("build", sessionId)
1511-
: buildWorkspacePath("debug", sessionId);
1521+
let nextPath: string;
1522+
switch (currentPage) {
1523+
case "docs":
1524+
case "test":
1525+
nextPath = buildWorkspacePath("test", sessionId);
1526+
break;
1527+
case "grade":
1528+
nextPath = buildGradePath(sessionId);
1529+
break;
1530+
case "verify":
1531+
nextPath = buildVerifyPath(sessionId);
1532+
break;
1533+
case "build":
1534+
nextPath = buildWorkspacePath("build", sessionId);
1535+
break;
1536+
case "debug":
1537+
default:
1538+
nextPath = buildWorkspacePath("debug", sessionId);
1539+
break;
1540+
}
15121541
navigate(nextPath);
15131542
setSessionsDrawerOpen(false);
15141543
},
@@ -1605,6 +1634,77 @@ function App() {
16051634
setWorkbenchDrawerOpen(true);
16061635
}, [activeWorkspaceId]);
16071636

1637+
const pageContent = useMemo(() => {
1638+
switch (currentPage) {
1639+
case "docs":
1640+
return <DocsPage />;
1641+
case "build":
1642+
return <BuildPage setNavActions={setNavActions} />;
1643+
case "debug":
1644+
return (
1645+
<SimulatorApp
1646+
basePath={simulatorBasePath}
1647+
setNavActions={setNavActions}
1648+
workspacesApi={workspacesApi}
1649+
onOpenSessionsDrawer={() => setSessionsDrawerOpen(true)}
1650+
activeWorkspaceId={activeWorkspaceId}
1651+
/>
1652+
);
1653+
case "test":
1654+
return (
1655+
<TestBotPage
1656+
onReplaceTestBotSession={handleReplaceTestBotSession}
1657+
onResetTestBotSession={handleResetTestBotSession}
1658+
activeWorkspaceId={activeWorkspaceId}
1659+
requestedRunId={requestedTestRunId}
1660+
resetToken={testBotResetToken}
1661+
setNavActions={setNavActions}
1662+
onFeedbackPersisted={handleFeedbackPersisted}
1663+
onAddErrorToWorkbench={handleAddErrorToWorkbench}
1664+
/>
1665+
);
1666+
case "verify":
1667+
return (
1668+
<VerifyPage
1669+
setNavActions={setNavActions}
1670+
onAppPathChange={handleAppPathChange}
1671+
activeWorkspaceId={activeWorkspaceId}
1672+
/>
1673+
);
1674+
case "grade":
1675+
default:
1676+
return (
1677+
<GradePage
1678+
setNavActions={setNavActions}
1679+
onAppPathChange={handleAppPathChange}
1680+
activeWorkspaceId={activeWorkspaceId}
1681+
requestedGradeRunId={requestedGradeRunId}
1682+
onFlagsUpdate={applyFlagsUpdate}
1683+
onOptimisticToggleFlag={optimisticToggleFlag}
1684+
onOptimisticFlagReason={optimisticFlagReason}
1685+
onAddErrorToWorkbench={handleAddErrorToWorkbench}
1686+
/>
1687+
);
1688+
}
1689+
}, [
1690+
activeWorkspaceId,
1691+
applyFlagsUpdate,
1692+
currentPage,
1693+
handleAddErrorToWorkbench,
1694+
handleAppPathChange,
1695+
handleFeedbackPersisted,
1696+
handleReplaceTestBotSession,
1697+
handleResetTestBotSession,
1698+
optimisticFlagReason,
1699+
optimisticToggleFlag,
1700+
requestedGradeRunId,
1701+
requestedTestRunId,
1702+
setNavActions,
1703+
simulatorBasePath,
1704+
testBotResetToken,
1705+
workspacesApi,
1706+
]);
1707+
16081708
return (
16091709
<WorkspaceProvider
16101710
workspaceId={activeWorkspaceId}
@@ -1716,53 +1816,7 @@ function App() {
17161816
</div>
17171817
<div className="app-content-frame">
17181818
<div className="page-shell">
1719-
{currentPage === "docs"
1720-
? <DocsPage />
1721-
: currentPage === "build"
1722-
? <BuildPage setNavActions={setNavActions} />
1723-
: currentPage === "debug"
1724-
? (
1725-
<SimulatorApp
1726-
basePath={simulatorBasePath}
1727-
setNavActions={setNavActions}
1728-
workspacesApi={workspacesApi}
1729-
onOpenSessionsDrawer={() => setSessionsDrawerOpen(true)}
1730-
activeWorkspaceId={activeWorkspaceId}
1731-
/>
1732-
)
1733-
: currentPage === "test"
1734-
? (
1735-
<TestBotPage
1736-
onReplaceTestBotSession={handleReplaceTestBotSession}
1737-
onResetTestBotSession={handleResetTestBotSession}
1738-
activeWorkspaceId={activeWorkspaceId}
1739-
requestedRunId={requestedTestRunId}
1740-
resetToken={testBotResetToken}
1741-
setNavActions={setNavActions}
1742-
onFeedbackPersisted={handleFeedbackPersisted}
1743-
onAddErrorToWorkbench={handleAddErrorToWorkbench}
1744-
/>
1745-
)
1746-
: currentPage === "verify"
1747-
? (
1748-
<VerifyPage
1749-
setNavActions={setNavActions}
1750-
onAppPathChange={handleAppPathChange}
1751-
activeWorkspaceId={activeWorkspaceId}
1752-
/>
1753-
)
1754-
: (
1755-
<GradePage
1756-
setNavActions={setNavActions}
1757-
onAppPathChange={handleAppPathChange}
1758-
activeWorkspaceId={activeWorkspaceId}
1759-
requestedGradeRunId={requestedGradeRunId}
1760-
onFlagsUpdate={applyFlagsUpdate}
1761-
onOptimisticToggleFlag={optimisticToggleFlag}
1762-
onOptimisticFlagReason={optimisticFlagReason}
1763-
onAddErrorToWorkbench={handleAddErrorToWorkbench}
1764-
/>
1765-
)}
1819+
{pageContent}
17661820
</div>
17671821
{workbenchDrawerOpen && (
17681822
<WorkbenchDrawer

0 commit comments

Comments
 (0)