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。

feat(ai): add select-all controls to skill picker

Hand Sonic46f7e95dc3d4
diff --git a/apps/desktop/src/components/editor/AiAssistant.vue b/apps/desktop/src/components/editor/AiAssistant.vue
index 3d37d463a7..a280ab27c6 100644
--- a/apps/desktop/src/components/editor/AiAssistant.vue
+++ b/apps/desktop/src/components/editor/AiAssistant.vue
@@ -643,6 +643,8 @@ const skillFailures = ref<ReadUserSkillFailure[]>([]);
// vanished from discovery must keep a removable chip (prd.md:37) instead of
// silently becoming an id the user can no longer drop.
const selectedSkillChips = computed(() => buildSelectedSkillChips(selectedSkillIds.value, (id) => userSkillStore.metaFor(id)));
+const selectableSkillIds = computed(() => userSkillStore.groupedSkills.flatMap((group) => group.skills.map((skill) => skill.id)));
+const canSelectAllSkills = computed(() => !userSkillStore.isLoading && !userSkillStore.lastError && selectableSkillIds.value.some((id) => !selectedSkillIds.value.includes(id)));
// Selector retry-on-open mirrors the template selector above.
watch(showSkillSelector, (open) => {
if (open) void userSkillStore.refresh(skillRootSettings());
@@ -666,6 +668,17 @@ function toggleSkillSelected(id: string) {
selectedSkillIds.value = selectedSkillIds.value.includes(id) ? selectedSkillIds.value.filter((skillId) => skillId !== id) : [...selectedSkillIds.value, id];
}
+function selectAllSkills() {
+ if (!canSelectAllSkills.value) return;
+ selectedSkillIds.value = [...new Set([...selectedSkillIds.value, ...selectableSkillIds.value])];
+ skillFailures.value = [];
+}
+
+function deselectAllSkills() {
+ selectedSkillIds.value = [];
+ skillFailures.value = [];
+}
+
function removeSelectedSkill(id: string) {
selectedSkillIds.value = removeSkillIds(selectedSkillIds.value, [id]);
skillFailures.value = [];
@@ -6380,7 +6393,7 @@ async function openExternalUrl(url: string) {
{{ t(group.source === "custom" ? "ai.skillsGroupCustom" : "ai.skillsGroupDefault") }}
</div>
<template v-for="skill in group.skills" :key="skill.id">
- <button type="button" class="flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-muted" @click="toggleSkillSelected(skill.id)">
+ <button type="button" class="flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-muted" :aria-pressed="selectedSkillIds.includes(skill.id)" @click="toggleSkillSelected(skill.id)">
<div class="flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border" :class="selectedSkillIds.includes(skill.id) ? 'border-primary bg-primary text-primary-foreground' : ''">
<Check v-if="selectedSkillIds.includes(skill.id)" class="h-3 w-3" />
</div>
@@ -6394,6 +6407,16 @@ async function openExternalUrl(url: string) {
</template>
</div>
<div class="border-t mt-1 px-1 pt-1">
+ <div class="flex gap-1">
+ <button type="button" class="flex min-w-0 flex-1 items-center gap-2 rounded-sm px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50" :disabled="!canSelectAllSkills" @click="selectAllSkills">
+ <Check class="h-3 w-3 shrink-0" />
+ {{ t("ai.skillsSelectAll") }}
+ </button>
+ <button type="button" class="flex min-w-0 flex-1 items-center gap-2 rounded-sm px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50" :disabled="selectedSkillIds.length === 0" @click="deselectAllSkills">
+ <X class="h-3 w-3 shrink-0" />
+ {{ t("ai.skillsDeselectAll") }}
+ </button>
+ </div>
<button type="button" class="flex w-full items-center gap-2 rounded-sm px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground" :disabled="userSkillStore.isLoading" @click="refreshSkills">
<Loader2 v-if="userSkillStore.isLoading" class="h-3 w-3 animate-spin" />
{{ t("ai.skillsRefresh") }}
diff --git a/apps/desktop/src/components/editor/__tests__/AiAssistant.mount.spec.ts b/apps/desktop/src/components/editor/__tests__/AiAssistant.mount.spec.ts
index d52a4c6035..ad991534e4 100644
--- a/apps/desktop/src/components/editor/__tests__/AiAssistant.mount.spec.ts
+++ b/apps/desktop/src/components/editor/__tests__/AiAssistant.mount.spec.ts
@@ -21,8 +21,10 @@ import type { AiExternalContextRequest } from "@/lib/ai/aiExternalContext";
import type { AiContext, AiRequestInput } from "@/lib/ai/ai";
import { buildAgentRequest } from "@/lib/ai/ai";
import { AI_SELECTION_CONTEXT_MAX_CHARS } from "@/lib/ai/aiAttachments";
+import type { UserSkillsListResult } from "@/types/userSkills";
const aiAssistantMountApi = vi.hoisted(() => ({
+ listUserSkills: vi.fn<() => Promise<UserSkillsListResult>>(),
conversations: [] as Array<Record<string, unknown>>,
runAgentStream: undefined as undefined | ((onEvent: (event: { type: string; delta?: string }) => void) => Promise<string>),
// #10058: the request the panel actually hands to the backend, and every
@@ -74,6 +76,7 @@ vi.mock("@/lib/backend/api", async (importOriginal) => {
return Promise.resolve();
},
readUserSkills: empty,
+ listUserSkills: aiAssistantMountApi.listUserSkills,
loadAiConfigs: empty,
listPlugins: empty,
loadPromptTemplates: empty,
@@ -102,6 +105,7 @@ afterEach(() => {
aiAssistantMountApi.runAgentStreamHistories = [];
aiAssistantMountApi.savedConversations = [];
aiAssistantMountApi.codeHighlighterDelayMs = 0;
+ aiAssistantMountApi.listUserSkills.mockReset();
while (cleanups.length) cleanups.pop()?.();
});
@@ -155,6 +159,114 @@ async function mountPanel(aiConfigLoaded: boolean, connection?: ConnectionConfig
}
describe("AiAssistant mount", () => {
+ function skillButton(label: string): HTMLButtonElement {
+ const button = [...document.querySelectorAll<HTMLButtonElement>("button")].find((item) => item.textContent?.trim() === label);
+ expect(button, label).toBeDefined();
+ return button!;
+ }
+
+ const skillCatalog: UserSkillsListResult = {
+ defaultRoot: {
+ status: "ok",
+ skills: [
+ { id: "d-one", name: "Default one", description: "" },
+ { id: "d-two", name: "Default two", description: "" },
+ ],
+ },
+ customRoot: { status: "ok", skills: [{ id: "c-one", name: "Custom one", description: "" }] },
+ };
+
+ it("selects all discovered skills without duplicates and keeps unavailable selections removable after refresh", async () => {
+ // happy-dom focus events can dismiss a newly teleported Reka popover.
+ const focus = vi.spyOn(HTMLElement.prototype, "focus").mockImplementation(() => {});
+ cleanups.push(() => focus.mockRestore());
+ aiAssistantMountApi.listUserSkills.mockResolvedValue(skillCatalog);
+ const { container, errors } = await mountPanel(true);
+ container.querySelector<HTMLButtonElement>(".ai-skills-selector-trigger")!.click();
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ expect(errors.map(String)).toEqual([]);
+ expect(aiAssistantMountApi.listUserSkills).toHaveBeenCalled();
+ await vi.waitFor(() => expect(document.querySelectorAll('[data-slot="popover-content"] button[aria-pressed="false"]')).toHaveLength(3));
+
+ const count = () => container.querySelector(".ai-skills-selector-count")?.textContent?.trim();
+ const selectAll = () => skillButton(i18n.global.t("ai.skillsSelectAll"));
+ const clear = () => skillButton(i18n.global.t("ai.skillsDeselectAll"));
+ expect(clear().disabled).toBe(true);
+ skillButton("Default one").click();
+ selectAll().click();
+ await vi.waitFor(() => expect(count()).toBe("3"));
+ expect(document.querySelectorAll('[data-slot="popover-content"] button[aria-pressed="true"]')).toHaveLength(3);
+ expect(selectAll().disabled).toBe(true);
+ selectAll().click();
+ expect(count()).toBe("3");
+
+ skillButton("Default one").click();
+ await vi.waitFor(() => expect(selectAll().disabled).toBe(false));
+ selectAll().click();
+ await vi.waitFor(() => expect(count()).toBe("3"));
+
+ aiAssistantMountApi.listUserSkills.mockResolvedValue({
+ defaultRoot: {
+ status: "ok",
+ skills: [
+ { id: "d-two", name: "Default two", description: "" },
+ { id: "d-three", name: "Default three", description: "" },
+ ],
+ },
+ customRoot: null,
+ });
+ skillButton(i18n.global.t("ai.skillsRefresh")).click();
+ await vi.waitFor(() => expect(selectAll().disabled).toBe(false));
+ selectAll().click();
+ await vi.waitFor(() => expect(count()).toBe("4"));
+ expect(container.textContent).toContain("c-one");
+ expect(container.textContent).toContain("d-one");
+
+ aiAssistantMountApi.listUserSkills.mockResolvedValue({ defaultRoot: { status: "missing", skills: [] }, customRoot: null });
+ skillButton(i18n.global.t("ai.skillsRefresh")).click();
+ await vi.waitFor(() => expect(document.body.textContent).toContain(i18n.global.t("ai.skillsEmpty")));
+ expect(selectAll().disabled).toBe(true);
+ expect(clear().disabled).toBe(false);
+ clear().click();
+ await vi.waitFor(() => expect(count()).toBeUndefined());
+ expect(clear().disabled).toBe(true);
+ expect(errors.map(String)).toEqual([]);
+ });
+
+ it("disables select-all during loading and errors but still allows clearing selected skills and retrying", async () => {
+ const focus = vi.spyOn(HTMLElement.prototype, "focus").mockImplementation(() => {});
+ cleanups.push(() => focus.mockRestore());
+ aiAssistantMountApi.listUserSkills.mockResolvedValue(skillCatalog);
+ const { container, errors } = await mountPanel(true);
+ container.querySelector<HTMLButtonElement>(".ai-skills-selector-trigger")!.click();
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ expect(errors.map(String)).toEqual([]);
+ const selectAll = () => skillButton(i18n.global.t("ai.skillsSelectAll"));
+ await vi.waitFor(() => expect(selectAll().disabled).toBe(false));
+ selectAll().click();
+ await vi.waitFor(() => expect(container.querySelector(".ai-skills-selector-count")?.textContent).toBe("3"));
+
+ let rejectRefresh!: (error: Error) => void;
+ aiAssistantMountApi.listUserSkills.mockImplementationOnce(
+ () =>
+ new Promise((_, reject) => {
+ rejectRefresh = reject;
+ }),
+ );
+ skillButton(i18n.global.t("ai.skillsRefresh")).click();
+ await vi.waitFor(() => expect(selectAll().disabled).toBe(true));
+ skillButton(i18n.global.t("ai.skillsDeselectAll")).click();
+ await vi.waitFor(() => expect(container.querySelector(".ai-skills-selector-count")).toBeNull());
+ rejectRefresh(new Error("QA catalog unavailable"));
+ await vi.waitFor(() => expect(document.body.textContent).toContain(i18n.global.t("ai.skillsLoadError")));
+ expect(selectAll().disabled).toBe(true);
+ skillButton(i18n.global.t("ai.skillsRetry")).click();
+ await vi.waitFor(() => expect(selectAll().disabled).toBe(false));
+ selectAll().click();
+ await vi.waitFor(() => expect(container.querySelector(".ai-skills-selector-count")?.textContent).toBe("3"));
+ expect(errors.map(String)).toEqual([]);
+ });
+
it("applies custom typography to restored message content and the prompt only", async () => {
aiAssistantMountApi.conversations = [
{
diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts
index 1528c10fe6..589d5768d6 100644
--- a/apps/desktop/src/i18n/locales/az.ts
+++ b/apps/desktop/src/i18n/locales/az.ts
@@ -3420,6 +3420,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "Bütün seçimləri ləğv et",
templateSelectorLoading: "Yüklənir...",
skillsEntry: "Skills",
+ skillsSelectAll: "Hamısını seç",
+ skillsDeselectAll: "Bütün seçimləri ləğv et",
skillsLoading: "Skills yüklənir…",
skillsEmpty: "Hələ skill tapılmadı",
skillsRefresh: "Siyahını yenilə",
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 2b9e6f77df..9352657f24 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -3801,6 +3801,8 @@ export default {
templateSelectorDeselectAll: "Deselect All",
templateSelectorLoading: "Loading...",
skillsEntry: "Skills",
+ skillsSelectAll: "Select all",
+ skillsDeselectAll: "Deselect all",
skillsLoading: "Loading skills…",
skillsEmpty: "No skills discovered yet",
skillsRefresh: "Refresh",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 614bcf3adf..c08296ee12 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -3545,6 +3545,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "Deseleccionar todas",
templateSelectorLoading: "Cargando...",
skillsEntry: "Skills",
+ skillsSelectAll: "Seleccionar todo",
+ skillsDeselectAll: "Deseleccionar todo",
skillsLoading: "Cargando skills…",
skillsEmpty: "Aún no se han detectado skills",
skillsRefresh: "Actualizar lista",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 314732039e..e86a7a6469 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -3363,6 +3363,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "Deseleziona tutto",
templateSelectorLoading: "Caricamento...",
skillsEntry: "Skills",
+ skillsSelectAll: "Seleziona tutto",
+ skillsDeselectAll: "Deseleziona tutto",
skillsLoading: "Caricamento skill…",
skillsEmpty: "Nessuna skill trovata",
skillsRefresh: "Aggiorna elenco",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index dfeeecb82a..692935e01e 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -3504,6 +3504,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "すべて解除",
templateSelectorLoading: "読み込み中...",
skillsEntry: "Skills",
+ skillsSelectAll: "すべて選択",
+ skillsDeselectAll: "選択をすべて解除",
skillsLoading: "Skills を読み込み中…",
skillsEmpty: "利用可能な Skills がありません",
skillsRefresh: "一覧を更新",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 123c8940a8..16923ff76d 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -3505,6 +3505,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "모두 선택 해제",
templateSelectorLoading: "불러오는 중...",
skillsEntry: "Skills",
+ skillsSelectAll: "모두 선택",
+ skillsDeselectAll: "모두 선택 해제",
skillsLoading: "Skills 을(를) 로드하는 중…",
skillsEmpty: "사용 가능한 Skills 이(가) 없습니다",
skillsRefresh: "목록 새로 고침",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 07f70ef051..0fedbffe9d 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -3471,6 +3471,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "Desmarcar todos",
templateSelectorLoading: "Carregando...",
skillsEntry: "Skills",
+ skillsSelectAll: "Selecionar tudo",
+ skillsDeselectAll: "Desmarcar tudo",
skillsLoading: "Carregando skills…",
skillsEmpty: "Nenhuma skill encontrada ainda",
skillsRefresh: "Atualizar lista",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index 01e234ca55..051382d128 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -3657,6 +3657,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "Снять выделение",
templateSelectorLoading: "Загрузка...",
skillsEntry: "Навыки",
+ skillsSelectAll: "Выбрать все",
+ skillsDeselectAll: "Снять выделение",
skillsLoading: "Загрузка навыков…",
skillsEmpty: "Навыки пока не найдены",
skillsRefresh: "Обновить",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index 552a88aa67..908070cdc5 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -3393,6 +3393,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "Tüm Seçimleri Kaldır",
templateSelectorLoading: "Yükleniyor...",
skillsEntry: "Skills",
+ skillsSelectAll: "Tümünü seç",
+ skillsDeselectAll: "Tümünün seçimini kaldır",
skillsLoading: "Skills yükleniyor…",
skillsEmpty: "Henüz skill bulunamadı",
skillsRefresh: "Listeyi yenile",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 1a51910bf3..020606cd78 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -3713,6 +3713,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "全不选",
templateSelectorLoading: "加载中...",
skillsEntry: "Skills",
+ skillsSelectAll: "全选",
+ skillsDeselectAll: "取消全选",
skillsLoading: "正在加载 Skills…",
skillsEmpty: "未发现可用 Skill",
skillsRefresh: "刷新列表",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 125b3edf02..102f348010 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -3361,6 +3361,8 @@ export default withEnglishFallback({
templateSelectorDeselectAll: "取消全選",
templateSelectorLoading: "載入中...",
skillsEntry: "Skills",
+ skillsSelectAll: "全選",
+ skillsDeselectAll: "取消全選",
skillsLoading: "正在載入 Skills…",
skillsEmpty: "未發現可用 Skill",
skillsRefresh: "重新整理清單",
diff --git a/docs/screenshots/issue-10793-select-all.png b/docs/screenshots/issue-10793-select-all.png
new file mode 100644
index 0000000000..9ef1575f93
Binary files /dev/null and b/docs/screenshots/issue-10793-select-all.png differ