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 @@ -4,8 +4,9 @@
*/

import React from 'react';
import { Loader2, CheckCircle, XCircle, Clock } from 'lucide-react';
import { Loader2, CheckCircle, XCircle } from 'lucide-react';
import { useI18n } from '@/infrastructure/i18n';
import { ToolProcessingDots } from '../ToolProcessingDots';
import './BaseToolCard.scss';

export interface BaseToolCardProps {
Expand Down Expand Up @@ -63,7 +64,7 @@ export const BaseToolCard: React.FC<BaseToolCardProps> = ({
case 'error':
return <XCircle className="base-tool-card__status-error" size={12} />;
default:
return <Clock className="base-tool-card__status-pending" size={12} />;
return <ToolProcessingDots className="base-tool-card__status-pending" size={12} />;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
*/

import React, { useState, useMemo } from 'react';
import { Search, File, FolderOpen, ChevronDown, ChevronUp, Loader2, CheckCircle, XCircle, Clock } from 'lucide-react';
import { Search, File, FolderOpen, ChevronDown, ChevronUp, Loader2, CheckCircle, XCircle } from 'lucide-react';
import { useI18n } from '@/infrastructure/i18n';
import { BaseToolCard, BaseToolCardProps } from '../BaseToolCard';
import { ToolProcessingDots } from '../ToolProcessingDots';
import './SearchCard.scss';

export interface SearchCardProps extends Omit<BaseToolCardProps, 'toolName' | 'displayName'> {
Expand Down Expand Up @@ -98,7 +99,7 @@ export const SearchCard: React.FC<SearchCardProps> = ({
case 'error':
return <XCircle className="search-card__status-error" size={12} />;
default:
return <Clock className="search-card__status-pending" size={12} />;
return <ToolProcessingDots className="search-card__status-pending" size={12} />;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
*/

import React from 'react';
import { CheckCircle, XCircle, Maximize2, FileText, Loader2, Clock } from 'lucide-react';
import { CheckCircle, XCircle, Maximize2, FileText, Loader2 } from 'lucide-react';
import { useI18n } from '@/infrastructure/i18n';
import { BaseToolCard, BaseToolCardProps } from '../BaseToolCard';
import { ToolProcessingDots } from '../ToolProcessingDots';
import './SnapshotCard.scss';

export interface SnapshotCardProps extends Omit<BaseToolCardProps, 'toolName' | 'displayName'> {
Expand Down Expand Up @@ -71,7 +72,7 @@ export const SnapshotCard: React.FC<SnapshotCardProps> = ({
case 'error':
return <XCircle className="snapshot-card__status-error" size={12} />;
default:
return <Clock className="snapshot-card__status-pending" size={12} />;
return <ToolProcessingDots className="snapshot-card__status-pending" size={12} />;
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Three-dot "processing" indicator for tool cards
*/
.bitfun-tool-processing-dots {
display: inline-flex;
align-items: center;
justify-content: center;
color: inherit;
vertical-align: middle;
}

.bitfun-tool-processing-dots__dot {
flex-shrink: 0;
border-radius: 50%;
background: currentColor;
animation: bitfun-tool-processing-dots-bounce 1.05s ease-in-out infinite;

&:nth-child(2) {
animation-delay: 0.15s;
}

&:nth-child(3) {
animation-delay: 0.3s;
}
}

.bitfun-tool-processing-dots--s10 {
gap: 1px;

.bitfun-tool-processing-dots__dot {
width: 2px;
height: 2px;
}
}

.bitfun-tool-processing-dots--s12 {
gap: 2px;

.bitfun-tool-processing-dots__dot {
width: 2px;
height: 2px;
}
}

.bitfun-tool-processing-dots--s14 {
gap: 2px;

.bitfun-tool-processing-dots__dot {
width: 2.5px;
height: 2.5px;
}
}

.bitfun-tool-processing-dots--s16 {
gap: 3px;

.bitfun-tool-processing-dots__dot {
width: 3px;
height: 3px;
}
}

@keyframes bitfun-tool-processing-dots-bounce {
0%,
60%,
100% {
transform: translateY(0);
opacity: 0.55;
}

30% {
transform: translateY(-2px);
opacity: 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Compact three-dot pulse for tool "pending / parsing" states (replaces clock icon).
*/

import React from 'react';
import './ToolProcessingDots.scss';

export type ToolProcessingDotsSize = 10 | 12 | 14 | 16;

export interface ToolProcessingDotsProps {
/** Visual scale aligned with common lucide-react icon sizes in tool headers */
size?: ToolProcessingDotsSize;
className?: string;
}

export const ToolProcessingDots: React.FC<ToolProcessingDotsProps> = ({
size = 14,
className = '',
}) => (
<span
className={`bitfun-tool-processing-dots bitfun-tool-processing-dots--s${size} ${className}`.trim()}
aria-hidden
role="presentation"
>
<span className="bitfun-tool-processing-dots__dot" />
<span className="bitfun-tool-processing-dots__dot" />
<span className="bitfun-tool-processing-dots__dot" />
</span>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { ToolProcessingDots } from './ToolProcessingDots';
export type { ToolProcessingDotsProps, ToolProcessingDotsSize } from './ToolProcessingDots';
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { i18nService } from '@/infrastructure/i18n';
export { BaseToolCard } from './BaseToolCard';
export type { BaseToolCardProps } from './BaseToolCard';

export { ToolProcessingDots } from './ToolProcessingDots';
export type { ToolProcessingDotsProps, ToolProcessingDotsSize } from './ToolProcessingDots';

export { SnapshotCard } from './SnapshotCard';
export type { SnapshotCardProps } from './SnapshotCard';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ import './Markdown.scss';
const log = createLogger('Markdown');
const COMPUTER_LINK_PREFIX = 'computer://';

// Module-level cache so that all simultaneously-mounting Markdown instances
// (e.g. dozens of history blocks after a workspace switch) share a single
// IPC round-trip for the workspace path. The in-flight deduplication in
// GlobalAPI already coalesces concurrent calls into one; this cache avoids
// even triggering a new IPC call while the result is still fresh.
let _cachedWorkspacePathResult: string | undefined;
let _cachedWorkspacePathAt = 0;
const WORKSPACE_PATH_CACHE_MS = 5000;

async function getWorkspacePathCached(): Promise<string | undefined> {
const now = Date.now();
if (_cachedWorkspacePathResult !== undefined && now - _cachedWorkspacePathAt < WORKSPACE_PATH_CACHE_MS) {
return _cachedWorkspacePathResult;
}
const result = await globalAPI.getCurrentWorkspacePath();
_cachedWorkspacePathResult = result;
_cachedWorkspacePathAt = Date.now();
return result;
}

/** Catches render errors from react-markdown/remark-gfm (e.g. RegExp in transformGfmAutolinkLiterals) and shows plain text fallback. */
class MarkdownErrorBoundary extends Component<
{ children: ReactNode; fallbackContent: string },
Expand Down Expand Up @@ -577,7 +597,7 @@ export const Markdown = React.memo<MarkdownProps>(({
useEffect(() => {
let cancelled = false;

void globalAPI.getCurrentWorkspacePath()
void getWorkspacePathCached()
.then((workspacePath) => {
if (!cancelled && workspacePath) {
setCurrentWorkspacePath(workspacePath);
Expand Down
38 changes: 27 additions & 11 deletions src/web-ui/src/flow_chat/components/ToolStatusIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*/

import React from 'react';
import { Loader2, CheckCircle, XCircle, Clock, AlertCircle } from 'lucide-react';
import { Loader2, CheckCircle, XCircle, AlertCircle, type LucideIcon } from 'lucide-react';
import { ToolProcessingDots } from '@/component-library';
import type { ToolExecutionStatus } from '../../shared/types/tool-events';

interface ToolStatusIndicatorProps {
Expand All @@ -13,13 +14,24 @@ interface ToolStatusIndicatorProps {
showLabel?: boolean;
}

const STATUS_CONFIG = {
const STATUS_CONFIG: Record<
ToolExecutionStatus,
{
icon: LucideIcon | null;
color: string;
bgColor: string;
label: string;
animate: boolean;
useDots?: boolean;
}
> = {
pending: {
icon: Clock,
icon: null,
color: 'text-gray-500',
bgColor: 'bg-gray-100',
label: 'Waiting',
animate: false
animate: false,
useDots: true,
},
receiving: {
icon: Loader2,
Expand All @@ -29,11 +41,12 @@ const STATUS_CONFIG = {
animate: true
},
starting: {
icon: Clock,
color: 'text-blue-500',
icon: null,
color: 'text-blue-500',
bgColor: 'bg-blue-100',
label: 'Starting',
animate: true
animate: false,
useDots: true,
},
running: {
icon: Loader2,
Expand Down Expand Up @@ -72,7 +85,6 @@ export const ToolStatusIndicator: React.FC<ToolStatusIndicatorProps> = ({
showLabel = true
}) => {
const config = STATUS_CONFIG[status];
const Icon = config.icon;

const formatDuration = (ms: number) => {
if (ms < 1000) return `${ms}ms`;
Expand All @@ -83,9 +95,13 @@ export const ToolStatusIndicator: React.FC<ToolStatusIndicatorProps> = ({
return (
<div className={`inline-flex items-center gap-2 ${className}`}>
<div className={`flex items-center justify-center w-5 h-5 rounded-full ${config.bgColor}`}>
<Icon
className={`w-3 h-3 ${config.color} ${config.animate ? 'animate-spin' : ''}`}
/>
{config.useDots ? (
<ToolProcessingDots size={12} className={config.color} />
) : config.icon ? (
<config.icon
className={`w-3 h-3 ${config.color} ${config.animate ? 'animate-spin' : ''}`}
/>
) : null}
</div>

{showLabel && (
Expand Down
5 changes: 2 additions & 3 deletions src/web-ui/src/flow_chat/tool-cards/CodeReviewToolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import {
AlertTriangle,
AlertCircle,
Info,
Clock,
ChevronDown,
ChevronUp,
} from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Tooltip } from '@/component-library';
import { Tooltip, ToolProcessingDots } from '@/component-library';
import type { ToolCardProps } from '../types/flow-chat';
import { BaseToolCard, ToolCardHeader } from './BaseToolCard';
import { createLogger } from '@/shared/utils/logger';
Expand Down Expand Up @@ -168,7 +167,7 @@ export const CodeReviewToolCard: React.FC<ToolCardProps> = React.memo(({
return null;
case 'pending':
default:
return <Clock size={12} />;
return <ToolProcessingDots size={12} />;
}
};

Expand Down
21 changes: 21 additions & 0 deletions src/web-ui/src/flow_chat/tool-cards/CompactToolCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,27 @@
}
}

// Utility: child elements hidden by default, revealed on card hover.
// Uses max-width + overflow to collapse layout space when hidden so no gap
// appears before the hover target is revealed.
.compact-tool-card .compact-extra-on-hover {
max-width: 0;
overflow: hidden;
opacity: 0;
pointer-events: none;
flex-shrink: 0;
transition: max-width 0.18s ease, opacity 0.15s ease;
}

.compact-tool-card:hover .compact-extra-on-hover {
max-width: 240px;
opacity: 1;
pointer-events: auto;
border-left: 1px solid var(--border-base);
padding-left: 6px;
margin-left: 6px;
}

/* ========== Expanded compact tools use the shared BaseToolCard shell ========== */
.base-tool-card-wrapper.compact-tool-card-wrapper--expanded-card {
width: 100%;
Expand Down
23 changes: 4 additions & 19 deletions src/web-ui/src/flow_chat/tool-cards/DefaultToolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
*/

import React, { useMemo, useState, useCallback } from 'react';
import { Loader2, XCircle, Clock, Check, ChevronDown, ChevronRight } from 'lucide-react';
import { ChevronDown, ChevronRight } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import type { ToolCardProps } from '../types/flow-chat';
import { CompactToolCard, CompactToolCardHeader } from './CompactToolCard';
import { ToolCardStatusSlot } from './ToolCardStatusSlot';
import { useToolCardHeightContract } from './useToolCardHeightContract';
import './DefaultToolCard.scss';

Expand Down Expand Up @@ -134,21 +135,6 @@ export const DefaultToolCard: React.FC<ToolCardProps> = ({
});
}, [applyExpandedState, canExpand, isExpanded, onExpand]);

const getStatusIcon = () => {
switch (status) {
case 'running':
case 'streaming':
return <Loader2 className="animate-spin" size={16} />;
case 'completed':
return <Check size={16} className="icon-check-done" />;
case 'cancelled':
case 'error':
return <XCircle size={16} />;
default:
return <Clock size={16} />;
}
};

const getStatusText = () => {
if (requiresConfirmation && !userConfirmed) {
return t('toolCards.default.waitingConfirm');
Expand Down Expand Up @@ -228,12 +214,11 @@ export const DefaultToolCard: React.FC<ToolCardProps> = ({
onClick={handleToggleExpand}
className={`default-tool-card ${showConfirmationHighlight ? 'requires-confirmation' : ''}`}
clickable={canExpand}
header={
header={
<CompactToolCardHeader
icon={getStatusIcon()}
icon={<ToolCardStatusSlot status={status} toolIcon={config.icon ?? undefined} />}
action={config.displayName}
content={getSummaryText()}
extra={config.icon ? <span className="default-tool-card__icon-badge">{config.icon}</span> : undefined}
rightStatusIcon={canExpand ? (isExpanded ? <ChevronDown size={14} /> : <ChevronRight size={14} />) : undefined}
/>
}
Expand Down
Loading
Loading