mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-11 00:32:38 +02:00
refactor: improve AssistantActionBar functionality and UI elements
- Removed unused quick ask mode state and effect, simplifying the component logic. - Updated tooltip descriptions for action buttons to provide clearer user guidance. - Enhanced the conditional rendering for the quick assist feature, improving user interaction with the clipboard functionality.
This commit is contained in:
parent
be98b395b2
commit
518cacf56e
1 changed files with 9 additions and 19 deletions
|
|
@ -465,16 +465,8 @@ const AssistantActionBar: FC = () => {
|
||||||
const isLast = useAuiState((s) => s.message.isLast);
|
const isLast = useAuiState((s) => s.message.isLast);
|
||||||
const aui = useAui();
|
const aui = useAui();
|
||||||
const api = useElectronAPI();
|
const api = useElectronAPI();
|
||||||
const [quickAskMode, setQuickAskMode] = useState("");
|
|
||||||
|
|
||||||
useEffect(() => {
|
const isQuickAssist = !!api?.replaceText && !!api?.getQuickAskMode;
|
||||||
if (!isLast || !api?.getQuickAskMode) return;
|
|
||||||
api.getQuickAskMode().then((mode) => {
|
|
||||||
if (mode) setQuickAskMode(mode);
|
|
||||||
});
|
|
||||||
}, [isLast, api]);
|
|
||||||
|
|
||||||
const isTransform = isLast && !!api?.replaceText && quickAskMode === "transform";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionBarPrimitive.Root
|
<ActionBarPrimitive.Root
|
||||||
|
|
@ -484,7 +476,7 @@ const AssistantActionBar: FC = () => {
|
||||||
className="aui-assistant-action-bar-root -ml-1 col-start-3 row-start-2 flex gap-1 text-muted-foreground md:data-floating:absolute md:data-floating:rounded-md md:data-floating:p-1 [&>button]:opacity-100 md:[&>button]:opacity-[var(--aui-button-opacity,1)]"
|
className="aui-assistant-action-bar-root -ml-1 col-start-3 row-start-2 flex gap-1 text-muted-foreground md:data-floating:absolute md:data-floating:rounded-md md:data-floating:p-1 [&>button]:opacity-100 md:[&>button]:opacity-[var(--aui-button-opacity,1)]"
|
||||||
>
|
>
|
||||||
<ActionBarPrimitive.Copy asChild>
|
<ActionBarPrimitive.Copy asChild>
|
||||||
<TooltipIconButton tooltip="Copy">
|
<TooltipIconButton tooltip="Copy to clipboard">
|
||||||
<AuiIf condition={({ message }) => message.isCopied}>
|
<AuiIf condition={({ message }) => message.isCopied}>
|
||||||
<CheckIcon />
|
<CheckIcon />
|
||||||
</AuiIf>
|
</AuiIf>
|
||||||
|
|
@ -494,29 +486,27 @@ const AssistantActionBar: FC = () => {
|
||||||
</TooltipIconButton>
|
</TooltipIconButton>
|
||||||
</ActionBarPrimitive.Copy>
|
</ActionBarPrimitive.Copy>
|
||||||
<ActionBarPrimitive.ExportMarkdown asChild>
|
<ActionBarPrimitive.ExportMarkdown asChild>
|
||||||
<TooltipIconButton tooltip="Download">
|
<TooltipIconButton tooltip="Download as Markdown">
|
||||||
<DownloadIcon />
|
<DownloadIcon />
|
||||||
</TooltipIconButton>
|
</TooltipIconButton>
|
||||||
</ActionBarPrimitive.ExportMarkdown>
|
</ActionBarPrimitive.ExportMarkdown>
|
||||||
{isLast && (
|
{isLast && (
|
||||||
<ActionBarPrimitive.Reload asChild>
|
<ActionBarPrimitive.Reload asChild>
|
||||||
<TooltipIconButton tooltip="Refresh">
|
<TooltipIconButton tooltip="Regenerate response">
|
||||||
<RefreshCwIcon />
|
<RefreshCwIcon />
|
||||||
</TooltipIconButton>
|
</TooltipIconButton>
|
||||||
</ActionBarPrimitive.Reload>
|
</ActionBarPrimitive.Reload>
|
||||||
)}
|
)}
|
||||||
{isTransform && (
|
{isQuickAssist && (
|
||||||
<button
|
<TooltipIconButton
|
||||||
type="button"
|
tooltip="Paste back into source app"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const text = aui.message().getCopyText();
|
const text = aui.message().getCopyText();
|
||||||
api?.replaceText(text);
|
api?.replaceText(text);
|
||||||
}}
|
}}
|
||||||
className="ml-1 inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90"
|
|
||||||
>
|
>
|
||||||
<ClipboardPaste className="size-3.5" />
|
<ClipboardPaste />
|
||||||
Paste back
|
</TooltipIconButton>
|
||||||
</button>
|
|
||||||
)}
|
)}
|
||||||
</ActionBarPrimitive.Root>
|
</ActionBarPrimitive.Root>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue