Merge branch 'staging' into devin/1755828439-report-editor-streaming-loading

This commit is contained in:
Nate Kelley 2025-08-21 22:07:04 -06:00
commit ad92215018
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
6 changed files with 32 additions and 33 deletions

View File

@ -12,7 +12,7 @@ const editorVariants = cva(
cn( cn(
'group/editor', 'group/editor',
'relative w-full cursor-text overflow-x-visible break-words whitespace-pre-wrap select-text', 'relative w-full cursor-text overflow-x-visible break-words whitespace-pre-wrap select-text',
'rounded-md ring-offset-background focus-visible:outline-none', 'ring-offset-background focus-visible:outline-none',
'placeholder:text-muted-foreground/80 **:data-slate-placeholder:!top-1/2 **:data-slate-placeholder:-translate-y-1/2 **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!', 'placeholder:text-muted-foreground/80 **:data-slate-placeholder:!top-1/2 **:data-slate-placeholder:-translate-y-1/2 **:data-slate-placeholder:text-muted-foreground/80 **:data-slate-placeholder:opacity-100!',
'[&_strong]:font-bold' '[&_strong]:font-bold'
), ),
@ -21,16 +21,16 @@ const editorVariants = cva(
variant: 'default' variant: 'default'
}, },
variants: { variants: {
disabled: { readOnly: {
true: 'cursor-not-allowed opacity-50' true: ''
}, },
focused: { focused: {
true: 'ring-2 ring-ring ring-offset-2' true: 'ring-2 ring-ring ring-offset-2'
}, },
variant: { variant: {
comment: cn('rounded-none border-none bg-transparent text-sm'), comment: cn('rounded-none border-none bg-transparent text-sm'),
default: 'size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]', default: 'px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]',
fullWidth: 'size-full px-16 pt-4 pb-72 text-base sm:px-24', fullWidth: 'px-16 pt-4 pb-72 text-base sm:px-24',
none: '' none: ''
} }
} }
@ -40,20 +40,20 @@ const editorVariants = cva(
export type EditorProps = PlateContentProps & VariantProps<typeof editorVariants>; export type EditorProps = PlateContentProps & VariantProps<typeof editorVariants>;
export const Editor = React.forwardRef<HTMLDivElement, EditorProps>( export const Editor = React.forwardRef<HTMLDivElement, EditorProps>(
({ className, disabled, focused, variant, children, ...props }, ref) => { ({ className, disabled, focused, variant, readOnly, ...props }, ref) => {
return ( return (
<PlateContent <PlateContent
ref={ref} ref={ref}
className={cn( className={cn(
editorVariants({ editorVariants({
disabled, readOnly,
focused, focused,
variant variant
}), }),
className className
)} )}
disabled={disabled} readOnly={readOnly}
disableDefaultStyles disableDefaultStyles={true}
{...props} {...props}
/> />
); );

View File

@ -5,8 +5,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
interface EditorContainerProps { interface EditorContainerProps {
className?: string; className?: string;
variant?: 'default' | 'comment'; variant?: 'default' | 'comment';
readonly?: boolean; readOnly?: boolean;
disabled?: boolean;
} }
const editorContainerVariants = cva( const editorContainerVariants = cva(
@ -27,13 +26,13 @@ const editorContainerVariants = cva(
'has-data-readonly:w-fit has-data-readonly:cursor-default has-data-readonly:border-transparent has-data-readonly:focus-within:[box-shadow:none]' 'has-data-readonly:w-fit has-data-readonly:cursor-default has-data-readonly:border-transparent has-data-readonly:focus-within:[box-shadow:none]'
) )
}, },
readonly: { readOnly: {
true: 'cursor-text' true: 'cursor-default user-select-none '
} }
}, },
defaultVariants: { defaultVariants: {
variant: 'default', variant: 'default',
readonly: false readOnly: false
} }
} }
); );
@ -41,8 +40,7 @@ const editorContainerVariants = cva(
export function EditorContainer({ export function EditorContainer({
className, className,
variant, variant,
disabled, readOnly,
readonly,
...props ...props
}: React.ComponentProps<'div'> & }: React.ComponentProps<'div'> &
VariantProps<typeof editorContainerVariants> & VariantProps<typeof editorContainerVariants> &
@ -51,7 +49,7 @@ export function EditorContainer({
<PlateContainer <PlateContainer
className={cn( className={cn(
'ignore-click-outside/toolbar', 'ignore-click-outside/toolbar',
editorContainerVariants({ variant, readonly }), editorContainerVariants({ variant, readOnly }),
className className
)} )}
{...props} {...props}

View File

@ -23,7 +23,6 @@ interface ReportEditorProps {
variant?: 'default'; variant?: 'default';
className?: string; className?: string;
containerClassName?: string; containerClassName?: string;
disabled?: boolean;
style?: React.CSSProperties; style?: React.CSSProperties;
onValueChange?: (value: string) => void; //markdown onValueChange?: (value: string) => void; //markdown
useFixedToolbarKit?: boolean; useFixedToolbarKit?: boolean;
@ -59,7 +58,6 @@ export const ReportEditor = React.memo(
mode = 'default', mode = 'default',
useFixedToolbarKit = false, useFixedToolbarKit = false,
readOnly = false, readOnly = false,
disabled = false,
isStreaming = false, isStreaming = false,
children, children,
postEditorChildren postEditorChildren
@ -72,9 +70,9 @@ export const ReportEditor = React.memo(
const editor = useReportEditor({ const editor = useReportEditor({
isStreaming, isStreaming,
mode, mode,
readOnly,
value, value,
initialElements, initialElements,
disabled,
useFixedToolbarKit useFixedToolbarKit
}); });
@ -123,22 +121,18 @@ export const ReportEditor = React.memo(
if (!editor) return null; if (!editor) return null;
return ( return (
<Plate <Plate editor={editor} onValueChange={onValueChangeDebounced}>
editor={editor}
readOnly={readOnly || isStreaming}
onValueChange={onValueChangeDebounced}>
<EditorContainer <EditorContainer
variant={variant} variant={variant}
readonly={readOnly} readOnly={readOnly}
disabled={disabled}
className={cn('editor-container relative overflow-auto', containerClassName)}> className={cn('editor-container relative overflow-auto', containerClassName)}>
{children} {children}
<ThemeWrapper id={id}> <ThemeWrapper id={id}>
<Editor <Editor
style={style} style={style}
placeholder={placeholder} placeholder={placeholder}
disabled={disabled}
className={cn('editor', className)} className={cn('editor', className)}
readOnly={readOnly || isStreaming}
autoFocus autoFocus
/> />
</ThemeWrapper> </ThemeWrapper>

View File

@ -13,15 +13,15 @@ import type { ReportElementWithId } from '@buster/server-shared/reports';
export const useReportEditor = ({ export const useReportEditor = ({
value, value,
disabled,
isStreaming, isStreaming,
mode = 'default', mode = 'default',
readOnly,
useFixedToolbarKit = false, useFixedToolbarKit = false,
initialElements initialElements
}: { }: {
value: string | undefined; //markdown value: string | undefined; //markdown
initialElements?: Value | ReportElementWithId[]; initialElements?: Value | ReportElementWithId[];
disabled: boolean; readOnly: boolean | undefined;
useFixedToolbarKit?: boolean; useFixedToolbarKit?: boolean;
isStreaming: boolean; isStreaming: boolean;
mode?: 'export' | 'default'; mode?: 'export' | 'default';
@ -43,7 +43,7 @@ export const useReportEditor = ({
const editor = usePlateEditor({ const editor = usePlateEditor({
plugins, plugins,
value: initialElements, value: initialElements,
readOnly: disabled || isStreaming readOnly: readOnly //this is for the initial value
}); });
useEditorServerUpdates({ editor, value, isStreaming }); useEditorServerUpdates({ editor, value, isStreaming });

View File

@ -12,6 +12,7 @@ import { useChatIndividualContextSelector } from '@/layouts/ChatLayout/ChatConte
import { useTrackAndUpdateReportChanges } from '@/api/buster-electric/reports/hooks'; import { useTrackAndUpdateReportChanges } from '@/api/buster-electric/reports/hooks';
import { ShimmerText } from '@/components/ui/typography/ShimmerText'; import { ShimmerText } from '@/components/ui/typography/ShimmerText';
import { GeneratingContent } from './GeneratingContent'; import { GeneratingContent } from './GeneratingContent';
import { useHotkeys } from 'react-hotkeys-hook';
export const ReportPageController: React.FC<{ export const ReportPageController: React.FC<{
reportId: string; reportId: string;
@ -63,7 +64,6 @@ export const ReportPageController: React.FC<{
<DynamicReportEditor <DynamicReportEditor
value={content} value={content}
placeholder="Start typing..." placeholder="Start typing..."
disabled={false}
className={commonClassName} className={commonClassName}
containerClassName="pt-9" containerClassName="pt-9"
variant="default" variant="default"

View File

@ -66,8 +66,15 @@ export function createModifyReportsReasoningEntry(
} }
} }
// Calculate elapsed time when complete // Only show elapsed time when all edits are complete (not during streaming)
secondaryTitle = formatElapsedTime(state.startTime); // Check if all edits have a final status (completed or failed), not just 'loading'
const allEditsComplete = state.edits?.every(
(edit) => edit.status === 'completed' || edit.status === 'failed'
) ?? false;
if (allEditsComplete) {
secondaryTitle = formatElapsedTime(state.startTime);
}
} }
return { return {