mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
commit730d0c82b1Author: Logan Yang <logancyang@gmail.com> Date: Mon Apr 21 20:13:21 2025 -0700 Switch insert and copy button positions (#1463) commit4efdc941f2Author: Logan Yang <logancyang@gmail.com> Date: Mon Apr 21 16:15:50 2025 -0700 Fix canvas read (#1462) commit93e4a04ef1Author: Emt-lin <41323133+Emt-lin@users.noreply.github.com> Date: Tue Apr 22 07:13:47 2025 +0800 fix: Add a new line when press the Enter key on mobile. (#1450) commit3c65d79a74Author: Logan Yang <logancyang@gmail.com> Date: Mon Apr 21 15:38:36 2025 -0700 Implement canvas adaptor (#1461) * Implement canvas parser * Refactor context processing and custom prompt handling - Update `processContextNotes` to exclude notes already processed by custom prompts using a set of excluded note paths. - Modify `extractVariablesFromPrompt` to return both a variables map and a set of included files. - Adjust `processPrompt` to track included files during prompt processing. - Update `Chat` component to handle context notes more efficiently by avoiding duplication of processed notes. - Ensure that the `FileParserManager` is initialized with the vault in `main.ts`. * Include canvas files in note context modal * Fix tests commit6a9085a71cAuthor: Logan Yang <logancyang@gmail.com> Date: Sun Apr 20 16:14:54 2025 -0700 Add a toggle to turn custom prompt templating off (#1460) commit448a64c383Author: Logan Yang <logancyang@gmail.com> Date: Sun Apr 20 15:52:42 2025 -0700 Update dependencies and support gpt 4.1 series, o4-mini and grok 3 (#1459) commit1d46ab90b0Author: Logan Yang <logancyang@gmail.com> Date: Sun Apr 20 12:14:56 2025 -0700 Fix image in note logic (#1457) * Refactor image processing in note context * Add passMarkdownImages setting commitf4bf334c27Author: Felix Haase <felix.haase@feki.de> Date: Fri Apr 18 08:19:35 2025 +0200 Ollama ApiKey support (#1421) * Update @langchain/ollama and ollama * Ollama: support api keys by passing headers commit19d8b50a74Author: Emt-lin <41323133+Emt-lin@users.noreply.github.com> Date: Fri Apr 18 14:13:25 2025 +0800 refactor: Optimize some user experiences. (#1441) commitfe9b9311baAuthor: Zero Liu <zerolxy@gmail.com> Date: Sun Apr 13 17:40:42 2025 -0700 Improve custom command (v3) (#1446) * Trim responses and auto focus replace on finishing * Make textarea auto scroll to bottom when generating * Support custom prompt syntax in custom command * Support follow up instruction * Fix unit test * Allow followup instruction to use custom prompt syntax commit648412a914Author: Zero Liu <zerolxy@gmail.com> Date: Wed Apr 2 21:44:37 2025 -0700 Add update notification (#1415) commitcb4510e920Author: Zero Liu <zerolxy@gmail.com> Date: Wed Apr 2 21:43:26 2025 -0700 Add user_id to broca requests (#1414)
119 lines
3.5 KiB
TypeScript
119 lines
3.5 KiB
TypeScript
import { Button } from "@/components/ui/button";
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
|
import { USER_SENDER } from "@/constants";
|
|
import { cn } from "@/lib/utils";
|
|
import { ChatMessage } from "@/sharedState";
|
|
import {
|
|
Check,
|
|
Copy,
|
|
LibraryBig,
|
|
PenSquare,
|
|
RotateCw,
|
|
TextCursorInput,
|
|
Trash2,
|
|
} from "lucide-react";
|
|
import { Platform } from "obsidian";
|
|
import React from "react";
|
|
|
|
interface ChatButtonsProps {
|
|
message: ChatMessage;
|
|
onCopy: () => void;
|
|
isCopied: boolean;
|
|
onInsertIntoEditor?: () => void;
|
|
onRegenerate?: () => void;
|
|
onEdit?: () => void;
|
|
onDelete: () => void;
|
|
onShowSources?: () => void;
|
|
hasSources: boolean;
|
|
}
|
|
|
|
export const ChatButtons: React.FC<ChatButtonsProps> = ({
|
|
message,
|
|
onCopy,
|
|
isCopied,
|
|
onInsertIntoEditor,
|
|
onRegenerate,
|
|
onEdit,
|
|
onDelete,
|
|
onShowSources,
|
|
hasSources,
|
|
}) => {
|
|
return (
|
|
<div
|
|
className={cn("flex gap-1", {
|
|
"group-hover:opacity-100 opacity-0": !Platform.isMobile,
|
|
})}
|
|
>
|
|
{message.sender === USER_SENDER ? (
|
|
<>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button onClick={onEdit} variant="ghost2" size="fit" title="Edit">
|
|
<PenSquare className="size-4" />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Edit</TooltipContent>
|
|
</Tooltip>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button onClick={onDelete} variant="ghost2" size="fit" title="Delete">
|
|
<Trash2 className="size-4" />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Delete</TooltipContent>
|
|
</Tooltip>
|
|
</>
|
|
) : (
|
|
<>
|
|
{hasSources && (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button onClick={onShowSources} variant="ghost2" size="fit" title="Show Sources">
|
|
<LibraryBig className="size-4" />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Show Sources</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
onClick={onInsertIntoEditor}
|
|
variant="ghost2"
|
|
size="fit"
|
|
title="Insert / Replace at cursor"
|
|
>
|
|
<TextCursorInput className="size-4" />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Insert / Replace at cursor</TooltipContent>
|
|
</Tooltip>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button variant="ghost2" size="fit" onClick={onCopy} title="Copy">
|
|
{isCopied ? <Check className="size-4" /> : <Copy className="size-4" />}
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Copy</TooltipContent>
|
|
</Tooltip>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button onClick={onRegenerate} variant="ghost2" size="fit" title="Regenerate">
|
|
<RotateCw className="size-4" />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Regenerate</TooltipContent>
|
|
</Tooltip>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button onClick={onDelete} variant="ghost2" size="fit" title="Delete">
|
|
<Trash2 className="size-4" />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Delete</TooltipContent>
|
|
</Tooltip>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|