Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.0 KB
Raw Blame
export interface AiPromptKeydownLikeEvent {
  key: string;
  shiftKey?: boolean;
  isComposing?: boolean;
  keyCode?: number;
}

export interface AiPromptSubmissionState {
  prompt: string;
  contextItemCount: number;
  isAttachmentProcessing: boolean;
  hasTab: boolean;
  hasConnection: boolean;
}

export function canSubmitAiPrompt(state: AiPromptSubmissionState): boolean {
  return !state.isAttachmentProcessing && state.hasTab && state.hasConnection && (state.prompt.trim().length > 0 || state.contextItemCount > 0);
}

export function isAiPromptImeCompositionEvent(event: AiPromptKeydownLikeEvent, compositionActive = false): boolean {
  return compositionActive || !!event.isComposing || event.keyCode === 229 || event.key === "Process";
}

export function shouldSubmitAiPromptOnKeydown(event: AiPromptKeydownLikeEvent, compositionActive = false): boolean {
  if (event.key !== "Enter") return false;
  if (event.shiftKey) return false;
  if (isAiPromptImeCompositionEvent(event, compositionActive)) return false;
  return true;
}