mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Modify the background color of the agent canvas #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -17,7 +17,7 @@ export function Collapse({
|
|||||||
children,
|
children,
|
||||||
rightContent,
|
rightContent,
|
||||||
open,
|
open,
|
||||||
defaultOpen = true,
|
defaultOpen = false,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
disabled,
|
disabled,
|
||||||
}: CollapseProps) {
|
}: CollapseProps) {
|
||||||
|
|||||||
@ -57,6 +57,7 @@ export const CrossLanguageFormField = ({
|
|||||||
maxCount={100}
|
maxCount={100}
|
||||||
{...field}
|
{...field}
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
|
defaultValue={field.value}
|
||||||
modalPopover
|
modalPopover
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { PropsWithChildren } from 'react';
|
|||||||
|
|
||||||
export function PageHeader({ children }: PropsWithChildren) {
|
export function PageHeader({ children }: PropsWithChildren) {
|
||||||
return (
|
return (
|
||||||
<header className="flex justify-between items-center border-b bg-background-header-bar p-5">
|
<header className="flex justify-between items-center border-b bg-text-title-invert p-5">
|
||||||
{children}
|
{children}
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -31,7 +31,7 @@ const SheetOverlay = React.forwardRef<
|
|||||||
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
||||||
|
|
||||||
const sheetVariants = cva(
|
const sheetVariants = cva(
|
||||||
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
|
'fixed z-50 gap-4 bg-text-title-invert rounded-lg p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
|
||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
side: {
|
side: {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ export function NodeWrapper({ children, className, selected }: IProps) {
|
|||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className={cn(
|
className={cn(
|
||||||
'bg-background-header-bar p-2.5 rounded-md w-[200px] text-xs',
|
'bg-text-title-invert p-2.5 rounded-md w-[200px] text-xs',
|
||||||
{ 'border border-background-checked': selected },
|
{ 'border border-background-checked': selected },
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -18,12 +18,16 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { NodeWrapper } from '../node-wrapper';
|
import { NodeWrapper } from '../node-wrapper';
|
||||||
import { ResizeIcon, controlStyle } from '../resize-icon';
|
import { ResizeIcon, controlStyle } from '../resize-icon';
|
||||||
import { useChangeName, useWatchFormChange } from './use-watch-change';
|
import { useWatchFormChange, useWatchNameFormChange } from './use-watch-change';
|
||||||
|
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
text: z.string(),
|
text: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const NameFormSchema = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
function NoteNode({ data, id, selected }: NodeProps<INoteNode>) {
|
function NoteNode({ data, id, selected }: NodeProps<INoteNode>) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@ -32,10 +36,15 @@ function NoteNode({ data, id, selected }: NodeProps<INoteNode>) {
|
|||||||
defaultValues: data.form,
|
defaultValues: data.form,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { handleChangeName } = useChangeName(id);
|
const nameForm = useForm<z.infer<typeof NameFormSchema>>({
|
||||||
|
resolver: zodResolver(NameFormSchema),
|
||||||
|
defaultValues: { name: data.name },
|
||||||
|
});
|
||||||
|
|
||||||
useWatchFormChange(id, form);
|
useWatchFormChange(id, form);
|
||||||
|
|
||||||
|
useWatchNameFormChange(id, nameForm);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeWrapper
|
<NodeWrapper
|
||||||
className="p-0 w-full h-full flex flex-col rounded-md "
|
className="p-0 w-full h-full flex flex-col rounded-md "
|
||||||
@ -46,14 +55,29 @@ function NoteNode({ data, id, selected }: NodeProps<INoteNode>) {
|
|||||||
</NodeResizeControl>
|
</NodeResizeControl>
|
||||||
<section className="px-1 py-2 flex gap-2 bg-background-highlight items-center note-drag-handle rounded-s-md">
|
<section className="px-1 py-2 flex gap-2 bg-background-highlight items-center note-drag-handle rounded-s-md">
|
||||||
<NotebookPen className="size-4" />
|
<NotebookPen className="size-4" />
|
||||||
|
<Form {...nameForm}>
|
||||||
|
<form>
|
||||||
|
<FormField
|
||||||
|
control={nameForm.control}
|
||||||
|
name="name"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="h-full">
|
||||||
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
|
placeholder={t('flow.notePlaceholder')}
|
||||||
|
{...field}
|
||||||
type="text"
|
type="text"
|
||||||
defaultValue={data.name}
|
/>
|
||||||
onChange={handleChangeName}
|
</FormControl>
|
||||||
></Input>
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
</section>
|
</section>
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form className="flex-1">
|
<form className="flex-1 p-1">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="text"
|
name="text"
|
||||||
@ -62,7 +86,7 @@ function NoteNode({ data, id, selected }: NodeProps<INoteNode>) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Textarea
|
<Textarea
|
||||||
placeholder={t('flow.notePlaceholder')}
|
placeholder={t('flow.notePlaceholder')}
|
||||||
className="resize-none rounded-none p-1 h-full overflow-auto bg-background-header-bar"
|
className="resize-none rounded-none p-1 h-full overflow-auto bg-background-header-bar focus-visible:ring-0 border-none"
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import useGraphStore from '@/pages/agent/store';
|
import useGraphStore from '@/pages/agent/store';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { UseFormReturn, useWatch } from 'react-hook-form';
|
import { UseFormReturn, useWatch } from 'react-hook-form';
|
||||||
|
|
||||||
export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
|
export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
|
||||||
@ -17,15 +17,14 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
|
|||||||
}, [id, updateNodeForm, values]);
|
}, [id, updateNodeForm, values]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useChangeName(id: string) {
|
export function useWatchNameFormChange(id?: string, form?: UseFormReturn<any>) {
|
||||||
|
let values = useWatch({ control: form?.control });
|
||||||
const updateNodeName = useGraphStore((state) => state.updateNodeName);
|
const updateNodeName = useGraphStore((state) => state.updateNodeName);
|
||||||
|
|
||||||
const handleChangeName = useCallback(
|
useEffect(() => {
|
||||||
(e: React.ChangeEvent<HTMLInputElement>) => {
|
// Manually triggered form updates are synchronized to the canvas
|
||||||
updateNodeName(id, e.target.value.trim());
|
if (id) {
|
||||||
},
|
updateNodeName(id, values.name);
|
||||||
[id, updateNodeName],
|
}
|
||||||
);
|
}, [id, updateNodeName, values]);
|
||||||
|
|
||||||
return { handleChangeName };
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,7 +105,6 @@ const AgentChatBox = () => {
|
|||||||
<div ref={ref} />
|
<div ref={ref} />
|
||||||
</div>
|
</div>
|
||||||
<MessageInput
|
<MessageInput
|
||||||
showUploadIcon={false}
|
|
||||||
value={value}
|
value={value}
|
||||||
sendLoading={sendLoading}
|
sendLoading={sendLoading}
|
||||||
disabled={false}
|
disabled={false}
|
||||||
|
|||||||
@ -2,6 +2,6 @@ import { Background } from '@xyflow/react';
|
|||||||
|
|
||||||
export function AgentBackground() {
|
export function AgentBackground() {
|
||||||
return (
|
return (
|
||||||
<Background color="rgba(255,255,255,0.15)" bgColor="rgba(22, 22, 24, 1)" />
|
<Background color="rgba(255,255,255,0.15)" bgColor="rgba(11, 11, 12, 1)" />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import { z } from 'zod';
|
|||||||
import { initialRetrievalValues } from '../../constant';
|
import { initialRetrievalValues } from '../../constant';
|
||||||
import { useWatchFormChange } from '../../hooks/use-watch-form-change';
|
import { useWatchFormChange } from '../../hooks/use-watch-form-change';
|
||||||
import { INextOperatorForm } from '../../interface';
|
import { INextOperatorForm } from '../../interface';
|
||||||
|
import { FormWrapper } from '../components/form-wrapper';
|
||||||
import { Output } from '../components/output';
|
import { Output } from '../components/output';
|
||||||
import { QueryVariable } from '../components/query-variable';
|
import { QueryVariable } from '../components/query-variable';
|
||||||
import { useValues } from './use-values';
|
import { useValues } from './use-values';
|
||||||
@ -92,12 +93,7 @@ function RetrievalForm({ node }: INextOperatorForm) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<FormWrapper>
|
||||||
className="space-y-6 p-4"
|
|
||||||
onSubmit={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<FormContainer>
|
<FormContainer>
|
||||||
<QueryVariable></QueryVariable>
|
<QueryVariable></QueryVariable>
|
||||||
<KnowledgeBaseFormField></KnowledgeBaseFormField>
|
<KnowledgeBaseFormField></KnowledgeBaseFormField>
|
||||||
@ -114,7 +110,7 @@ function RetrievalForm({ node }: INextOperatorForm) {
|
|||||||
<UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField>
|
<UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField>
|
||||||
</FormContainer>
|
</FormContainer>
|
||||||
<Output list={outputList}></Output>
|
<Output list={outputList}></Output>
|
||||||
</form>
|
</FormWrapper>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ export default function Agent() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section className="flex flex-col w-full flex-1">
|
||||||
<div className="px-8 pt-8 ">
|
<div className="px-8 pt-8 ">
|
||||||
<ListFilterBar
|
<ListFilterBar
|
||||||
title="Agents"
|
title="Agents"
|
||||||
@ -45,7 +45,8 @@ export default function Agent() {
|
|||||||
</Button>
|
</Button>
|
||||||
</ListFilterBar>
|
</ListFilterBar>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap gap-4 max-h-[78vh] overflow-auto px-8">
|
<div className="flex-1 overflow-auto">
|
||||||
|
<div className="flex flex-wrap gap-4 px-8">
|
||||||
{data.map((x) => {
|
{data.map((x) => {
|
||||||
return (
|
return (
|
||||||
<AgentCard
|
<AgentCard
|
||||||
@ -56,7 +57,8 @@ export default function Agent() {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-8 px-8">
|
</div>
|
||||||
|
<div className="mt-8 px-8 pb-8">
|
||||||
<RAGFlowPagination
|
<RAGFlowPagination
|
||||||
{...pick(pagination, 'current', 'pageSize')}
|
{...pick(pagination, 'current', 'pageSize')}
|
||||||
total={pagination.total}
|
total={pagination.total}
|
||||||
|
|||||||
@ -52,7 +52,6 @@ module.exports = {
|
|||||||
'background-card': 'var(--background-card)',
|
'background-card': 'var(--background-card)',
|
||||||
'background-checked': 'var(--background-checked)',
|
'background-checked': 'var(--background-checked)',
|
||||||
'background-highlight': 'var(--background-highlight)',
|
'background-highlight': 'var(--background-highlight)',
|
||||||
'background-agent': 'var(--background-agent)',
|
|
||||||
|
|
||||||
'input-border': 'var(--input-border)',
|
'input-border': 'var(--input-border)',
|
||||||
'dot-green': 'var(--dot-green)',
|
'dot-green': 'var(--dot-green)',
|
||||||
|
|||||||
@ -199,7 +199,6 @@
|
|||||||
--background-checked: rgba(76, 164, 231, 1);
|
--background-checked: rgba(76, 164, 231, 1);
|
||||||
|
|
||||||
--background-highlight: rgba(76, 164, 231, 0.1);
|
--background-highlight: rgba(76, 164, 231, 0.1);
|
||||||
--background-agent: rgba(22, 22, 24, 1);
|
|
||||||
|
|
||||||
--input-border: rgba(255, 255, 255, 0.2);
|
--input-border: rgba(255, 255, 255, 0.2);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user