import { ChatChangeEvent, ChatModel, ChatRequestModel } from '@theia/ai-chat/lib/common'; import { DisposableCollection, Emitter, Event } from '@theia/core'; import { ReactWidget } from '@theia/core/lib/browser'; import { ContextKey, ContextKeyService } from '@theia/core/lib/browser/context-key-service'; import * as React from '@theia/core/shared/react'; import '../../../src/browser/style/chat-find.css'; import { ChatFindMatch, ChatFindMatcher, ChatFindOptions } from './chat-find-matcher.js'; export interface ChatFindState { regexp: RegExp | undefined; matches: ChatFindMatch[]; current: ChatFindMatch | undefined; } /** * The find bar of a chat view: owns query, options, matches and the current match, and tracks the * chat model so matches follow streamed responses. Reveal and highlighting are done by the host * (the chat tree widget) via {@link onDidRequestReveal} and {@link onDidChangeState}. */ export declare class ChatFindWidget extends ReactWidget { static readonly ID = "chat-find-widget"; protected static readonly RECOMPUTE_DELAY_MS = 100; protected matcher: ChatFindMatcher; protected contextKeyService: ContextKeyService; protected readonly onDidChangeStateEmitter: Emitter; readonly onDidChangeState: Event; protected readonly onDidRequestRevealEmitter: Emitter; readonly onDidRequestReveal: Event; /** Focused when the bar closes and the previously focused element is gone. */ fallbackFocusTarget: HTMLElement | undefined; protected visibleKey: ContextKey; protected query: string; protected options: ChatFindOptions; protected regexp: RegExp | undefined; protected matches: ChatFindMatch[]; protected currentIndex: number; protected chatModel: ChatModel | undefined; protected nodeOrder: Map; protected readonly toDisposeOnModelChange: DisposableCollection; protected recomputeTimeout: ReturnType | undefined; protected previouslyFocused: HTMLElement | undefined; protected input: HTMLInputElement | undefined; protected pendingFocus: boolean; protected init(): void; dispose(): void; get isOpen(): boolean; get state(): ChatFindState; get currentMatch(): ChatFindMatch | undefined; /** * Whether there is anything to search. A session without requests renders the welcome screen (which hosts * the session list), so the find bar has nothing to search and stays closed there. */ get canFind(): boolean; /** * Track a chat model; query and options are kept, the position resets. Like the find widget of an editor, the bar * belongs to one session: it closes when another session is tracked, and `Ctrl+F` brings the query back. */ setChatModel(model: ChatModel | undefined): void; open(): void; /** Closes the bar and returns focus to where it was before the bar opened. */ dismiss(): void; /** Closes the bar and clears the highlights without touching focus. */ protected hideBar(): void; setQuery(query: string): void; toggleOption(option: keyof ChatFindOptions): void; next(): void; previous(): void; protected step(delta: number): void; protected revealCurrent(): void; protected handleModelChange(event: ChatChangeEvent): void; protected trackResponse(request: ChatRequestModel): void; protected scheduleRecompute(): void; /** * Recompute matches. The current match is kept by identity when it still exists; otherwise (or when * `moveToNearest` is set after a query change) the first match at or after the previous position becomes current. * While the bar is closed there are no matches. */ protected recompute(moveToNearest: boolean): void; /** Closes the bar once the tracked session has no requests left to search. */ protected closeWhenNothingToFind(): void; protected fireStateIfOpen(): void; protected computeNodeOrder(): Map; protected pickCurrentIndex(previous: ChatFindMatch | undefined, moveToNearest: boolean): number; /** Document order of two matches: row order, then content index, then offset. */ protected compare(a: ChatFindMatch, b: ChatFindMatch): number; protected focusInput(): void; protected setInput: (input: HTMLInputElement | null) => void; protected handleInputChange: (event: React.ChangeEvent) => void; protected handleInputKeyDown: (event: React.KeyboardEvent) => void; protected handleToggleClick: (event: React.MouseEvent) => void; protected handlePreviousClick: () => void; protected handleNextClick: () => void; protected handleCloseClick: () => void; protected render(): React.ReactNode; protected renderToggle(option: keyof ChatFindOptions, icon: string, title: string): React.ReactNode; protected renderButton(icon: string, title: string, enabled: boolean, onClick: () => void): React.ReactNode; } //# sourceMappingURL=chat-find-widget.d.ts.map