fix(vscode): hide Save-as-plan and Add-to-notes actions in VS Code runtime
Both flows write into ~/.config/openchamber which isn't reachable from the VS Code webview, so the buttons were dead weight there.
This commit is contained in:
@@ -1498,25 +1498,27 @@ const AssistantMessageBody: React.FC<Omit<MessageBodyProps, 'isUser'>> = ({
|
|||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent sideOffset={6}>{isSharing ? 'Saving image...' : 'Save as image'}</TooltipContent>
|
<TooltipContent sideOffset={6}>{isSharing ? 'Saving image...' : 'Save as image'}</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip delayDuration={1000}>
|
{!isVSCodeRuntime() ? (
|
||||||
<TooltipTrigger asChild>
|
<Tooltip delayDuration={1000}>
|
||||||
<Button
|
<TooltipTrigger asChild>
|
||||||
type="button"
|
<Button
|
||||||
size="icon"
|
type="button"
|
||||||
variant="ghost"
|
size="icon"
|
||||||
disabled={!hasCopyableText || !currentProjectRef}
|
variant="ghost"
|
||||||
className={cn(
|
disabled={!hasCopyableText || !currentProjectRef}
|
||||||
'h-8 w-8 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50',
|
className={cn(
|
||||||
(!hasCopyableText || !currentProjectRef) && 'opacity-50'
|
'h-8 w-8 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50',
|
||||||
)}
|
(!hasCopyableText || !currentProjectRef) && 'opacity-50'
|
||||||
onPointerDown={(event) => event.stopPropagation()}
|
)}
|
||||||
onClick={handleSaveAsPlanClick}
|
onPointerDown={(event) => event.stopPropagation()}
|
||||||
>
|
onClick={handleSaveAsPlanClick}
|
||||||
<RiBookletLine className="h-4 w-4" />
|
>
|
||||||
</Button>
|
<RiBookletLine className="h-4 w-4" />
|
||||||
</TooltipTrigger>
|
</Button>
|
||||||
<TooltipContent sideOffset={6}>Save as plan</TooltipContent>
|
</TooltipTrigger>
|
||||||
</Tooltip>
|
<TooltipContent sideOffset={6}>Save as plan</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
) : null}
|
||||||
<Tooltip delayDuration={1000}>
|
<Tooltip delayDuration={1000}>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { copyTextToClipboard } from '@/lib/clipboard';
|
|||||||
import { toast } from '@/components/ui';
|
import { toast } from '@/components/ui';
|
||||||
import { getProjectNotesAndTodos, saveProjectNotesAndTodos } from '@/lib/openchamberConfig';
|
import { getProjectNotesAndTodos, saveProjectNotesAndTodos } from '@/lib/openchamberConfig';
|
||||||
import { summarizeText } from '@/lib/voice/summarize';
|
import { summarizeText } from '@/lib/voice/summarize';
|
||||||
|
import { isVSCodeRuntime } from '@/lib/desktop';
|
||||||
|
|
||||||
interface TextSelectionMenuProps {
|
interface TextSelectionMenuProps {
|
||||||
containerRef: React.RefObject<HTMLElement | null>;
|
containerRef: React.RefObject<HTMLElement | null>;
|
||||||
@@ -628,21 +629,23 @@ export const TextSelectionMenu: React.FC<TextSelectionMenuProps> = ({ containerR
|
|||||||
<span>Copy</span>
|
<span>Copy</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
{!isVSCodeRuntime() ? (
|
||||||
onClick={handleAddToNotes}
|
<button
|
||||||
disabled={isAddingToNotes}
|
onClick={handleAddToNotes}
|
||||||
className={cn(
|
disabled={isAddingToNotes}
|
||||||
'flex items-center gap-2 px-3 py-2 rounded-lg',
|
className={cn(
|
||||||
'text-sm font-medium',
|
'flex items-center gap-2 px-3 py-2 rounded-lg',
|
||||||
'bg-[var(--surface-muted)] text-[var(--surface-foreground)]',
|
'text-sm font-medium',
|
||||||
'active:opacity-80 disabled:opacity-60 disabled:cursor-not-allowed',
|
'bg-[var(--surface-muted)] text-[var(--surface-foreground)]',
|
||||||
'transition-opacity duration-150'
|
'active:opacity-80 disabled:opacity-60 disabled:cursor-not-allowed',
|
||||||
)}
|
'transition-opacity duration-150'
|
||||||
type="button"
|
)}
|
||||||
>
|
type="button"
|
||||||
{isAddingToNotes ? <RiLoader4Line className="h-5 w-5 animate-spin" /> : <RiBookletLine className="h-5 w-5" />}
|
>
|
||||||
<span>Add to notes</span>
|
{isAddingToNotes ? <RiLoader4Line className="h-5 w-5 animate-spin" /> : <RiBookletLine className="h-5 w-5" />}
|
||||||
</button>
|
<span>Add to notes</span>
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
</div>,
|
</div>,
|
||||||
document.body
|
document.body
|
||||||
);
|
);
|
||||||
@@ -703,24 +706,28 @@ export const TextSelectionMenu: React.FC<TextSelectionMenuProps> = ({ containerR
|
|||||||
<span className="whitespace-nowrap">New session</span>
|
<span className="whitespace-nowrap">New session</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div className="w-px h-4 bg-[var(--interactive-border)]" />
|
{!isVSCodeRuntime() ? (
|
||||||
|
<>
|
||||||
|
<div className="w-px h-4 bg-[var(--interactive-border)]" />
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={handleAddToNotes}
|
onClick={handleAddToNotes}
|
||||||
disabled={isAddingToNotes}
|
disabled={isAddingToNotes}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex items-center gap-1.5 px-2 py-1 rounded-md',
|
'flex items-center gap-1.5 px-2 py-1 rounded-md',
|
||||||
'text-sm font-medium',
|
'text-sm font-medium',
|
||||||
'text-[var(--surface-foreground)]',
|
'text-[var(--surface-foreground)]',
|
||||||
'hover:bg-[var(--interactive-hover)] disabled:opacity-60 disabled:cursor-not-allowed',
|
'hover:bg-[var(--interactive-hover)] disabled:opacity-60 disabled:cursor-not-allowed',
|
||||||
'transition-colors duration-150'
|
'transition-colors duration-150'
|
||||||
)}
|
)}
|
||||||
title="Save distilled insight to notes"
|
title="Save distilled insight to notes"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
{isAddingToNotes ? <RiLoader4Line className="h-4 w-4 animate-spin" /> : <RiBookletLine className="h-4 w-4" />}
|
{isAddingToNotes ? <RiLoader4Line className="h-4 w-4 animate-spin" /> : <RiBookletLine className="h-4 w-4" />}
|
||||||
<span className="whitespace-nowrap">Add to notes</span>
|
<span className="whitespace-nowrap">Add to notes</span>
|
||||||
</button>
|
</button>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>,
|
</div>,
|
||||||
document.body
|
document.body
|
||||||
|
|||||||
Reference in New Issue
Block a user