Skip to content
Open
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
71 changes: 43 additions & 28 deletions src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,41 @@ const LearnContent: React.FC<LearnContentProps> = ({ file }) => {

return (
<ContentContainer>
{currentIndex !== steps.length - 1 && (
<div style={{ display: "flex", justifyContent: "flex-end", marginBottom: "12px" }}>
<Button
type="link"
onClick={handleExitLearning}
style={{
background: "transparent",
border: "none",
color: "#6b7280",
cursor: "pointer",
fontSize: "0.9rem",
textDecoration: "underline",
padding: 0,
height: "auto"
}}
>
Exit learning
</Button>
</div>
)}
<div style={{ display: "flex", justifyContent: "flex-end", marginBottom: "12px", gap: "10px" }}>
{steps[currentIndex]?.sampleName && (
<Button
type="primary"
onClick={() => navigate(`/?sample=${encodeURIComponent(steps[currentIndex].sampleName!)}`)}
style={{
backgroundColor: colors.primary,
borderColor: colors.primary,
fontSize: "0.9rem",
height: "auto",
padding: "4px 12px"
}}
>
Open in Playground
</Button>
Comment on lines +104 to +118
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new "Open in Playground" button introduces a new learn→playground navigation path, but there’s no component test covering that the button renders for modules with a sampleName and that clicking it navigates to /?sample=.... Given existing component tests in src/tests/components, adding a test for this behavior would help prevent regressions.

Copilot generated this review using guidance from repository custom instructions.
)}
{currentIndex !== steps.length - 1 && (
<Button
type="link"
onClick={handleExitLearning}
style={{
background: "transparent",
border: "none",
color: "#6b7280",
cursor: "pointer",
fontSize: "0.9rem",
textDecoration: "underline",
padding: 0,
height: "auto"
}}
>
Exit learning
</Button>
)}
</div>
{content && (
<ReactMarkdown
rehypePlugins={[rehypeRaw, rehypeHighlight]}
Expand Down Expand Up @@ -153,14 +168,14 @@ const LearnContent: React.FC<LearnContentProps> = ({ file }) => {
<LeftOutlined /> Previous
</NavigationButton>
{currentIndex === steps.length - 1 ? (
<NavigationButton onClick={handleExitLearning}>
Finish
</NavigationButton>
) : (
<NavigationButton onClick={handleNext}>
Next <RightOutlined />
</NavigationButton>
)}
<NavigationButton onClick={handleExitLearning}>
Finish
</NavigationButton>
) : (
<NavigationButton onClick={handleNext}>
Next <RightOutlined />
</NavigationButton>
)}
</NavigationButtons>
</ContentContainer>
);
Expand Down
6 changes: 3 additions & 3 deletions src/constants/learningSteps/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export const steps = [
{ title: "Overview", link: "/learn/intro" },
{ title: "Module 1", link: "/learn/module1" },
{ title: "Module 2", link: "/learn/module2" },
{ title: "Module 3", link: "/learn/module3" },
{ title: "Module 1", link: "/learn/module1", sampleName: "Hello World" },
{ title: "Module 2", link: "/learn/module2", sampleName: "Formula Now" },
{ title: "Module 3", link: "/learn/module3", sampleName: "Join" },
Comment on lines +5 to +7
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sampleName values are hardcoded strings that must exactly match Sample.NAME values for loadSample to work. This duplicates source-of-truth data and can silently break if sample names change. Consider importing the NAME constants from the relevant src/samples/* modules (or exporting a shared sample ID enum) and referencing those here instead of repeating the strings.

Copilot uses AI. Check for mistakes.
];
3 changes: 3 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,11 @@ const useAppStore = create<AppState>()(
init: async () => {
const params = new URLSearchParams(window.location.search);
const compressedData = params.get("data");
const sampleName = params.get("sample");
if (compressedData) {
await get().loadFromLink(compressedData);
} else if (sampleName) {
await get().loadSample(sampleName);
} else {
await get().rebuild();
}
Comment on lines 234 to 244
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init() now calls loadSample(sampleName) when ?sample=... is present, but loadSample is a no-op when the sample name is unknown. In that case init() will skip rebuild() and the app can remain with agreementHtml unset/empty. Consider making loadSample throw/return a boolean when the sample is not found, and have init() fall back to rebuild() (and/or surface an error) when the sample cannot be loaded.

Copilot uses AI. Check for mistakes.
Comment on lines 234 to 244
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior (loading a sample via ?sample=... in init()) is user-facing and affects initialization flow, but there’s no unit/integration test covering it. Please add a store-level test that sets window.location.search to include sample and asserts loadSample is invoked (or sampleName/editor values update) and agreementHtml is produced after initialization.

Copilot generated this review using guidance from repository custom instructions.
Expand Down
Loading