Skip to content

Commit

Permalink
Merge branch 'main' into feat-test-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
JBR90 committed Dec 3, 2024
2 parents 88a0d62 + 122bc4e commit 96d22fd
Show file tree
Hide file tree
Showing 53 changed files with 1,026 additions and 820 deletions.
39 changes: 39 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
## [1.17.1](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.17.0...v1.17.1) (2024-12-03)


### Bug Fixes

* add linting command to db package ([#392](https://github.com/oaknational/oak-ai-lesson-assistant/issues/392)) ([d2177d5](https://github.com/oaknational/oak-ai-lesson-assistant/commit/d2177d5c061e973affd1ea52b0ef025c8c37cb29))
* address sonar major issues ([#393](https://github.com/oaknational/oak-ai-lesson-assistant/issues/393)) ([202a21f](https://github.com/oaknational/oak-ai-lesson-assistant/commit/202a21fbac0d457514c9944735b174c79dced08c))
* do not define components inline ([#413](https://github.com/oaknational/oak-ai-lesson-assistant/issues/413)) ([abda175](https://github.com/oaknational/oak-ai-lesson-assistant/commit/abda1753afecd9385b19b695767568abdd4383c1))
* do not use array index for key / use void for onSubmit ([#409](https://github.com/oaknational/oak-ai-lesson-assistant/issues/409)) ([44b5961](https://github.com/oaknational/oak-ai-lesson-assistant/commit/44b59617f3af8cad83110efdc2cb4df23d06e073))
* help page cloudflare email ([#399](https://github.com/oaknational/oak-ai-lesson-assistant/issues/399)) ([f6262f2](https://github.com/oaknational/oak-ai-lesson-assistant/commit/f6262f26d470a30ea721343bbab2cbfded77b91d))
* high and medium severity bugs on sonar cloud - AI-637 ([#379](https://github.com/oaknational/oak-ai-lesson-assistant/issues/379)) ([fb0258e](https://github.com/oaknational/oak-ai-lesson-assistant/commit/fb0258ec2f3c0d5fb79d884d3918827460cba404))
* icons in dialogs ([#398](https://github.com/oaknational/oak-ai-lesson-assistant/issues/398)) ([9700214](https://github.com/oaknational/oak-ai-lesson-assistant/commit/970021462a94b800dba270130f5ba1b1548e8745))
* intentionality of async / promise code for question generation ([#402](https://github.com/oaknational/oak-ai-lesson-assistant/issues/402)) ([65d1c5f](https://github.com/oaknational/oak-ai-lesson-assistant/commit/65d1c5f89c1b238e24315c02bde2e9eb253b4da3))
* memoize the sidebar context provider's value ([#408](https://github.com/oaknational/oak-ai-lesson-assistant/issues/408)) ([60ee010](https://github.com/oaknational/oak-ai-lesson-assistant/commit/60ee0102ea1ee733d6527c5460fd404cd7773292))
* minor sonar issues ([#390](https://github.com/oaknational/oak-ai-lesson-assistant/issues/390)) ([015cd25](https://github.com/oaknational/oak-ai-lesson-assistant/commit/015cd25984c3e5d1a545afef39fd111aa5245d58))
* prefer nullish coalescing ([#391](https://github.com/oaknational/oak-ai-lesson-assistant/issues/391)) ([b40def9](https://github.com/oaknational/oak-ai-lesson-assistant/commit/b40def9cfd3d69a0089db861a2f6ed47321a3753))
* readonly props for icons.tsx ([#389](https://github.com/oaknational/oak-ai-lesson-assistant/issues/389)) ([7b4d5bc](https://github.com/oaknational/oak-ai-lesson-assistant/commit/7b4d5bcc508b3179ea5313ec783aba90d1a7f3ae))
* revert tabindex change ([#404](https://github.com/oaknational/oak-ai-lesson-assistant/issues/404)) ([ac72713](https://github.com/oaknational/oak-ai-lesson-assistant/commit/ac72713dc54595f6bfacfd99e63899616f18b8ec))
* sonar maintain issues [#4](https://github.com/oaknational/oak-ai-lesson-assistant/issues/4) ([#405](https://github.com/oaknational/oak-ai-lesson-assistant/issues/405)) ([eca0019](https://github.com/oaknational/oak-ai-lesson-assistant/commit/eca001996a684f8d01465196c1c600d00e43a964))
* sonar maintain linting [#1](https://github.com/oaknational/oak-ai-lesson-assistant/issues/1) ([#394](https://github.com/oaknational/oak-ai-lesson-assistant/issues/394)) ([f4d95fc](https://github.com/oaknational/oak-ai-lesson-assistant/commit/f4d95fcbf39c3c43c3811f8c2022a37af363826a))
* sonar maintain linting [#2](https://github.com/oaknational/oak-ai-lesson-assistant/issues/2) ([#395](https://github.com/oaknational/oak-ai-lesson-assistant/issues/395)) ([1ed9d60](https://github.com/oaknational/oak-ai-lesson-assistant/commit/1ed9d6028713b096a68a0558d67608dc9efb812f))
* sonar maintain linting [#3](https://github.com/oaknational/oak-ai-lesson-assistant/issues/3) ([#403](https://github.com/oaknational/oak-ai-lesson-assistant/issues/403)) ([daa7efe](https://github.com/oaknational/oak-ai-lesson-assistant/commit/daa7efe6a2d5d2501f5108cd3c1ccaec86126655))
* sonar minors [#5](https://github.com/oaknational/oak-ai-lesson-assistant/issues/5) ([#414](https://github.com/oaknational/oak-ai-lesson-assistant/issues/414)) ([5f749f4](https://github.com/oaknational/oak-ai-lesson-assistant/commit/5f749f42f9f5d3d78c736438e313f4f5eff5406b))

# [1.17.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.16.2...v1.17.0) (2024-11-28)


### Bug Fixes

* assert readonly props ([#381](https://github.com/oaknational/oak-ai-lesson-assistant/issues/381)) ([cd88576](https://github.com/oaknational/oak-ai-lesson-assistant/commit/cd88576c5a337ad30f48783d74ea45d746a60956))
* help page cloudflare email ([#399](https://github.com/oaknational/oak-ai-lesson-assistant/issues/399)) ([391b67c](https://github.com/oaknational/oak-ai-lesson-assistant/commit/391b67c27a4048d4e422be22226d8d5aa1ac71bd))
* minor linting ([#384](https://github.com/oaknational/oak-ai-lesson-assistant/issues/384)) ([ec4ce6e](https://github.com/oaknational/oak-ai-lesson-assistant/commit/ec4ce6e5dcc7dbd4e242be65fd3b5f9708b94a40))
* svg clip-rule should be clipRule in JSX ([#382](https://github.com/oaknational/oak-ai-lesson-assistant/issues/382)) ([610d8c8](https://github.com/oaknational/oak-ai-lesson-assistant/commit/610d8c838273de24212a8531a8bc4b6136c05db1))


### Features

* move delete all button and restyle side menu ([#375](https://github.com/oaknational/oak-ai-lesson-assistant/issues/375)) ([69b2371](https://github.com/oaknational/oak-ai-lesson-assistant/commit/69b2371bf9ee7e7f783aa191ba6932dba0171837))

## [1.16.2](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.16.1...v1.16.2) (2024-11-25)


Expand Down
1 change: 0 additions & 1 deletion apps/nextjs/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export const decorators: Decorator[] = [
ClerkDecorator,
(Story) => (
<>
{/* TODO: Mock tRPC calls with MSW */}
<TRPCReactProvider>
<AnalyticsProvider>
<DialogProvider>
Expand Down
17 changes: 12 additions & 5 deletions apps/nextjs/src/ai-apps/quiz-designer/quizRequestGeneration.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { GenerationPart } from "@oakai/core/src/types";
import { aiLogger } from "@oakai/logger";

import { getAgesFromKeyStage } from "@/utils/getAgesFromKeyStage";

import { extraQuizPromptInfo } from "./extraQuizPromptInfo";
import type { QuizAppState, QuizAppStateQuestion } from "./state/types";

type RequestionGenerationInputs = {
const logger = aiLogger("quiz");

export type RequestionGenerationInputs = {
lastGenerationId: string | null;
sessionId: string;
factQuestion: string;
Expand All @@ -26,14 +29,16 @@ type RequestionGenerationInputs = {
};
};

type QuizRequestGenerationProps = {
export type QuizRequestGenerationProps = {
state: QuizAppState;
questionRow: QuizAppStateQuestion;
lastGeneration: GenerationPart<string> | undefined;
requestGeneration: (requestionGenInputs: RequestionGenerationInputs) => void;
requestGeneration: (
requestionGenInputs: RequestionGenerationInputs,
) => Promise<void>;
};

export function quizRequestGeneration({
export async function quizRequestGeneration({
state,
questionRow,
requestGeneration,
Expand All @@ -47,7 +52,7 @@ export function quizRequestGeneration({
state,
questionRow,
});
requestGeneration({
await requestGeneration({
lastGenerationId: lastGeneration?.lastGenerationId ?? null,
sessionId,
factQuestion: `${topic}: ${questionRow.question.value}`,
Expand All @@ -68,5 +73,7 @@ export function quizRequestGeneration({
(distractor) => distractor.value,
),
},
}).catch((e) => {
logger.error(e);
});
}
26 changes: 16 additions & 10 deletions apps/nextjs/src/app/admin/aila/[chatId]/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { OakAccordion, OakPrimaryButton } from "@oaknational/oak-components";

import { trpc } from "@/utils/trpc";

function ModerationListItem({ moderation }: { readonly moderation: Moderation }) {
function ModerationListItem({
moderation,
}: {
readonly moderation: Moderation;
}) {
const { id, invalidatedAt } = moderation;
const [invalidated, setInvalidated] = useState(Boolean(invalidatedAt));
const invalidateModeration = trpc.admin.invalidateModeration.useMutation({
Expand All @@ -28,7 +32,7 @@ function ModerationListItem({ moderation }: { readonly moderation: Moderation })
iconName="cross"
className="ml-auto"
onClick={() =>
invalidateModeration.mutateAsync({ moderationId: id })
void invalidateModeration.mutateAsync({ moderationId: id })
}
isLoading={invalidateModeration.isLoading}
disabled={!!invalidated}
Expand All @@ -41,14 +45,16 @@ function ModerationListItem({ moderation }: { readonly moderation: Moderation })
{moderation.justification}
</blockquote>
<div className="mt-2 space-x-2">
{moderation.categories.map((category, index) => (
<span
key={index}
className="inline-block rounded-md bg-zinc-300 px-8 py-4 text-xs font-semibold text-zinc-800"
>
{String(category)}
</span>
))}
{Array.from(new Set(moderation.categories))
.map((c) => String(c))
.map((category) => (
<span
key={category}
className="inline-block rounded-md bg-zinc-300 px-8 py-4 text-xs font-semibold text-zinc-800"
>
{category}
</span>
))}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Meta, StoryObj } from "@storybook/react";
import { ChatModerationDisplay } from "./ChatModerationDisplay";

const meta: Meta<typeof ChatModerationDisplay> = {
title: "Components/Chat/ChatModerationDisplay",
title: "Components/Dialogs/ChatModerationDisplay",
component: ChatModerationDisplay,
tags: ["autodocs"],
decorators: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import useAnalytics from "@/lib/analytics/useAnalytics";
import { useAtBottom } from "@/lib/hooks/use-at-bottom";
import { cn } from "@/lib/utils";

export function ButtonScrollToBottom({ className, ...props }: ButtonProps) {
export function ButtonScrollToBottom({
className,
...props
}: Readonly<ButtonProps>) {
const isAtBottom = useAtBottom();
const { trackEvent } = useAnalytics();
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Meta, StoryObj } from "@storybook/react";

import { ChatModerationProvider } from "@/components/ContextProviders/ChatModerationContext";

import { DemoLimitMessage } from "./demo-limit-message";

const meta: Meta<typeof DemoLimitMessage> = {
title: "Components/Chat/DemoLimitMessage",
component: DemoLimitMessage,
tags: ["autodocs"],
decorators: [
(Story) => (
<ChatModerationProvider chatId="test-chat-id">
<Story />
</ChatModerationProvider>
),
],
};

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

export const Default: Story = {
args: {},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";

import { ChatMessage } from "@/components/AppComponents/Chat/chat-message";

export function DemoLimitMessage({ id }: Readonly<{ id: string }>) {
return (
<div className="w-full flex-col gap-11">
<ChatMessage
chatId={id}
ailaStreamingStatus="Idle"
message={{
id: "demo-limit",
role: "assistant",
content:
'{"type": "error", "message": "**Your lesson is complete**\\nYou can no longer edit this lesson. [Create new lesson.](/aila)"}',
}}
persistedModerations={[]}
separator={<span className="my-10 flex" />}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Meta, StoryObj } from "@storybook/react";

import { DemoContext } from "@/components/ContextProviders/Demo";

import { InChatDownloadButtons } from "./in-chat-download-buttons";

const DemoDecorator: Story["decorators"] = (Story, { parameters }) => (
<DemoContext.Provider
value={{
isDemoUser: false,
isSharingEnabled: true,
...parameters.demoContext,
}}
>
<Story />
</DemoContext.Provider>
);

const meta: Meta<typeof InChatDownloadButtons> = {
title: "Components/Chat/InChatDownloadButtons",
component: InChatDownloadButtons,
tags: ["autodocs"],
args: {
id: "test-chat-id",
},
decorators: [DemoDecorator],
};

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

export const Default: Story = {};

export const SharingDisabled: Story = {
parameters: {
demoContext: {
isSharingEnabled: false,
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { OakBox, OakFlex, OakIcon, OakSpan } from "@oaknational/oak-components";
import Link from "next/link";

import { useDemoUser } from "@/components/ContextProviders/Demo";

import { useDialog } from "../../DialogContext";

export const InChatDownloadButtons = ({ id }: { readonly id: string }) => {
const demo = useDemoUser();
const { setDialogWindow } = useDialog();

return (
<OakFlex $flexDirection="column" $gap="all-spacing-7" $mv="space-between-l">
{demo.isSharingEnabled && (
<Link
href={demo.isSharingEnabled ? `/aila/download/${id}` : "#"}
onClick={() => {
if (!demo.isSharingEnabled) {
setDialogWindow("demo-share-locked");
}
}}
>
<InnerInChatButton iconName="download">Download</InnerInChatButton>
</Link>
)}
<button
onClick={() => {
if (demo.isSharingEnabled) {
setDialogWindow("share-chat");
} else {
setDialogWindow("demo-share-locked");
}
}}
>
<InnerInChatButton iconName="share">Share</InnerInChatButton>
</button>
</OakFlex>
);
};

const InnerInChatButton = ({
iconName,
children,
}: {
readonly iconName: "download" | "share";
readonly children: string;
}) => {
return (
<OakFlex
$pa="inner-padding-m"
$gap="all-spacing-3"
$background="white"
$borderRadius="border-radius-m"
$alignItems="center"
$dropShadow="drop-shadow-standard"
>
<OakBox $transform="scale">
<OakIcon iconName={iconName} $width="all-spacing-7" />
</OakBox>
<OakSpan $font="body-2">{children}</OakSpan>
</OakFlex>
);
};
Loading

0 comments on commit 96d22fd

Please sign in to comment.