import type { ConnectionConfig, ObjectBrowserFilter, ObjectBrowserViewport, QueryTab, TabOutputView, TableInfoTab } from "@/types/database"; import type { NavigationTarget } from "@/composables/useNavigationTargets"; import type { DataGridReloadIntent } from "@/lib/dataGrid/dataGridToolbar"; import type { DataGridSortMode } from "@/lib/dataGrid/dataGridSort"; import type { SqlObjectNavigationTarget } from "@/lib/sql/sqlNavigation"; import type { SqlExecutionOverride, SqlExecutionSnapshot } from "@/lib/sql/sqlExecutionTarget"; import type { AiConversationBinding } from "@/lib/ai/aiConversationBinding"; export interface StatementRange { from: number; to: number; } export interface QueryEditorSurfaceHandle { focusSearch(target?: Element | null): boolean; focusWhere(): boolean; openGoToColumn(): boolean; openTableStructureEditor?(initialTab?: TableInfoTab): boolean; refreshData(target?: Element | null): boolean; toggleResultsPane(): boolean; refreshQueryEditorCompletionCache(): boolean; handleModRTarget(target: Element): boolean; requestQueryEditorExecute(): boolean; captureQueryEditorExecutionSnapshot(): SqlExecutionSnapshot | undefined; requestQueryEditorExecuteInNewResultTab(): boolean; requestQueryEditorPreviewChanges(stackSql?: string): Promise; shouldBlockQueryEditorExecutionShortcut(event: KeyboardEvent): boolean; cancelQueryEditorExecutionViewport(requestId: number): boolean; acceptQueryEditorExecutionViewport(requestId: number): boolean; pasteClipboardAsSqlInCondition(): Promise; applyTableStructureChanges(): Promise; /** A Redis logical database is part of the execution target. */ insertRedisCommand(command: string, target: AiConversationBinding): Promise; executeRedisCommand(command: string, target: AiConversationBinding): Promise; /** * Whether this surface's Redis console is mounted, on screen, and pointed at * `target`. Side-effect free โ€” the AI panel polls it before routing a * command, because the console is a lazily-loaded component rendered only for * the active tab, and retrying the *command* to detect readiness could run it * twice. */ isRedisConsoleReady(target: AiConversationBinding): boolean; previewStatementRange(range: StatementRange | null): boolean; focusStatementRange(range: StatementRange | null): boolean; focusErrorPosition(offset: number): boolean; foldAll?(): boolean; unfoldAll?(): boolean; } export interface QueryResultSurfaceHandle { focusSearch(target?: Element | null): boolean; refreshData(target?: Element | null): boolean; toggleResultsPane(): boolean; handleModRTarget(target: Element): boolean; previewStatementRange(range: StatementRange | null): boolean; focusStatementRange(range: StatementRange | null): boolean; focusErrorPosition(offset: number): boolean; } export interface ContentAreaSurfaceProps { activeTab: QueryTab; activeConnection?: ConnectionConfig; executableSql: string; activeOutputView: TabOutputView; formatSqlRequest: { id: number; tabId: string } | null; compressSqlRequest: { id: number; tabId: string } | null; selectedSql: string; cursorPos: number; blockDangerousRedisCommands: boolean; zenMode?: boolean; } /** * Event contract between content surfaces and the workspace/App layer. * Every operation that can outlive a focus change โ€” execution, cancellation, * result paging, AI hand-off, formatting, view switches โ€” carries the tabId * of the tab that originated it, so consumers never have to re-read the * global active tab after an await (see redevelopment guide ยง6.1). */ export interface ContentAreaSurfaceEmits { closeTab: [tabId: string]; "locate-tab": [tab: QueryTab]; "update:activeOutputView": [tabId: string, value: TabOutputView]; fixWithAi: [tabId: string, errorMessage: string]; sendSelectionToAi: [tabId: string, sql: string]; previewChangesAvailable: [tabId: string, value: boolean]; execute: [tabId: string, sqlOverride?: SqlExecutionOverride]; executeInNewResultTab: [tabId: string, sqlOverride?: SqlExecutionOverride]; saveSql: [tabId: string]; cancel: [tabId: string]; explain: [tabId: string]; editorUpdate: [tabId: string, value: string]; editorSelectionChange: [tabId: string, value: string]; editorCursorChange: [tabId: string, pos: number]; editorViewportChange: [tabId: string, viewport: { scrollTop: number; scrollLeft: number }]; editorSelectionStateChange: [tabId: string, selection: { anchor: number; head: number }]; editorStateFlushed: [tabId: string]; formatError: [tabId: string]; reload: [tabId: string, sql?: string, searchText?: string, whereInput?: string, orderBy?: string, limit?: number, offset?: number, intent?: DataGridReloadIntent]; paginate: [tabId: string, offset: number, limit: number, whereInput?: string, orderBy?: string, appendResult?: boolean]; sort: [tabId: string, column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string, mode?: DataGridSortMode, effectiveOrderBy?: string]; executeSql: [tabId: string, sql: string]; clickTable: [tabId: string, target: SqlObjectNavigationTarget]; viewTableData: [tabId: string, target: SqlObjectNavigationTarget]; viewTableDdl: [tabId: string, target: SqlObjectNavigationTarget]; editTableStructure: [tabId: string, target: SqlObjectNavigationTarget]; openObjectSource: [tabId: string, target: SqlObjectNavigationTarget, initialEditing: boolean]; openObjectTable: [tabId: string, target: { tableName: string; schema?: string; tableType?: string; catalog?: string; comment?: string | null }]; openDatabaseSearchTarget: [tabId: string, target: NavigationTarget]; objectSchemaChange: [tabId: string, schema: string | undefined]; objectBrowserViewportChange: [tabId: string, viewport: ObjectBrowserViewport]; objectBrowserSearchChange: [tabId: string, query: string]; objectBrowserFilterChange: [tabId: string, filter: ObjectBrowserFilter]; addObjectTableToAi: [tabId: string, tables: Array<{ name: string; schema?: string }>]; structureEditorSaved: [tabId: string, commentChanged: boolean, createdTableName?: string]; structureEditorClose: [tabId: string]; previewStatement: [tabId: string, range: StatementRange | null]; focusStatement: [tabId: string, range: StatementRange | null]; focusErrorOffset: [tabId: string, offset: number]; openSettings: [initialTab?: string, initialSection?: string]; openConnectionSettings: [connectionId: string, initialTab: "advanced"]; toggleZenMode: []; toggleResultsPane: []; }