Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: release candidate 2024-09-12 #128

Merged
merged 22 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4d8d4dc
chore: ensure whole moderation result is logged (#83)
mantagen Sep 9, 2024
5a37dc0
chore: add workflow to merge approved RCs (#100)
codeincontext Sep 9, 2024
76e3cd5
fix(moderation prompt): lower false positives in toxic category (#102)
mantagen Sep 10, 2024
f2d1a57
fix: exports page overlap (#105)
tomwisecodes Sep 10, 2024
91e31bb
chore: remove second aila heading (#103)
tomwisecodes Sep 10, 2024
5f58830
chore: add space before email link (#110)
JBR90 Sep 10, 2024
45e5a63
fix: in app feedback snags (#108)
tomwisecodes Sep 10, 2024
cb9f431
chore: back to lesson from help (#104)
tomwisecodes Sep 10, 2024
dedfd24
fix: sidebar getting stuck at 0 (#107)
tomwisecodes Sep 10, 2024
c235310
fix: mobile video sizing (#106)
tomwisecodes Sep 10, 2024
741c935
fix: return protocol error messages for user restrictions (#111)
codeincontext Sep 11, 2024
b02ce31
feat: update content guidance text (#75)
codeincontext Sep 11, 2024
c066f97
feat: add pwa manifest (#101)
simonrose121 Sep 11, 2024
5094c47
feat: invalidate moderation and unblock user (#109)
mantagen Sep 11, 2024
18bfccc
fix: error colour precedence in message wrapper (#112)
JBR90 Sep 11, 2024
36b26ba
fix: change extensions in mobile button (#115)
tomwisecodes Sep 11, 2024
db1b0d8
fix: quiz designer snags (#113)
tomwisecodes Sep 11, 2024
cbbf4d2
fix: correct paths for help (#118)
tomwisecodes Sep 11, 2024
a492838
fix: help button (#120)
tomwisecodes Sep 12, 2024
705a267
fix: survey not found bug (#121)
mantagen Sep 12, 2024
683d787
build(release v1.6.1): See CHANGE_LOG.md
semantic-release-bot Sep 12, 2024
7402e72
fix: use new AI protocol format for friendly errors (#122)
codeincontext Sep 12, 2024
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
27 changes: 27 additions & 0 deletions .github/workflows/accept_release_candidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Accept Release Candidate

on:
pull_request_review:
types: [submitted]

jobs:
merge:
name: Merge Release Candidate
if: |
github.event.review.state == 'approved' &&
github.event.pull_request.merged == false &&
github.event.pull_request.base.ref == 'production' &&
startsWith(github.event.pull_request.head.ref, 'rc')

runs-on: ubuntu-latest
steps:
- name: "Merge pull request"
uses: "actions/github-script@v7"
with:
script: |
await github.rest.pulls.merge({
merge_method: "merge",
owner: context.repo.owner,
pull_number: context.issue.number,
repo: context.repo.repo,
})
7 changes: 7 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.6.1](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.6.0...v1.6.1) (2024-09-12)


### Bug Fixes

* survey not found bug ([#121](https://github.com/oaknational/oak-ai-lesson-assistant/issues/121)) ([e22cfa5](https://github.com/oaknational/oak-ai-lesson-assistant/commit/e22cfa5cf15765fec20928aedb806645dd32895f))

# [1.6.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.5.1...v1.6.0) (2024-09-06)


Expand Down
15 changes: 15 additions & 0 deletions apps/nextjs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["../../.eslintrc.cjs", "next", "plugin:storybook/recommended"],
rules: {
"no-restricted-imports": [
"error",
{
paths: [
{
name: "posthog-js/react",
importNames: ["usePostHog"],
message:
"usePostHog doesn't support multiple PostHog instances, use useAnalytics instead",
},
],
},
],
},
};
2 changes: 1 addition & 1 deletion apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"languagedetect": "^2.0.0",
"next": "14.2.5",
"object-hash": "^3.0.0",
"openai": "^4.52.0",
"openai": "^4.58.1",
"p-limit": "^6.1.0",
"partial-json-parser": "^1.2.2",
"posthog-js": "^1.139.1",
Expand Down
21 changes: 0 additions & 21 deletions apps/nextjs/src/app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use server";

import { auth } from "@clerk/nextjs/server";
import { AilaPersistedChat, chatSchema } from "@oakai/aila/src/protocol/schema";
import { Prisma, prisma } from "@oakai/db";
import * as Sentry from "@sentry/nextjs";
Expand Down Expand Up @@ -58,26 +57,6 @@ export async function getChatById(
);
}

export async function getChatForAuthenticatedUser(
id: string,
): Promise<AilaPersistedChat | null> {
const { userId } = auth();

const chat = await getChatById(id);

if (!chat) {
return null;
}

const userIsOwner = chat.userId === userId;

if (!userIsOwner) {
return null;
}

return chat;
}

export async function getSharedChatById(
id: string,
): Promise<AilaPersistedChat | null> {
Expand Down
29 changes: 29 additions & 0 deletions apps/nextjs/src/app/admin/aila/[chatId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use client";

import { OakMaxWidth } from "@oaknational/oak-components";

import Layout from "@/components/AppComponents/Layout";

interface ChatLayoutProps {
children: React.ReactNode;
}

export default function ChatLayout({ children }: Readonly<ChatLayoutProps>) {
return (
<div className="relative flex h-full overflow-hidden">
<div className="group w-full overflow-auto pl-0 duration-300 ease-in-out animate-in peer-[[data-state=open]]:lg:pl-[250px] peer-[[data-state=open]]:xl:pl-[300px]">
<Layout>
<div className="mt-27">
<OakMaxWidth
$maxWidth={["all-spacing-21", "all-spacing-24"]}
$pa="inner-padding-m"
$ph={["inner-padding-none", "inner-padding-s"]}
>
{children}
</OakMaxWidth>
</div>
</Layout>
</div>
</div>
);
}
45 changes: 45 additions & 0 deletions apps/nextjs/src/app/admin/aila/[chatId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use client";

import { useUser } from "#clerk/nextjs";
import { redirect } from "#next/navigation";

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

import { AdminChatView } from "./view";

interface AdminChatProps {
params: {
chatId: string;
};
}

export default function AdminChat({ params }: Readonly<AdminChatProps>) {
const user = useUser();
const { chatId } = params;
const { data: chat, isLoading: isChatLoading } = trpc.admin.getChat.useQuery({
id: chatId,
});
const { data: moderations, isLoading: isModerationsLoading } =
trpc.admin.getModerations.useQuery({ id: chatId });

if (user.isLoaded && !user.isSignedIn) {
redirect(`/sign-in?next=/admin/aila/${params.chatId}`);
}

if (isChatLoading || isModerationsLoading) {
return <LoadingWheel />;
}

console.log("chat", chat);

if (!chat) {
return <div>No chat found</div>;
}

if (!moderations) {
return <div>No moderations found</div>;
}

return <AdminChatView chat={chat} moderations={moderations} />;
}
91 changes: 91 additions & 0 deletions apps/nextjs/src/app/admin/aila/[chatId]/view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { useState } from "react";

import { type AilaPersistedChat } from "@oakai/aila/src/protocol/schema";
import { getSafetyResult } from "@oakai/core/src/utils/ailaModeration/helpers";
import { type Moderation } from "@oakai/db";
import { OakAccordion, OakPrimaryButton } from "@oaknational/oak-components";

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

function ModerationListItem({ moderation }: { moderation: Moderation }) {
const { id, invalidatedAt } = moderation;
const [invalidated, setInvalidated] = useState(Boolean(invalidatedAt));
const invalidateModeration = trpc.admin.invalidateModeration.useMutation({
onSuccess: () => setInvalidated(true),
});
return (
<li
key={moderation.id}
className={`rounded-md border p-4 shadow-sm ${invalidated ? "opacity-50" : "opacity-100"}`}
>
<div className="flex w-full items-start justify-between">
<div className="flex w-full flex-col space-y-8">
<div className="flex items-center">
<p className="font-medium capitalize">
{getSafetyResult(moderation)}
</p>
<OakPrimaryButton
iconName="cross"
className="ml-auto"
onClick={() =>
invalidateModeration.mutateAsync({ moderationId: id })
}
isLoading={invalidateModeration.isLoading}
disabled={!!invalidated}
>
{invalidated ? "Invalidated" : "Invalidate"}
</OakPrimaryButton>
</div>

<blockquote className="border-l-4 bg-gray-50 p-4 pl-4 italic text-zinc-700 shadow-md">
{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>
))}
</div>
</div>
</div>
</li>
);
}

export function AdminChatView({
chat,
moderations,
}: {
chat: AilaPersistedChat;
moderations: Moderation[];
}) {
return (
<>
<h1 className="mb-18">{chat.lessonPlan.title}</h1>
<h2 className="mb-4 text-2xl font-bold">Moderations</h2>
<ul className="mb-18 space-y-4">
{moderations.map((moderation) => {
return (
<ModerationListItem key={moderation.id} moderation={moderation} />
);
})}
</ul>

<h2 className="mb-4 text-2xl font-bold">Raw data</h2>
<OakAccordion header="Chat raw" id="accordion-1">
<pre>
<code>{JSON.stringify(chat, null, 2)}</code>
</pre>
</OakAccordion>
<OakAccordion header="Moderations raw" id="accordion-1">
<pre>
<code>{JSON.stringify(moderations, null, 2)}</code>
</pre>
</OakAccordion>
</>
);
}
9 changes: 8 additions & 1 deletion apps/nextjs/src/app/aila/help/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useRef } from "react";

import { OakLink } from "@oaknational/oak-components";
import { useSearchParams } from "next/navigation";

import { Header } from "@/components/AppComponents/Chat/header";
import GetInTouchBox from "@/components/AppComponents/GetInTouchBox";
Expand All @@ -25,6 +26,9 @@ const Help = () => {
}
};

const searchParams = useSearchParams();
const ailaId = searchParams.get("ailaId");

return (
<>
<Header />
Expand Down Expand Up @@ -94,7 +98,10 @@ const Help = () => {

<div className="mb-40 max-w-[800px]">
<div className="mb-20 mt-10 sm:hidden">
<OakLink href="/aila" iconName="chevron-left">
<OakLink
href={ailaId ? `/aila/${ailaId}` : `/aila`}
iconName="chevron-left"
>
Back to Aila
</OakLink>
</div>
Expand Down
Loading
Loading