Skip to content

Commit

Permalink
Merge branch 'main' into fix/delete-all-button
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwisecodes committed Nov 18, 2024
2 parents 50ba4d3 + d0fe2d0 commit 7fb0f40
Show file tree
Hide file tree
Showing 58 changed files with 1,655 additions and 410 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
45 changes: 45 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
## [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)


### Bug Fixes

* add missing dependencies to lesson plan tracking context ([#307](https://github.com/oaknational/oak-ai-lesson-assistant/issues/307)) ([3758dfc](https://github.com/oaknational/oak-ai-lesson-assistant/commit/3758dfcda8a937ca363c0eb40014b01d18c93c23))
* add missing prisma import ([#342](https://github.com/oaknational/oak-ai-lesson-assistant/issues/342)) ([a0ac1de](https://github.com/oaknational/oak-ai-lesson-assistant/commit/a0ac1de89dc6dda38ab64a02054e992072332fd5))
* disable feature flagg polling in tests ([c44e1f1](https://github.com/oaknational/oak-ai-lesson-assistant/commit/c44e1f10e98dcda37367f2cd03b324078c7b910f))
* null render in sidebar provider ([#337](https://github.com/oaknational/oak-ai-lesson-assistant/issues/337)) ([9a12851](https://github.com/oaknational/oak-ai-lesson-assistant/commit/9a12851471aeb5f36e7aebd9c1652d0c2a565966))
* remaining linting fixes ([#272](https://github.com/oaknational/oak-ai-lesson-assistant/issues/272)) ([18a0f70](https://github.com/oaknational/oak-ai-lesson-assistant/commit/18a0f7061bc9d8bd72c4f6d44eec003acd878df1))
* set up server side styled-components ([f221c24](https://github.com/oaknational/oak-ai-lesson-assistant/commit/f221c2442617031fa694708da953b4a5f1ea5e6c))
* skip instrumentation when running turbopack - fix HMR ([4d6fd3b](https://github.com/oaknational/oak-ai-lesson-assistant/commit/4d6fd3b963710703b547cda5b2085bfc7f00f941))


### Features

* add rag schema (migration) ([#343](https://github.com/oaknational/oak-ai-lesson-assistant/issues/343)) ([638f43f](https://github.com/oaknational/oak-ai-lesson-assistant/commit/638f43fa0167f28974250f3da2d67ef95aaae57e))
* allow us to configure the server port for local testing ([#308](https://github.com/oaknational/oak-ai-lesson-assistant/issues/308)) ([33bee19](https://github.com/oaknational/oak-ai-lesson-assistant/commit/33bee19e5e631428b648159452ef5af5dbec36bd))
* bootstrap posthog feature flags with local evaluation ([15e8a67](https://github.com/oaknational/oak-ai-lesson-assistant/commit/15e8a67e9a1ce8e08baa5642c7fffbd2193d3b64))
* sync featureFlagGroup from clerk to posthog ([46b4f13](https://github.com/oaknational/oak-ai-lesson-assistant/commit/46b4f13a1e887177035a9d195886f34647a87ac9))
* update emails to use html ([#319](https://github.com/oaknational/oak-ai-lesson-assistant/issues/319)) ([a71e7bc](https://github.com/oaknational/oak-ai-lesson-assistant/commit/a71e7bc4b6416ef01b48de4c950805f8244e658b))
* use featureFlagGroup claim for feature flags ([759534a](https://github.com/oaknational/oak-ai-lesson-assistant/commit/759534a8b8189c25d665b34db1cdf7f0b7a8f31e))

## [1.13.1](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.13.0...v1.13.1) (2024-11-05)


### Bug Fixes

* revert prisma to 5.16.1 ([#336](https://github.com/oaknational/oak-ai-lesson-assistant/issues/336)) ([a593618](https://github.com/oaknational/oak-ai-lesson-assistant/commit/a593618b013607fbde75cfa98663d7298db7ff89))

# [1.13.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.12.1...v1.13.0) (2024-10-31)


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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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
56 changes: 22 additions & 34 deletions apps/nextjs/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@ 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 { 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 @@ -35,33 +27,29 @@ const preview: Preview = {
tags: ["autodocs"],
};

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

export const decorators: Decorator[] = [
ThemeDecorator,
RadixThemeDecorator,
(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>
<TooltipProvider>
<Story />
</TooltipProvider>
</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 @@ -47,7 +48,7 @@
"@oaknational/oak-components": "^1.26.0",
"@oaknational/oak-consent-client": "^2.1.0",
"@portabletext/react": "^3.1.0",
"@prisma/client": "^5.21.1",
"@prisma/client": "5.16.1",
"@prisma/extension-accelerate": "^1.0.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/aila-download-all/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async function getHandler(req: Request): Promise<Response> {
}

const lessonExport = await prisma.lessonExport.findFirst({
where: { gdriveFileId: fileId, userId },
where: { gdriveFileId: fileId, userId, expiredAt: null },
});

if (!lessonExport) {
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs/src/app/api/aila-download/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ async function getHandler(req: Request): Promise<Response> {
where: {
gdriveFileId: fileId,
userId,
expiredAt: null,
},
cacheStrategy: { ttl: 60 * 5, swr: 60 * 2 },
});
Expand Down
4 changes: 3 additions & 1 deletion apps/nextjs/src/app/api/chat/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const defaultConfig: Config = {
prisma: globalPrisma,
createAila: async (options) => {
const webActionsPlugin = createWebActionsPlugin(globalPrisma);
return new Aila({
const createdAila = new Aila({
...options,
plugins: [...(options.plugins || []), webActionsPlugin],
prisma: options.prisma ?? globalPrisma,
Expand All @@ -26,5 +26,7 @@ export const defaultConfig: Config = {
userId: undefined,
},
});
await createdAila.initialise();
return createdAila;
},
};
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/chat/errorHandling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe("handleChatException", () => {
type: "error",
value: "Rate limit exceeded",
message:
"**Unfortunately you’ve exceeded your fair usage limit for today.** Please come back in 1 hour. If you require a higher limit, please [make a request](https://forms.gle/tHsYMZJR367zydsG8).",
"**Unfortunately you’ve exceeded your fair usage limit for today.** Please come back in 1 hour. If you require a higher limit, please [make a request](https://share.hsforms.com/118hyngR-QSS0J7vZEVlRSgbvumd).",
});
});
});
Expand Down
4 changes: 3 additions & 1 deletion apps/nextjs/src/app/api/chat/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ describe("Chat API Route", () => {
chatCategoriser: mockChatCategoriser,
},
};
return new Aila(ailaConfig);
const ailaInstance = new Aila(ailaConfig);
await ailaInstance.initialise();
return ailaInstance;
}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
prisma: {} as any,
Expand Down
Loading

0 comments on commit 7fb0f40

Please sign in to comment.