Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

fix(library): bind picker actions directly

CloudTianTianf343e2bcb0a3
diff --git a/src/renderer/index.html b/src/renderer/index.html
index 201c022c..ebf20bae 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -1690,8 +1690,8 @@
</div>
<div class="form-msg" id="kb-picker-msg"></div>
<div class="modal-actions">
- <button class="btn" onclick="closeKbPicker()" data-i18n="common.cancel">Cancel</button>
- <button class="btn btn-primary" onclick="confirmKbPicker()" data-i18n="common.confirm">Confirm</button>
+ <button class="btn" id="kb-picker-cancel" type="button" data-i18n="common.cancel">Cancel</button>
+ <button class="btn btn-primary" id="kb-picker-confirm" type="button" data-i18n="common.confirm">Confirm</button>
</div>
</div>
</div>
diff --git a/src/renderer/modules/kb-picker.js b/src/renderer/modules/kb-picker.js
index b03a7f9a..af7190d3 100644
--- a/src/renderer/modules/kb-picker.js
+++ b/src/renderer/modules/kb-picker.js
@@ -299,6 +299,8 @@ async function confirmKbPicker() {
}
}
window.confirmKbPicker = confirmKbPicker;
+document.getElementById('kb-picker-cancel')?.addEventListener('click', closeKbPicker);
+document.getElementById('kb-picker-confirm')?.addEventListener('click', confirmKbPicker);
/**
* Derive a default filename stem from message content. Strips markdown
diff --git a/test/renderer/kb-picker.test.ts b/test/renderer/kb-picker.test.ts
index c875b35f..224126a3 100644
--- a/test/renderer/kb-picker.test.ts
+++ b/test/renderer/kb-picker.test.ts
@@ -7,8 +7,15 @@ const source = readFileSync(
resolve(__dirname, '../../src/renderer/modules/kb-picker.js'),
'utf8',
);
+const indexSource = readFileSync(
+ resolve(__dirname, '../../src/renderer/index.html'),
+ 'utf8',
+);
-function load(initialStorage: Record<string, string> = {}) {
+function load(
+ initialStorage: Record<string, string> = {},
+ elements: Record<string, unknown> = {},
+) {
const values = new Map(Object.entries(initialStorage));
const translations: Record<string, string> = {
'contexts.root_label': 'Root',
@@ -31,7 +38,7 @@ function load(initialStorage: Record<string, string> = {}) {
setItem: (key: string, value: string) => { values.set(key, value); },
removeItem: (key: string) => { values.delete(key); },
},
- document: { getElementById: () => null },
+ document: { getElementById: (id: string) => elements[id] ?? null },
setTimeout: vi.fn(),
window: {},
};
@@ -41,6 +48,22 @@ function load(initialStorage: Record<string, string> = {}) {
}
describe('Library location picker', () => {
+ it('binds the visible cancel and confirm actions without inline global lookups', () => {
+ const cancel = { addEventListener: vi.fn() };
+ const confirm = { addEventListener: vi.fn() };
+ const { sandbox } = load({}, {
+ 'kb-picker-cancel': cancel,
+ 'kb-picker-confirm': confirm,
+ });
+
+ expect(indexSource).toContain('id="kb-picker-cancel"');
+ expect(indexSource).toContain('id="kb-picker-confirm"');
+ expect(indexSource).not.toContain('onclick="closeKbPicker()"');
+ expect(indexSource).not.toContain('onclick="confirmKbPicker()"');
+ expect(cancel.addEventListener).toHaveBeenCalledWith('click', sandbox.window.closeKbPicker);
+ expect(confirm.addEventListener).toHaveBeenCalledWith('click', sandbox.window.confirmKbPicker);
+ });
+
it('identifies the Global or Project Library in both the title and destination', () => {
const { sandbox } = load();
const target = { textContent: '' };