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(agents): select focused picker results with Enter

CloudTianTiandf08b7c0921d
diff --git a/src/renderer/modules/agents.js b/src/renderer/modules/agents.js
index 0aa43ccd..92994a87 100644
--- a/src/renderer/modules/agents.js
+++ b/src/renderer/modules/agents.js
@@ -4583,23 +4583,19 @@ function _refreshAgentPickerSelection() {
el.dataset.recipientKeyboardWired = '1';
el.addEventListener('keydown', (event) => {
if (event.isComposing || event.keyCode === 229) return;
- if (event.key === ' ') {
+ if (event.key === ' ' || event.key === 'Enter') {
event.preventDefault();
el.dataset.pickerSourceType = 'keyboard';
el.click();
+ return;
}
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
event.preventDefault();
_moveAgentPickerActive(event.key === 'ArrowDown' ? 1 : -1);
list.querySelector('.skill-picker-item.active')?.focus();
}
- if (event.key === 'Enter' || event.key === 'Escape') {
+ if (event.key === 'Escape') {
event.preventDefault();
- if (event.key === 'Enter' && _atKeyMark) {
- el.dataset.pickerSourceType = 'keyboard';
- el.click();
- return;
- }
_closeAgentPicker();
_focusInput(_composerRecipientInput(_targetFromPickerAnchor(picker.dataset.anchorId)));
}
@@ -4966,13 +4962,6 @@ function bindAgentPickers() {
return;
}
if (e.key === 'Enter') {
- const picker = document.getElementById('agent-picker');
- if (_agentPickerTab === 'agents' && _isMultiRecipientPicker(picker?.dataset.anchorId) && !_atKeyMark) {
- e.preventDefault();
- _closeAgentPicker();
- _focusInput(_composerRecipientInput(_targetFromPickerAnchor(picker.dataset.anchorId)));
- return;
- }
const listEl = document.getElementById('agent-picker-list');
const active = listEl?.querySelector('.skill-picker-item.active[data-id]')
|| listEl?.querySelector('.skill-picker-item[data-id]');
diff --git a/test/renderer/agent-picker-selection.test.ts b/test/renderer/agent-picker-selection.test.ts
index 992bb7b1..60e1cbf3 100644
--- a/test/renderer/agent-picker-selection.test.ts
+++ b/test/renderer/agent-picker-selection.test.ts
@@ -39,6 +39,7 @@ function pickerHarness(anchorId: string, atKey: boolean) {
const header = new Element();
const input = {
value: '@Codex work @',
+ focus() {},
setSelectionRange() {},
dispatchEvent() {},
};
@@ -59,6 +60,7 @@ function pickerHarness(anchorId: string, atKey: boolean) {
escapeHtml: (s: string) => s,
_composerSelectedRecipients: vi.fn(() => selected),
_toggleComposerRecipient: vi.fn(),
+ _composerRecipientInput: () => input,
setTimeout: (fn: Function) => fn(),
Event: class {},
addEventListener() {},
@@ -97,14 +99,24 @@ describe('agent picker selection display', () => {
expect(vm.runInContext('_atKeyMark', context)).toBeNull();
});
- it('keeps Enter on a focused autocomplete result as selection', () => {
- const { list } = pickerHarness('new-chat-recipient-chip', true);
+ it.each([false, true])('selects a focused result with Enter (opened with @: %s)', (atKey) => {
+ const { list } = pickerHarness('new-chat-recipient-chip', atKey);
const select = vi.fn();
list.children[2].handlers.click = select;
list.children[2].handlers.keydown({ key: 'Enter', preventDefault() {} });
expect(select).toHaveBeenCalledOnce();
});
+ it.each([{ isComposing: true }, { keyCode: 229 }])('does not select while confirming an IME candidate: %j', (composition) => {
+ const { list } = pickerHarness('new-chat-recipient-chip', false);
+ const select = vi.fn();
+ list.children[2].handlers.click = select;
+ const preventDefault = vi.fn();
+ list.children[2].handlers.keydown({ key: 'Enter', preventDefault, ...composition });
+ expect(select).not.toHaveBeenCalled();
+ expect(preventDefault).not.toHaveBeenCalled();
+ });
+
it('keeps automation outside the multi-recipient display', () => {
const { context, header, list } = pickerHarness('auto-recipient-chip', false);
expect(context._composerSelectedRecipients).not.toHaveBeenCalled();