import { Notification } from '@jupyterlab/apputils'; import { PathExt } from '@jupyterlab/coreutils'; import type { TranslationBundle } from '@jupyterlab/translation'; import { closeIcon, HTMLSelect, LabIcon, ReactWidget } from '@jupyterlab/ui-components'; import type { CommandRegistry } from '@lumino/commands'; import type { Message } from '@lumino/messaging'; import * as React from 'react'; import type { IAgent } from '../launcher/agents'; import { contextSummary } from './popup'; import { serverPath } from './prompt'; import type { IQueuedPrompt, PromptQueue } from './queue'; import type { ISessionTarget } from './targetPicker'; import type { AskAgentTarget } from './tokens'; /** * Command the context buttons dispatch; keeps the panel decoupled from the plugin. */ const HIGHLIGHT_LINES_COMMAND = 'xtralab:highlight-lines'; /** * Textarea height that fits `text` without scrolling, within sane bounds: * tall enough to look editable, short enough that one long comment cannot * crowd out the rest of the queue. */ function rowsFor(text: string): number { return Math.min(8, Math.max(2, text.split('\n').length)); } /** * A target as a `