Skip to content

Commit a38ea61

Browse files
committed
Address review: move DEFAULT_MODERATOR_INSTRUCTIONS to constants, harden URL-failure test
1 parent 9278d64 commit a38ea61

4 files changed

Lines changed: 16 additions & 15 deletions

File tree

frontend/src/assets/configurations/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,3 +530,12 @@ export const TRIGGER_LABELS: Record<string, string> = {
530530
new_thread: "On Thread",
531531
new_message: "On Message",
532532
} as const;
533+
534+
// Default agent task instructions used when creating a thread-moderation
535+
// CorpusAction (rendered as the placeholder/initial value in the modal).
536+
export const DEFAULT_MODERATOR_INSTRUCTIONS = `You are a thread moderator for this corpus. Your role is to:
537+
1. Monitor discussion threads and messages for policy compliance
538+
2. Take appropriate moderation actions when needed
539+
3. Respond helpfully to user questions when appropriate
540+
541+
You have access to thread context, messages, and moderation tools. Use them judiciously.`;

frontend/src/components/corpuses/CreateCorpusActionModal.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { StyledTextArea } from "../widgets/modals/styled";
2020
import { toast } from "react-toastify";
2121
import _ from "lodash";
2222
import { OS_LEGAL_COLORS } from "../../assets/configurations/osLegalStyles";
23+
import { DEFAULT_MODERATOR_INSTRUCTIONS } from "../../assets/configurations/constants";
2324
import { InlineBadge } from "../agents/AgentBadges";
2425
import { FormField } from "../widgets/form/FormField";
2526

@@ -71,13 +72,6 @@ const DEFAULT_MODERATION_TOOLS = [
7172
{ name: "unpin_thread", description: "Unpin a pinned thread" },
7273
] as const;
7374

74-
export const DEFAULT_MODERATOR_INSTRUCTIONS = `You are a thread moderator for this corpus. Your role is to:
75-
1. Monitor discussion threads and messages for policy compliance
76-
2. Take appropriate moderation actions when needed
77-
3. Respond helpfully to user questions when appropriate
78-
79-
You have access to thread context, messages, and moderation tools. Use them judiciously.`;
80-
8175
const DEFAULT_DOCUMENT_AGENT_INSTRUCTIONS =
8276
"You are a document processing agent for this corpus.";
8377

frontend/tests/CorpusDescriptionEditor.ct.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,10 @@ test.describe("CorpusDescriptionEditor", () => {
743743
mount,
744744
page,
745745
}) => {
746-
// Intercept the markdown URL with a 500 error so the fetch().then() throws
746+
// Abort the network request so the fetch promise rejects and the
747+
// component's .catch() branch (setCurrentContent("")) runs.
747748
await page.route("**/test-md/**", async (route: any) => {
748-
await route.fulfill({
749-
status: 500,
750-
body: "boom",
751-
});
749+
await route.abort("failed");
752750
});
753751

754752
const component = await mount(
@@ -762,12 +760,12 @@ test.describe("CorpusDescriptionEditor", () => {
762760
timeout: 20000,
763761
});
764762

765-
// Editor remains mounted but body may contain text (the fetch itself
766-
// succeeds — 500 body). The important thing is the component didn't crash.
767763
const textarea = page.locator(
768764
'textarea[placeholder="Write your corpus description in Markdown..."]'
769765
);
770766
await expect(textarea).toBeVisible({ timeout: 5000 });
767+
// The catch branch resets content to empty string; pin that contract.
768+
await expect(textarea).toHaveValue("", { timeout: 5000 });
771769

772770
await component.unmount();
773771
});

frontend/tests/CreateCorpusActionModal.ct.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
CREATE_CORPUS_ACTION,
1414
UPDATE_CORPUS_ACTION,
1515
} from "../src/graphql/mutations";
16-
import { DEFAULT_MODERATOR_INSTRUCTIONS } from "../src/components/corpuses/CreateCorpusActionModal";
16+
import { DEFAULT_MODERATOR_INSTRUCTIONS } from "../src/assets/configurations/constants";
1717
import { docScreenshot } from "./utils/docScreenshot";
1818

1919
const TEST_CORPUS_ID = "corpus-123";

0 commit comments

Comments
 (0)