Skip to content

Commit

Permalink
Merge branch 'main' into fix/stream_error_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext authored Nov 20, 2024
2 parents aefa085 + 3e18b44 commit a33c8fd
Show file tree
Hide file tree
Showing 102 changed files with 2,727 additions and 1,783 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "Chromatic"

on: push

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-chromatic
cancel-in-progress: true

jobs:
changed-files:
runs-on: ubuntu-latest
name: changed-files
outputs:
all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }}
any_changed: ${{ steps.changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
apps/nextjs/**
chromatic:
name: Run Chromatic
needs: [changed-files]
if: ${{ needs.changed-files.outputs.any_changed == 'true' }}

runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Inject Doppler env vars
uses: dopplerhq/[email protected]
id: doppler
with:
doppler-token: ${{ secrets.DOPPLER_TOKEN }}
inject-env-vars: true
- name: Run Chromatic
uses: chromaui/action@latest
with:
workingDir: apps/nextjs
exitZeroOnChanges: true
exitOnceUploaded: true
onlyChanged: true
31 changes: 31 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# [1.16.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.15.0...v1.16.0) (2024-11-18)


### Features

* add FeatureFlagProvider ([#353](https://github.com/oaknational/oak-ai-lesson-assistant/issues/353)) ([1d4995e](https://github.com/oaknational/oak-ai-lesson-assistant/commit/1d4995ea0c82772259bc5312ba8d872dbd30b2b9))
* link to hubspot form from requests for full access and higher rate - AI-626 AI-627 ([#359](https://github.com/oaknational/oak-ai-lesson-assistant/issues/359)) ([05ccce6](https://github.com/oaknational/oak-ai-lesson-assistant/commit/05ccce69348b03df2edee01dd1a27814a071be3d))

# [1.15.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.14.2...v1.15.0) (2024-11-13)


### Features

* add additional materials button - AI-539 [migration] ([#255](https://github.com/oaknational/oak-ai-lesson-assistant/issues/255)) ([d0fe2d0](https://github.com/oaknational/oak-ai-lesson-assistant/commit/d0fe2d015865b89ea2287993652a6f8111f0ae4a))
* prisma health check - AI-625 ([#356](https://github.com/oaknational/oak-ai-lesson-assistant/issues/356)) ([854950d](https://github.com/oaknational/oak-ai-lesson-assistant/commit/854950d51524eb8d84a0ec9695c88b67f829fd8d))

## [1.14.2](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.14.1...v1.14.2) (2024-11-12)


### Bug Fixes

* design-changes-to-footer ([#324](https://github.com/oaknational/oak-ai-lesson-assistant/issues/324)) ([273cfdc](https://github.com/oaknational/oak-ai-lesson-assistant/commit/273cfdc668ca45def0b8a68dc08b7301974e1def))
* only categorise initial user input once ([#348](https://github.com/oaknational/oak-ai-lesson-assistant/issues/348)) ([dd5bf71](https://github.com/oaknational/oak-ai-lesson-assistant/commit/dd5bf71a21421ac6e0beb60b4bab560cb159d877))

## [1.14.1](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.14.0...v1.14.1) (2024-11-07)


### Bug Fixes

* allow requests without a cookie header ([#352](https://github.com/oaknational/oak-ai-lesson-assistant/issues/352)) ([80f5050](https://github.com/oaknational/oak-ai-lesson-assistant/commit/80f50507ab370032a3ef6767bcfe5da0d8b6fe82))

# [1.14.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.13.1...v1.14.0) (2024-11-07)


Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tests-e2e/.auth
.env.sentry-build-plugin

*storybook.log
.chromatic.log

# Playwright artifacts
playwright-report
playwright-report
11 changes: 0 additions & 11 deletions apps/nextjs/.storybook/MockClerkProvider.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from "react";

import { Theme } from "@radix-ui/themes";
import "@radix-ui/themes/styles.css";

export const ThemeDecorator = (Story: React.ComponentType) => (
export const RadixThemeDecorator = (Story: React.ComponentType) => (
<Theme>
<Story />
</Theme>
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs/.storybook/preview.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import "../src/app/globals.css";
@import "../src/app/theme-config.css";
@import "../../../node_modules/@radix-ui/themes/styles.css";
60 changes: 26 additions & 34 deletions apps/nextjs/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ import "@fontsource/lexend/900.css";
import { OakThemeProvider, oakDefaultTheme } from "@oaknational/oak-components";
import type { Preview, Decorator } from "@storybook/react";

// ModerationProvider is coming in the main Chat.tsx refactor
//import { ModerationProvider } from "../src/components/AppComponents/Chat/Chat/ModerationProvider";
import { TooltipProvider } from "../src/components/AppComponents/Chat/ui/tooltip";
import { DialogProvider } from "../src/components/AppComponents/DialogContext";
import { CookieConsentProvider } from "../src/components/ContextProviders/CookieConsentProvider";
import { DemoProvider } from "../src/components/ContextProviders/Demo";
import LessonPlanTrackingProvider from "../src/lib/analytics/lessonPlanTrackingContext";
import { SidebarProvider } from "../src/lib/hooks/use-sidebar";
import { AnalyticsProvider } from "../src/mocks/analytics/provider";
import { ClerkDecorator } from "../src/mocks/clerk/ClerkDecorator";
import { TRPCReactProvider } from "../src/utils/trpc";
import { MockClerkProvider } from "./MockClerkProvider";
import { ThemeDecorator } from "./ThemeDecorator";
import { RadixThemeDecorator } from "./decorators/RadixThemeDecorator";
import "./preview.css";

const preview: Preview = {
Expand All @@ -32,36 +26,34 @@ const preview: Preview = {
},
},
},
tags: ["autodocs"],
};

// Providers not currently used
// - CookieConsentProvider
// - DemoProvider
// - LessonPlanTrackingProvider
// - DialogProvider
// - SidebarProvider
// - ChatModerationProvider

export const decorators: Decorator[] = [
ThemeDecorator,
RadixThemeDecorator,
ClerkDecorator,
(Story) => (
<MockClerkProvider>
<CookieConsentProvider>
{" "}
<TRPCReactProvider>
<DemoProvider>
<AnalyticsProvider>
<LessonPlanTrackingProvider chatId={"faked"}>
<DialogProvider>
<OakThemeProvider theme={oakDefaultTheme}>
<SidebarProvider>
<TooltipProvider>
{/* <ModerationProvider initialModerations={[]}> */}
<Story />
{/* </ModerationProvider> */}
</TooltipProvider>
</SidebarProvider>
</OakThemeProvider>
</DialogProvider>
</LessonPlanTrackingProvider>
</AnalyticsProvider>
</DemoProvider>{" "}
</TRPCReactProvider>
</CookieConsentProvider>
</MockClerkProvider>
<>
{/* TODO: Mock tRPC calls with MSW */}
<TRPCReactProvider>
<AnalyticsProvider>
<DialogProvider>
<OakThemeProvider theme={oakDefaultTheme}>
<TooltipProvider>
<Story />
</TooltipProvider>
</OakThemeProvider>
</DialogProvider>
</AnalyticsProvider>
</TRPCReactProvider>
</>
),
];

