Skip to content
Draft
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: 4 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"test": "tsx --test tests/*.test.ts",
"build:solver": "node scripts/build-solver.mjs",
"test:solver-native": "node scripts/test-solver-native.mjs",
"bench:solver": "tsx scripts/bench-solver.ts"
"bench:solver": "tsx scripts/bench-solver.ts",
"demo:planner": "vite --config tests/vite.semester.config.ts --host 127.0.0.1 --port 5190",
"build:planner-demo": "vite build --config tests/vite.semester.config.ts",
"pack:planner-demo": "npm run build:planner-demo && node scripts/pack-planner-demo.mjs"
},
"dependencies": {
"@ai-sdk/anthropic": "^4.0.0",
Expand Down
30 changes: 30 additions & 0 deletions app/scripts/pack-planner-demo.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
import { gzipSync } from "node:zlib";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";

const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const dist = join(root, "dist/semester-preview");
const entry = readFileSync(join(dist, "tests/semester-lab.html"), "utf8");
const jsPath = entry.match(/src="([^\"]+\.js)"/)?.[1];
const cssPath = entry.match(/href="([^\"]+\.css)"/)?.[1];
if (!jsPath || !cssPath)
throw new Error("Build the planner demo before packing it.");
const js = readFileSync(join(dist, jsPath.replace(/^\//, "")), "utf8");
let css = readFileSync(join(dist, cssPath.replace(/^\//, "")), "utf8");
const font = readFileSync(
join(root, "public/fonts/caveat-latin.woff2"),
).toString("base64");
css = css.replaceAll("/fonts/caveat-latin.woff2", `data:font/woff2;base64,${font}`);
const zipped = gzipSync(js, { level: 9 }).toString("base64");
const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>PI. Semester Lab</title><style>${css}</style></head><body><div id="root"></div><script type="module">
const data=Uint8Array.from(atob(${JSON.stringify(zipped)}),c=>c.charCodeAt(0));
const source=await new Response(new Blob([data]).stream().pipeThrough(new DecompressionStream('gzip'))).text();
const script=document.createElement('script');script.type='module';script.textContent=source;document.body.appendChild(script);
</script></body></html>`;
mkdirSync(join(root, ".artifacts"), { recursive: true });
const target = join(root, ".artifacts/semester-lab.html");
writeFileSync(target, html);
console.log(
`Packed standalone demo. ${Buffer.byteLength(html).toLocaleString()} bytes. ${target}`,
);
32 changes: 32 additions & 0 deletions app/solver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,35 @@ schedule, registers courses, or reserves seats.
The component is lazy-loaded only when the lab is opened. While a constraint
change is being solved, the previous timetable is labeled as previous and its
controls are unavailable. No obsolete worker result can replace newer input.

## Offline presentation and development demo

Run these commands from `app`.

```
npm run demo:planner
```

Open `http://127.0.0.1:5190/tests/semester-lab.html`. This Vite entry uses the real
component, worker, and Wasm engine with explicitly synthetic section times. It
makes no model or Junction API calls and requires no sign-in. The production
planner still uses its existing authentication.

```
npm run pack:planner-demo
```

This builds the demo and creates `.artifacts/semester-lab.html`. Open the file
directly in a modern browser supporting WebAssembly, workers, and
`DecompressionStream`. React, CSS, fonts, worker code, and Wasm are embedded in
one file. No HTTP requests are needed to run the planner. The GitHub link in the
header opens the repository only when clicked. Generated output stays ignored.

Presentation sequence. Pin the initial week, protect Friday, move the earliest
start to 10am, compare another plan, and click a class to lock it. Undo a change.
Then open the impossible-week example. Three courses each have two slots, every
pair fits, but there is no assignment for all three. Finally set an impossible
start time in the normal semester and use a verified relaxation to recover.

Keep the SAMPLE DATA label visible. A successful demo does not validate real
Junction records, registration eligibility, or production account integration.
81 changes: 81 additions & 0 deletions app/tests/semester-lab-demo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
body {
background: #f6f5ef;
}
.lab-demo-shell {
max-width: 1250px;
margin: 0 auto;
padding: 0 44px 45px;
}
.lab-demo-bar {
height: 73px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 18px;
margin-bottom: 31px;
border-bottom: 1px solid #dedfd2;
}
.lab-demo-bar > a {
color: #2c3932;
display: inline-flex;
gap: 9px;
align-items: center;
text-decoration: none;
font-size: 14px;
}
.lab-demo-pi {
font-family: Georgia, serif;
font-size: 29px;
color: #21786c;
line-height: 1;
}
.lab-demo-bar > a > span:last-child {
padding-left: 10px;
border-left: 1px solid #d5d7c9;
font-size: 11px;
color: #6b7565;
}
.lab-demo-bar > div {
display: flex;
align-items: center;
gap: 15px;
}
.lab-demo-label {
font-size: 8px;
font-weight: 650;
letter-spacing: 0.12em;
color: #69705f;
}
.lab-demo-bar button {
font-size: 10px;
color: #466551;
border-bottom: 1px solid #b8c7b6;
padding: 3px 0;
}
@media (max-width: 1000px) {
.lab-demo-shell {
padding: 0 24px 32px;
}
.lab-demo-label {
display: none;
}
}
@media (max-width: 700px) {
.lab-demo-shell {
padding: 0 16px 25px;
}
.lab-demo-bar {
height: auto;
min-height: 67px;
margin-bottom: 23px;
flex-wrap: wrap;
gap: 8px;
padding: 12px 0;
}
.lab-demo-bar > div {
gap: 10px;
}
.lab-demo-bar > a > span:last-child {
display: none;
}
}
2 changes: 2 additions & 0 deletions app/tests/semester-lab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!doctype html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>PI. Semester Lab prototype</title></head><body><div id="root"></div><script type="module" src="./semester-lab.tsx"></script></body></html>
53 changes: 53 additions & 0 deletions app/tests/semester-lab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { useState } from "react";
import { createRoot } from "react-dom/client";
import { SemesterLab } from "../src/client/components/SemesterLab";
import { impossible, semester } from "./fixtures/semester";
import "../src/client/styles.css";
import "./semester-lab-demo.css";

function Demo() {
const [scenario, setScenario] = useState<"semester" | "impossible">(
"semester",
);
const [version, setVersion] = useState(0);
return (
<div className="lab-demo-shell">
<div className="lab-demo-bar">
<a
href="https://github.com/TigerAppsOrg/pi"
target="_blank"
rel="noreferrer"
aria-label="PI on GitHub"
>
<span className="lab-demo-pi">π</span>
<strong>PI</strong>
<span>TigerApps</span>
</a>
<div>
<span className="lab-demo-label">
WORKING PROTOTYPE · SAMPLE DATA
</span>
<button
type="button"
onClick={() => {
setScenario(scenario === "semester" ? "impossible" : "semester");
setVersion((v) => v + 1);
}}
>
{scenario === "semester"
? "Try an impossible week"
: "Back to the semester"}
</button>
<button type="button" onClick={() => setVersion((v) => v + 1)}>
Reset
</button>
</div>
</div>
<SemesterLab
key={`${scenario}-${version}`}
problem={scenario === "semester" ? semester : impossible}
/>
</div>
);
}
createRoot(document.getElementById("root")!).render(<Demo />);
17 changes: 17 additions & 0 deletions app/tests/vite.semester.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { fileURLToPath } from "node:url";

export default defineConfig({
root: fileURLToPath(new URL("..", import.meta.url)),
plugins: [react()],
worker: { format: "iife" },
build: {
outDir: "dist/semester-preview",
assetsInlineLimit: 1000000,
rollupOptions: {
input: "tests/semester-lab.html",
output: { inlineDynamicImports: true },
},
},
});
Loading