Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ const FlexiblePanel: React.FC<ExtendedFlexiblePanelProps> = memo(({
key={sessionId}
sessionId={sessionId}
autoFocus={true}
supportsCopyPaste={false}
/>
</div>
</React.Suspense>
Expand Down
1 change: 1 addition & 0 deletions src/web-ui/src/app/scenes/terminal/TerminalScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const TerminalScene: React.FC<TerminalSceneProps> = ({ isActive = true }) => {
showStatusBar
onExit={handleExit}
onClose={handleClose}
supportsCopyPaste={false}
/>
) : (
<div className="bitfun-terminal-scene__empty">
Expand Down
1 change: 1 addition & 0 deletions src/web-ui/src/flow_chat/tool-cards/TerminalToolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ export const TerminalToolCard: React.FC<TerminalToolCardProps> = ({
successMessage={t('toolCards.terminal.commandCopied')}
failureMessage={t('toolCards.terminal.copyCommandFailed')}
ariaLabel={t('toolCards.terminal.copyCommand')}
showSuccessNotification={false}
/>
);

Expand Down
3 changes: 3 additions & 0 deletions src/web-ui/src/flow_chat/tool-cards/ToolCardHeaderActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface ToolCardCopyActionProps {
ariaLabel?: string;
className?: string;
disabled?: boolean;
showSuccessNotification?: boolean;
}

export const ToolCardCopyAction: React.FC<ToolCardCopyActionProps> = ({
Expand All @@ -41,11 +42,13 @@ export const ToolCardCopyAction: React.FC<ToolCardCopyActionProps> = ({
ariaLabel,
className,
disabled,
showSuccessNotification
}) => {
const { copied, copy } = useCopyTextAction({
getText,
successMessage,
failureMessage,
showSuccessNotification
});

return (
Expand Down
9 changes: 7 additions & 2 deletions src/web-ui/src/flow_chat/tool-cards/useCopyTextAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ interface UseCopyTextActionOptions {
successMessage: string;
failureMessage: string;
resetMs?: number;
showSuccessNotification?: boolean;
}

export function useCopyTextAction({
getText,
successMessage,
failureMessage,
resetMs = 1600,
showSuccessNotification = true,
}: UseCopyTextActionOptions) {
const [copied, setCopied] = useState(false);
const resetTimerRef = useRef<number | null>(null);
Expand Down Expand Up @@ -42,7 +44,10 @@ export function useCopyTextAction({
}

setCopied(true);
notificationService.success(successMessage, { duration: resetMs });
if (showSuccessNotification){
notificationService.success(successMessage, { duration: resetMs });
}


if (resetTimerRef.current !== null) {
window.clearTimeout(resetTimerRef.current);
Expand All @@ -51,7 +56,7 @@ export function useCopyTextAction({
setCopied(false);
resetTimerRef.current = null;
}, resetMs);
}, [failureMessage, getText, resetMs, successMessage]);
}, [failureMessage, getText, resetMs, successMessage,showSuccessNotification]);

return { copied, copy };
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class ContextResolver {
`terminal-${Date.now()}`;
const sessionId = terminalElement.getAttribute('data-session-id') || undefined;
const isReadOnly = terminalElement.getAttribute('data-readonly') === 'true';

const supportsCopyPaste = terminalElement.getAttribute('data-supports-copy-paste') !== 'false';

const selection = window.getSelection();
const selectedText = selection?.toString() || '';
Expand All @@ -143,7 +143,8 @@ export class ContextResolver {
sessionId,
hasSelection,
selectedText: hasSelection ? selectedText : undefined,
isReadOnly
isReadOnly,
supportsCopyPaste
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export class TerminalMenuProvider implements IMenuProvider {
const terminalContext = context as TerminalContext;
const items: MenuItem[] = [];
const isReadOnly = terminalContext.isReadOnly ?? false;

const supportsCopyPaste = terminalContext.supportsCopyPaste ?? true;

items.push({
if(supportsCopyPaste) {
items.push({
id: 'terminal-copy',
label: i18nService.t('common:actions.copy'),
icon: 'Copy',
Expand Down Expand Up @@ -51,6 +52,8 @@ export class TerminalMenuProvider implements IMenuProvider {
}
});
}
}



items.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export interface TerminalContext extends BaseContext {
selectedText?: string;

isReadOnly?: boolean;

supportsCopyPaste?: boolean;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface ConnectedTerminalProps {
onClose?: () => void;
onTitleChange?: (title: string) => void;
onExit?: (exitCode?: number) => void;
supportsCopyPaste?: boolean;
}

const ConnectedTerminal: React.FC<ConnectedTerminalProps> = memo(({
Expand All @@ -49,6 +50,7 @@ const ConnectedTerminal: React.FC<ConnectedTerminalProps> = memo(({
onClose,
onTitleChange,
onExit,
supportsCopyPaste = true,
}) => {
const terminalRef = useRef<TerminalRef>(null);
const [title, setTitle] = useState<string>(initialSession?.name || 'Terminal');
Expand Down Expand Up @@ -412,6 +414,7 @@ const ConnectedTerminal: React.FC<ConnectedTerminalProps> = memo(({
onReady={handleTerminalReady}
onPaste={handlePaste}
preventShrinkBelowColsRef={preventShrinkBelowColsRef}
supportsCopyPaste={supportsCopyPaste}
/>

{showStatusBar && session && (
Expand Down
3 changes: 3 additions & 0 deletions src/web-ui/src/tools/terminal/components/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export interface TerminalProps {
* content. Set back to 0 (or leave unset) to restore normal resize behaviour.
*/
preventShrinkBelowColsRef?: React.MutableRefObject<number>;
supportsCopyPaste?: boolean;
}

export interface TerminalRef {
Expand Down Expand Up @@ -179,6 +180,7 @@ const Terminal = forwardRef<TerminalRef, TerminalProps>(({
onReady,
onPaste,
preventShrinkBelowColsRef,
supportsCopyPaste = true,
}, ref) => {
const containerRef = useRef<HTMLDivElement>(null);
const terminalRef = useRef<XTerm | null>(null);
Expand Down Expand Up @@ -684,6 +686,7 @@ const Terminal = forwardRef<TerminalRef, TerminalProps>(({
className={`bitfun-terminal ${className}`}
data-terminal-id={terminalId}
data-session-id={sessionId}
data-supports-copy-paste={supportsCopyPaste?'true':'false'}
>
<div
ref={containerRef}
Expand Down
Loading