Expand Down
6 changes: 6 additions & 0 deletions apps/nextjs/chromatic.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"onlyChanged": true,
"projectId": "Project:672908473f629875f0be294f",
"storybookBaseDir": "apps/nextjs",
"zip": true
}
5 changes: 3 additions & 2 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"with-env": "dotenv -e ../../.env --",
"aila": "tsx scripts/aila-cli.ts",
"storybook": "dotenv -e ../../.env -- storybook dev -p 6006 --no-open",
"build-storybook": "dotenv -e ../../.env -- storybook build"
"build-storybook": "dotenv -e ../../.env -- storybook build",
"chromatic": "pnpm with-env pnpm dlx chromatic"
},
"prettier": "@oakai/prettier-config",
"dependencies": {
Expand All @@ -44,7 +45,7 @@
"@oakai/exports": "*",
"@oakai/logger": "*",
"@oakai/prettier-config": "*",
"@oaknational/oak-components": "^1.26.0",
"@oaknational/oak-components": "^1.44.0",
"@oaknational/oak-consent-client": "^2.1.0",
"@portabletext/react": "^3.1.0",
"@prisma/client": "5.16.1",
Expand Down
68 changes: 68 additions & 0 deletions apps/nextjs/src/app/aila/[id]/download/DownloadView.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import type { AilaPersistedChat } from "@oakai/aila/src/protocol/schema";
import type { Meta, StoryObj } from "@storybook/react";

import { DemoProvider } from "../../../../../src/components/ContextProviders/Demo";
import { DownloadContent } from "./DownloadView";

const meta: Meta<typeof DownloadContent> = {
title: "Pages/Chat/Download",
component: DownloadContent,
parameters: {
layout: "fullscreen",
},
decorators: [
(Story) => (
<DemoProvider>
<Story />
</DemoProvider>
),
],
};

export default meta;
type Story = StoryObj<typeof DownloadContent>;

const chat: AilaPersistedChat = {
id: "nSLmbQ1LO75zLTcA",
path: "/aila/nSLmbQ1LO75zLTcA",
title: "The End of Roman Britain",
userId: "user_2nQuq4jFWLfo4w1WNA6xEBp93IY",
lessonPlan: {
title: "The End of Roman Britain",
subject: "history",
keyStage: "key-stage-3",
learningOutcome:
"I can explain the factors leading to the end of Roman rule in Britain and its impact on society.",
learningCycles: [
"Identify the key factors that led to the exit of the Romans from Britain.",
"Discuss the immediate social and economic impacts of the Roman departure on Britain.",
"Explore how archaeologists have uncovered evidence of the Roman era in Britain.",
],
},
relevantLessons: [],
createdAt: 1732008272042,
updatedAt: 1732008303927,
iteration: 2,
messages: [
{
id: "u-Mksqgrrlq7-02EvL",
content:
"Create a lesson plan about The End of Roman Britain for Key Stage 3 History",
role: "user",
},
{
id: "a-ttJ8OIwaxn4aFEOq",
content:
'{"type":"llmMessage","sectionsToEdit":["learningOutcome","learningCycles"],"patches":[{"type":"patch","reasoning":"Creating a new lesson plan from scratch as no existing Oak lessons are available for this topic. Setting a clear learning outcome and defining the learning cycles to structure the lesson effectively.","value":{"type":"string","op":"add","path":"/learningOutcome","value":"I can explain the factors leading to the end of Roman rule in Britain and its impact on society."},"status":"complete"},{"type":"patch","reasoning":"Outlining the learning cycles to provide a structured approach to teaching the factors leading to the end of Roman Britain, the immediate effects, and the archaeological evidence.","value":{"type":"string-array","op":"add","path":"/learningCycles","value":["Identify the key factors that led to the exit of the Romans from Britain.","Discuss the immediate social and economic impacts of the Roman departure on Britain.","Explore how archaeologists have uncovered evidence of the Roman era in Britain."]},"status":"complete"}],"sectionsEdited":["learningOutcome","learningCycles"],"prompt":{"type":"text","value":"Are the learning outcome and learning cycles appropriate for your pupils? If not, suggest an edit. Otherwise, tap **Continue** to move on to the next step."},"status":"complete"}',
role: "assistant",
},
],
subject: "history",
keyStage: "key-stage-3",
};

export const Default: Story = {
args: {
chat,
},
};
12 changes: 10 additions & 2 deletions apps/nextjs/src/app/aila/[id]/download/DownloadView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useDownloadView } from "./useDownloadView";
type DownloadViewProps = Readonly<{
chat: AilaPersistedChat;
}>;
export function DownloadView({ chat }: Readonly<DownloadViewProps>) {
export function DownloadContent({ chat }: Readonly<DownloadViewProps>) {
const { lessonPlan, id } = chat;
const {
lessonSlidesExport,
Expand All @@ -37,7 +37,7 @@ export function DownloadView({ chat }: Readonly<DownloadViewProps>) {
const isLessonComplete = totalSectionsComplete >= totalSections;

return (
<Layout>
<>
<DialogRoot>
<DialogContents
chatId={chat.id}
Expand Down Expand Up @@ -194,6 +194,14 @@ export function DownloadView({ chat }: Readonly<DownloadViewProps>) {
</Box>
</div>
</DialogRoot>
</>
);
}

export function DownloadView(props: Readonly<DownloadViewProps>) {
return (
<Layout>
<DownloadContent {...props} />
</Layout>
);
}
40 changes: 40 additions & 0 deletions apps/nextjs/src/app/aila/[id]/share/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
import type { Meta, StoryObj } from "@storybook/react";

import ShareChat from "./";

const meta: Meta<typeof ShareChat> = {
title: "Pages/Chat/Share",
component: ShareChat,
parameters: {
layout: "fullscreen",
},
};

export default meta;
type Story = StoryObj<typeof ShareChat>;

const lessonPlan: LooseLessonPlan = {
title: "The End of Roman Britain",
subject: "history",
keyStage: "key-stage-3",
learningOutcome:
"I can explain the factors leading to the end of Roman rule in Britain and its impact on society.",
learningCycles: [
"Identify the key factors that led to the exit of the Romans from Britain.",
"Discuss the immediate social and economic impacts of the Roman departure on Britain.",
"Explore how archaeologists have uncovered evidence of the Roman era in Britain.",
],
};

export const Default: Story = {
args: {
lessonPlan,
creatorsName: "Mr Teacher",
moderation: {
id: "mock-moderation-id",
categories: ["l/strong-language"],
justification: "Mock sensitive result",
},
},
};
Loading

0 comments on commit a33c8fd

Please sign in to comment.