Skip to content

Commit 1ce0560

Browse files
authored
Fixed policy ai editor scroll (#1857)
* chore(package): lock packageManager to [email protected] * refactor(policy): update policy details and AI assistant components for improved functionality * feat(docs): add ai-policy-editor page to documentation * refactor(policy): enhance layout and styling of policy details and AI assistant components * refactor(ui): update conversation component styles for consistency
1 parent 9f7c6a0 commit 1ce0560

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

apps/app/src/app/(app)/[orgId]/policies/[policyId]/editor/components/PolicyDetails.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ export function PolicyContentManager({
188188
<div className="space-y-4">
189189
<Card>
190190
<CardContent className="p-4">
191-
<div className="flex gap-4">
192-
<div className="flex-1 min-w-0">
191+
<div className="flex gap-4 h-[60vh]">
192+
<div className="flex-1 min-w-0 h-full overflow-y-auto">
193193
<Tabs
194194
defaultValue={displayFormat}
195195
onValueChange={(format) =>
@@ -240,7 +240,7 @@ export function PolicyContentManager({
240240
</div>
241241

242242
{showAiAssistant && isAiPolicyAssistantEnabled && (
243-
<div className="w-80 shrink-0 min-h-[400px] self-stretch flex flex-col">
243+
<div className="w-80 shrink-0 self-stretch flex flex-col overflow-hidden">
244244
<PolicyAiAssistant
245245
messages={messages}
246246
status={status}

apps/app/src/app/(app)/[orgId]/policies/[policyId]/editor/components/ai/policy-ai-assistant.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function PolicyAiAssistant({
6969
};
7070

7171
return (
72-
<div className="flex h-full flex-col border-l bg-background">
72+
<div className="flex h-full min-h-0 flex-col border-l bg-background">
7373
<div className="flex items-center justify-between border-b px-3 py-2">
7474
<span className="text-sm font-medium">AI Assistant</span>
7575
{close && (
@@ -79,7 +79,7 @@ export function PolicyAiAssistant({
7979
)}
8080
</div>
8181

82-
<Conversation>
82+
<Conversation className="min-h-0" aria-label="Policy AI assistant conversation">
8383
<ConversationContent className="gap-3 p-3">
8484
{messages.length === 0 ? (
8585
<div className="text-sm text-muted-foreground py-4">

apps/app/src/app/api/policies/[policyId]/chat/route.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { getPolicyTools } from '@/app/(app)/[orgId]/policies/[policyId]/editor/tools/policy-tools';
21
import { auth } from '@/utils/auth';
32
import { openai } from '@ai-sdk/openai';
43
import { db } from '@db';
54
import { convertToModelMessages, streamText, type UIMessage } from 'ai';
65
import { headers } from 'next/headers';
76
import { NextResponse } from 'next/server';
7+
import { getPolicyTools } from '../../../../(app)/[orgId]/policies/[policyId]/editor/tools/policy-tools';
88

99
export const maxDuration = 60;
1010

@@ -80,6 +80,8 @@ Current Policy Content:
8080
${policyContentText}
8181
---
8282
83+
IMPORTANT: This assistant is ONLY for editing policies. You MUST always use one of the available tools.
84+
8385
Your role:
8486
1. Edit and improve policies when asked
8587
2. Ensure policies remain compliant with relevant frameworks
@@ -99,8 +101,10 @@ COMMUNICATION STYLE:
99101
- Be concise and direct
100102
- Ask clarifying questions when the user's intent is unclear
101103
- One sentence to explain, then act (use tool or ask question)
104+
- Your conversational messages to the user must be plain text only (no markdown headers, bold, italics, bullet points, or code blocks)
105+
- Note: The policy content in proposePolicy tool MUST still use proper markdown formatting
102106
103-
CRITICAL MARKDOWN FORMATTING RULES (when using proposePolicy):
107+
CRITICAL MARKDOWN FORMATTING RULES:
104108
- Every heading MUST have text after the # symbols (e.g., "## Section Title", never just "##")
105109
- Preserve the original document structure and all sections
106110
- Use proper heading hierarchy (# for title, ## for sections, ### for subsections)

packages/ui/src/components/ai-elements/conversation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type ConversationProps = ComponentProps<typeof StickToBottom>;
1212
export const Conversation = ({ className, ...props }: ConversationProps) => (
1313
<StickToBottom
1414
className={cn(
15-
'relative flex-1 overflow-y-hidden bg-gradient-to-b from-background via-background to-muted/60',
15+
'relative flex-1 overflow-hidden bg-linear-to-b from-background via-background to-muted/60',
1616
className,
1717
)}
1818
initial="smooth"

0 commit comments

Comments
 (0)