Agent Zero AI framework
Add optional Right Click menus for chats, tasks, and files
Alessandrof4f7823b5fb8
diff --git a/plugins/AGENTS.md b/plugins/AGENTS.mdindex 0e1639a04..f6e6d2f8f 100644--- a/plugins/AGENTS.md+++ b/plugins/AGENTS.md@@ -99,6 +99,7 @@ Direct child DOX files:| [_plugin_scan/AGENTS.md](_plugin_scan/AGENTS.md) | LLM-guided security scanner for third-party plugins. || [_plugin_validator/AGENTS.md](_plugin_validator/AGENTS.md) | Plugin manifest, structure, convention, and security validator. || [_promptinclude/AGENTS.md](_promptinclude/AGENTS.md) | Promptinclude scanning and prompt injection. |+| [_right-click/AGENTS.md](_right-click/AGENTS.md) | Optional right-click menus for sidebar chats/tasks and Files entries. || [_skills/AGENTS.md](_skills/AGENTS.md) | Active and hidden skill configuration and prompt injection. || [_telegram_integration/AGENTS.md](_telegram_integration/AGENTS.md) | Telegram bot integration and per-user chat sessions. || [_text_editor/AGENTS.md](_text_editor/AGENTS.md) | Native text read, write, and patch tool. |diff --git a/plugins/_right-click/AGENTS.md b/plugins/_right-click/AGENTS.mdnew file mode 100644index 000000000..ef8d248fc--- /dev/null+++ b/plugins/_right-click/AGENTS.md@@ -0,0 +1,43 @@+# Right Click Plugin DOX++## Purpose++- Own optional right-click actions for sidebar chats/tasks and Files entries.++## Ownership++- `plugin.yaml` owns the toggleable, configuration-free bundled plugin.+- `api/chat_files_path.py` resolves a known chat's saved folder through `persist_chat`; the endpoint retains default authentication/CSRF and never creates or selects a context.+- `webui/right-click-store.js` owns gesture routing, pointer placement, dismissal, and keyboard focus.+- `extensions/webui/sidebar-start/` owns page-scoped listeners and their Alpine teardown.+- `extensions/webui/sidebar-row-actions-menu/` adds Open in Files and Save/Load only to chat context menus.+- `extensions/webui/file-browser-actions-menu/` adds directory Open, file Download, and inline-confirmed Delete only to file context menus.+- `webui/thumbnail.webp` owns the generated 256 × 256 plugin thumbnail, kept below 20,000 bytes.++## Local Contracts++- Keep `always_enabled: false`; activation uses the standard plugin toggle and frontend reload.+- Invoke the existing row's overflow trigger, preserving plugin actions and Files host ownership; never clone menus or patch stores.+- Reuse Files dropdown positioning and the shared dropdown styles.+- Right-click must not select a chat, navigate a folder, open a file, or change checkbox selection.+- Save passes the clicked chat ID to `chats.saveChat(ctxid)` without switching the active chat.+- Open in Files resolves the clicked chat through this plugin's `chat_files_path` endpoint, then uses `chatInput.browseFiles(path)` for standard canvas/modal routing. Always open `usr/chats/<id>`, independent of project membership; use `usr/chats` if the chat has no saved folder yet. Reject missing/unknown IDs rather than selecting or creating a context. Do not infer the path from the selected chat or fall back to another chat on errors.+- Disable Open in Files while Files is loading, renaming, or doing bulk work so its navigation guards preserve pending operations.+- File actions keep backend-owned remote permission checks. Reuse existing Edit (Editor), Open in Browser/Desktop, and folder Download ZIP entries without duplication.+- Delete uses `$confirmClick` and stops the click from reaching the menu's automatic close handler; close only after confirmation. Closing the menu discards the plugin entry and its armed state.+- Preserve native menus outside supported rows, in text inputs and file pickers, and with Shift held.+- Close on outside click, surrounding scroll, resize, Escape, action, and unmount; scrolling the menu itself stays usable.++## Work Guidance++- Keep gesture behavior plugin-local and both existing three-dot menus intact.+- Cover parent/child chats, task rows, list/icon entries, and modal/canvas Files hosts.++## Verification++- Run `pytest plugins/_right-click/tests tests/test_sidebar_row_actions.py tests/test_editor_files.py`.+- Smoke-test plugin disable/re-enable with page reload, keyboard navigation, and viewport-edge placement.++## Child DOX Index++No child DOX files.diff --git a/plugins/_right-click/README.md b/plugins/_right-click/README.mdnew file mode 100644index 000000000..6964e0386--- /dev/null+++ b/plugins/_right-click/README.md@@ -0,0 +1,21 @@+# Right Click++Right-click a sidebar chat or task, or a file/folder entry in list or icon view,+to open its existing action menu at the pointer. Chat menus also include+**Open in Files**, **Save Chat** (for the clicked chat), and **Load Chat**, alongside+Pin and Rename. Open in Files uses the clicked chat's saved folder under+`usr/chats`, regardless of its project, and the existing canvas/window preference+without selecting that chat. Chats without a saved folder yet open `usr/chats`.+The three-dot buttons keep their original menus.++File menus include **Download** and **Delete** (click again to confirm), along+with the existing **Edit** action for Editor and **Open in Browser/Desktop** for+supported file types. Folders offer **Open** and **Download ZIP**. Remote actions+respect the connection's permissions.++Use the arrow keys to navigate, Enter to choose, and Escape to dismiss.+Shift + right-click keeps the browser's native menu. File pickers and text inputs+retain their native right-click behavior.++Enabled by default. Disable **Right Click** in Plugins and reload the page to+restore native right-click menus everywhere.diff --git a/plugins/_right-click/api/chat_files_path.py b/plugins/_right-click/api/chat_files_path.pynew file mode 100644index 000000000..f543f4e3d--- /dev/null+++ b/plugins/_right-click/api/chat_files_path.py@@ -0,0 +1,18 @@+from agent import AgentContext+from helpers import files, persist_chat+from helpers.api import ApiHandler, Request, Response+++class ChatFilesPath(ApiHandler):+ async def process(self, input: dict, request: Request) -> dict | Response:+ ctxid = input.get("ctxid")+ if not isinstance(ctxid, str) or not ctxid:+ return Response("Missing chat ID.", 400)+ context = AgentContext.get(ctxid)+ if not context:+ return Response("Chat context not found.", 404)++ path = persist_chat.get_chat_folder_path(context.id)+ if not files.is_dir(path):+ path = files.get_abs_path(persist_chat.CHATS_FOLDER)+ return {"ok": True, "path": files.normalize_a0_path(path)}diff --git a/plugins/_right-click/extensions/webui/file-browser-actions-menu/file-actions.html b/plugins/_right-click/extensions/webui/file-browser-actions-menu/file-actions.htmlnew file mode 100644index 000000000..0515338d2--- /dev/null+++ b/plugins/_right-click/extensions/webui/file-browser-actions-menu/file-actions.html@@ -0,0 +1,30 @@+<html>+<head>+ <script type="module">+ import { store } from "/plugins/_right-click/webui/right-click-store.js";+ </script>+</head>+<body>+ <div x-data x-show="$store.rightClick.kind === 'file' && ($store.fileBrowser.remoteAllowed(file.is_dir ? 'browse' : 'download', file) || $store.fileBrowser.remoteAllowed('delete', file))">+ <div class="dropdown-separator"></div>+ <button type="button" class="dropdown-item"+ x-show="file.is_dir && $store.fileBrowser.remoteAllowed('browse', file)"+ @click="$store.fileBrowser.navigateToFolder(file.path)">+ <x-icon name="folder_open"></x-icon>+ <span>Open</span>+ </button>+ <button type="button" class="dropdown-item"+ x-show="!file.is_dir && $store.fileBrowser.remoteAllowed('download', file)"+ @click="$store.fileBrowser.downloadFile(file)">+ <x-icon name="download"></x-icon>+ <span>Download</span>+ </button>+ <button type="button" class="dropdown-item"+ x-show="$store.fileBrowser.remoteAllowed('delete', file)"+ @click.stop="$confirmClick($event, () => { $store.fileBrowser.deleteFile(file); $store.rightClick.close(); })">+ <x-icon name="delete"></x-icon>+ <span>Delete</span>+ </button>+ </div>+</body>+</html>diff --git a/plugins/_right-click/extensions/webui/sidebar-row-actions-menu/chat-actions.html b/plugins/_right-click/extensions/webui/sidebar-row-actions-menu/chat-actions.htmlnew file mode 100644index 000000000..756f5ff8e--- /dev/null+++ b/plugins/_right-click/extensions/webui/sidebar-row-actions-menu/chat-actions.html@@ -0,0 +1,28 @@+<html>+<head>+ <script type="module">+ import { store } from "/plugins/_right-click/webui/right-click-store.js";+ </script>+</head>+<body>+ <div x-data x-show="$store.rightClick.kind === 'sidebar' && $store.sidebar.rowMenuKind === 'chat'">+ <div class="dropdown-separator"></div>+ <button type="button" class="dropdown-item" role="menuitem"+ :disabled="$store.fileBrowser.isLoading || $store.fileBrowser.isRenaming || $store.fileBrowser.isBulkBusy"+ @click="$store.rightClick.openChatFiles()">+ <x-icon name="folder_open"></x-icon>+ <span>Open in Files</span>+ </button>+ <button type="button" class="dropdown-item" role="menuitem"+ @click="$store.chats.saveChat($store.rightClick.chatId); $store.rightClick.close()">+ <x-icon name="download"></x-icon>+ <span>Save Chat</span>+ </button>+ <button type="button" class="dropdown-item" role="menuitem"+ @click="$store.chats.loadChats(); $store.rightClick.close()">+ <x-icon name="upload"></x-icon>+ <span>Load Chat</span>+ </button>+ </div>+</body>+</html>diff --git a/plugins/_right-click/extensions/webui/sidebar-start/right-click.html b/plugins/_right-click/extensions/webui/sidebar-start/right-click.htmlnew file mode 100644index 000000000..8bd644ce2--- /dev/null+++ b/plugins/_right-click/extensions/webui/sidebar-start/right-click.html@@ -0,0 +1,17 @@+<html>+<head>+ <script type="module">+ import { store } from "/plugins/_right-click/webui/right-click-store.js";+ </script>+</head>+<body>+ <div x-data+ @contextmenu.document="$store.rightClick.open($event)"+ @click.document.capture="$store.rightClick.closeOutside($event)"+ @scroll.window.capture="$store.rightClick.closeOutside($event)"+ @resize.window="$store.rightClick.close()"+ @keydown.window.capture="$store.rightClick.keydown($event)"+ x-effect="if ($store.rightClick.kind && !$store.rightClick.isOpen()) $store.rightClick.close()"+ x-destroy="$store.rightClick.close()"></div>+</body>+</html>diff --git a/plugins/_right-click/plugin.yaml b/plugins/_right-click/plugin.yamlnew file mode 100644index 000000000..fe5b718d4--- /dev/null+++ b/plugins/_right-click/plugin.yaml@@ -0,0 +1,8 @@+name: _right-click+title: Right Click+description: Right-click chats, tasks, and file entries to open their action menus.+version: 1.0.0+settings_sections: []+per_project_config: false+per_agent_config: false+always_enabled: falsediff --git a/plugins/_right-click/tests/test_chat_files_path.py b/plugins/_right-click/tests/test_chat_files_path.pynew file mode 100644index 000000000..2d394aa49--- /dev/null+++ b/plugins/_right-click/tests/test_chat_files_path.py@@ -0,0 +1,27 @@+import asyncio+from importlib import import_module+from pathlib import Path+from types import SimpleNamespace+++def test_saved_chat_folder_and_unsaved_fallback(monkeypatch, tmp_path):+ monkeypatch.syspath_prepend(str(Path(__file__).resolve().parents[3]))+ module = import_module('plugins._right-click.api.chat_files_path')+ monkeypatch.setattr(module.persist_chat, 'CHATS_FOLDER', str(tmp_path))+ contexts = {'saved': SimpleNamespace(id='saved'), 'new': SimpleNamespace(id='new')}+ monkeypatch.setattr(module.AgentContext, 'get', contexts.get)+ (tmp_path / 'saved').mkdir()+ handler = module.ChatFilesPath(None, None)++ def resolve(ctxid):+ return asyncio.run(handler.process({'ctxid': ctxid}, None))++ assert resolve('saved') == {'ok': True, 'path': str(tmp_path / 'saved')}+ assert resolve('new') == {'ok': True, 'path': str(tmp_path)}+ assert not (tmp_path / 'new').exists(), 'browsing must not create or persist a chat'+ assert resolve('missing').status_code == 404+ assert resolve('../../etc').status_code == 404+ for ctxid in ('', None, []):+ assert resolve(ctxid).status_code == 400+ assert handler.requires_auth() is True+ assert handler.requires_csrf() is Truediff --git a/plugins/_right-click/tests/test_right_click.py b/plugins/_right-click/tests/test_right_click.pynew file mode 100644index 000000000..668e9992b--- /dev/null+++ b/plugins/_right-click/tests/test_right_click.py@@ -0,0 +1,232 @@+"""Exercise right-click routing with the real menu and chat stores."""+from pathlib import Path+import re+import subprocess+++ROOT = Path(__file__).resolve().parents[3]+++def test_right_click_menus_and_targeted_export():+ def store_source(path):+ source = (ROOT / path).read_text()+ source = re.sub(r'^import\b[\s\S]*?;\n', '', source, flags=re.M)+ source = source.replace('export const store =', 'const store =')+ source = source.replace('export { store };', '')+ return '(() => {\n' + source + '\nreturn store;\n})()'++ script = r'''+import assert from 'node:assert/strict';+const createStore = (_name, model) => model;+const createFileTree = () => ({});+const window = { innerWidth: 800, innerHeight: 600 };+globalThis.Alpine = { nextTick: async () => {} };+const document = { activeElement: null, querySelectorAll: () => [menu] };+const buttons = [0, 1].map(id => ({+ id, checkVisibility: () => true, focus() { document.activeElement = this; },+}));+const menu = {+ offsetWidth: 210, checkVisibility: () => true,+ querySelectorAll: () => buttons, contains: target => target === menu || buttons.includes(target),+};+const exported = [];+const sendJsonData = async (url, body) => {+ assert.equal(url, '/chat_export'); exported.push(body.ctxid);+ return { ctxid: body.ctxid, content: '{}' };+};+const getContext = () => 'fallback';+const toast = () => {};+const toastFetchError = (_message, error) => { throw error; };+const fileRequests = [], openedPaths = [], errors = [];+let pathResponse = {ok:true, path:'/a0/usr/chats/clicked'};+const callJsonApi = async (url, body) => {+ assert.equal(url, '/plugins/_right-click/chat_files_path'); fileRequests.push(body.ctxid);+ return pathResponse;+};+const chatInputStore = {browseFiles: async path => openedPaths.push(path)};+const toastFrontendError = message => errors.push(message);+'''+ for name, path in [+ ('sidebarStore', 'webui/components/sidebar/sidebar-store.js'),+ ('fileBrowserStore', 'webui/components/modals/file-browser/file-browser-store.js'),+ ('chatsStore', 'webui/components/sidebar/chats/chats-store.js'),+ ('rightClick', 'plugins/_right-click/webui/right-click-store.js'),+ ]:+ script += f'const {name} = {store_source(path)};\n'++ script += r'''+const owner = {};+let currentKind = 'chat', currentId = 'unselected', blocked = false;+const rect = { left: 10, right: 230, top: 40, bottom: 80 };+const trigger = {+ getBoundingClientRect: () => rect, closest: () => owner,+ focus() { document.activeElement = this; },+ click() {+ rightClick.closeOutside({ target: this });+ if (currentKind === 'file') fileBrowserStore.toggleDropdown(currentId, this);+ else sidebarStore.rowMenuToggle(`${currentKind}:${currentId}`, currentKind, this);+ },+};+const row = {+ matches: () => currentKind === 'file', querySelector: () => trigger,+ getBoundingClientRect: () => rect,+};+const event = (extra = {}) => ({+ target: { closest: selector => selector.startsWith('input') ? blocked : row },+ clientX: 790, clientY: 590, defaultPrevented: false,+ preventDefault() { this.defaultPrevented = true; }, ...extra,+});+chatsStore.selected = 'selected';+chatsStore.downloadFile = () => {};+for (const [kind, id] of [['chat', 'unselected'], ['chat', 'child'], ['task', 'scheduled'], ['file', '/a0/test.txt']]) {+ currentKind = kind; currentId = id;+ const opened = event();+ await rightClick.open(opened);+ assert.equal(opened.defaultPrevented, true);+ assert.equal(rightClick.isOpen(), true);+ assert.equal(chatsStore.selected, 'selected', 'right-click preserves active chat');+ assert.equal(document.activeElement, buttons[0]);+ const style = kind === 'file' ? fileBrowserStore.dropdownStyle : sidebarStore.rowMenuStyle;+ assert.equal(style.left, '582px', 'use measured width at right edge');+ assert.equal(style.top, 'auto', 'open upward at bottom edge');+ assert.equal(style.bottom, '16px');+ if (kind === 'file') assert.equal(fileBrowserStore.dropdownOwner, owner);+ if (kind === 'chat') {+ assert.equal(rightClick.chatId, id);+ await chatsStore.saveChat(rightClick.chatId);+ assert.equal(exported.at(-1), id, 'export clicked chat, not selection');+ } else assert.equal(rightClick.chatId, '');+ await rightClick.open(event({ clientX: 25, clientY: 50 }));+ assert.equal(rightClick.isOpen(), true, 'repeated right-click reopens instead of toggling');+ rightClick.closeOutside({ target: menu });+ assert.equal(rightClick.isOpen(), true, 'menu clicks and scrolling stay usable');+ const key = key => ({ key, preventDefault() {}, stopPropagation() {} });+ rightClick.keydown(key('ArrowDown'));+ assert.equal(document.activeElement, buttons[1]);+ rightClick.keydown(key('Home'));+ assert.equal(document.activeElement, buttons[0]);+ rightClick.keydown(key('Escape'));+ assert.equal(rightClick.isOpen(), false);+ assert.equal(document.activeElement, trigger);+}+document.activeElement = null;+await rightClick.open(event({ pointerType: 'mouse' }));+assert.equal(document.activeElement, null, 'pointer menus do not force a keyboard focus ring');+rightClick.keydown({ key: 'ArrowUp', preventDefault() {}, stopPropagation() {} });+assert.equal(document.activeElement, buttons.at(-1), 'ArrowUp starts at the last menu item');+for (const extra of [{ shiftKey: true }, { defaultPrevented: true }, { target: { closest: () => null } }]) {+ await rightClick.open(event(extra));+ assert.equal(rightClick.isOpen(), false, 'respect native or already-handled menus');+}+blocked = true;+let native = event(); await rightClick.open(native);+assert.equal(native.defaultPrevented, false, 'inert rows and text fields keep native behavior');+blocked = false;+fileBrowserStore.pickerMode = 'text-open';+native = event(); await rightClick.open(native);+assert.equal(native.defaultPrevented, false, 'picker does not expose hidden file actions');+fileBrowserStore.pickerMode = '';+await rightClick.open(event());+rightClick.closeOutside({ target: {} });+assert.equal(rightClick.isOpen(), false);+currentKind = 'chat';+await rightClick.open(event());+trigger.click();+assert.equal(rightClick.kind, '', 'ordinary overflow click hides the extra chat actions');+assert.equal(sidebarStore.rowMenuOpenId, `chat:${currentId}`);+rightClick.chatId = 'clicked';+rightClick.kind = 'sidebar';+await rightClick.openChatFiles();+assert.deepEqual(fileRequests, ['clicked']);+assert.deepEqual(openedPaths, ['/a0/usr/chats/clicked']);+assert.equal(chatsStore.selected, 'selected', 'Open in Files keeps the current chat selected');+assert.equal(sidebarStore.rowMenuOpenId, '');+rightClick.chatId = 'missing';+pathResponse = {ok:false, error:'Chat unavailable'};+await rightClick.openChatFiles();+assert.equal(openedPaths.length, 1, 'failed lookup does not open another chat folder');+assert.deepEqual(errors, ['Chat unavailable']);+await chatsStore.saveChat();+assert.equal(exported.at(-1), 'selected', 'header Save Chat keeps its default target');+chatsStore.selected = '';+await chatsStore.saveChat();+assert.equal(exported.at(-1), 'fallback');+chatsStore.readJsonFiles = async () => [];+await chatsStore.loadChats();+assert.equal(exported.at(-1), 'fallback', 'cancelling Load does not send an empty request');+'''+ subprocess.run(['node', '--input-type=module'], input=script, text=True,+ check=True, timeout=15, cwd=ROOT)+++def test_file_delete_uses_shared_two_click_confirmation():+ html = (ROOT / 'plugins/_right-click/extensions/webui/file-browser-actions-menu/file-actions.html').read_text()+ handler = re.search(r'@click\.stop="([^"]*\$confirmClick[^"]*)"', html).group(1)+ source = (ROOT / 'webui/js/confirmClick.js').read_text()+ source = re.sub(r'^import\b[\s\S]*?;\n', '', source, flags=re.M)+ source = source.replace('export function ', 'function ')+ script = r'''+import assert from 'node:assert/strict';+const ICON_SELECTOR = 'x-icon';+const getIconName = icon => icon.name;+const setIconName = (icon, name) => icon.name = name;+let reset, deleted = [], closes = 0;+const setTimeout = callback => {reset = callback; return 1;};+const clearTimeout = () => {};+const icon = {name:'delete', textContent:''};+const classes = new Set();+const button = {+ textContent:'Delete', innerHTML:'<x-icon name="delete"></x-icon><span>Delete</span>',+ querySelector: () => icon, classList:{add:name => classes.add(name), remove:name => classes.delete(name)},+};+const file = {path:'/a0/tmp/delete-check'};+const $store = {fileBrowser:{deleteFile: item => deleted.push(item.path)}, rightClick:{close:() => closes++}};+''' + source + '\nconst click = ($event, $confirmClick, $store, file) => {' + handler + r'''};+click({currentTarget:button}, confirmClick, $store, file);+assert.equal(deleted.length, 0);+assert.equal(closes, 0, 'first click must keep the menu open');+assert.equal(classes.has('confirming'), true);+assert.match(button.innerHTML, /Confirm/);+reset();+assert.equal(classes.has('confirming'), false);+click({currentTarget:button}, confirmClick, $store, file);+assert.equal(deleted.length, 0, 'expired confirmation needs a new first click');+click({currentTarget:button}, confirmClick, $store, file);+assert.deepEqual(deleted, [file.path]);+assert.equal(closes, 1);+'''+ subprocess.run(['node', '--input-type=module'], input=script, text=True,+ check=True, timeout=15, cwd=ROOT)+++def test_files_navigation_applies_the_path_to_canvas_and_modal():+ source = (ROOT / 'webui/components/chat/input/input-store.js').read_text()+ source = re.sub(r'^import\b[\s\S]*?;\n', '', source, flags=re.M)+ source = source.replace('export { store };', '')+ script = r'''+import assert from 'node:assert/strict';+const createStore = (_name, model) => model;+const calls = [];+let opened = true;+const shortcuts = {+ getCurrentContextId: () => 'selected',+ callJsonApi: async () => ({ok:true, path:'/workdir'}),+};+const openLatestSurface = async (_id, payload) => {calls.push(['surface', payload.path]); return opened;};+const fileBrowserStore = {+ navigateToFolder: async path => calls.push(['navigate', path]),+ open: async path => calls.push(['fallback', path]),+};+''' + source + r'''+await store.browseFiles('/a0/usr/chats/clicked');+assert.deepEqual(calls, [['surface','/a0/usr/chats/clicked'], ['navigate','/a0/usr/chats/clicked']]);+calls.length = 0;+await store.browseFiles();+assert.deepEqual(calls, [['surface','/workdir'], ['navigate','/workdir']]);+calls.length = 0;+opened = false;+await store.browseFiles('/a0/usr/chats/clicked');+assert.deepEqual(calls, [['surface','/a0/usr/chats/clicked'], ['fallback','/a0/usr/chats/clicked']]);+'''+ subprocess.run(['node', '--input-type=module'], input=script, text=True,+ check=True, timeout=15, cwd=ROOT)diff --git a/plugins/_right-click/webui/right-click-store.js b/plugins/_right-click/webui/right-click-store.jsnew file mode 100644index 000000000..1e150d588--- /dev/null+++ b/plugins/_right-click/webui/right-click-store.js@@ -0,0 +1,115 @@+import { createStore } from "/js/AlpineStore.js";+import { callJsonApi } from "/js/api.js";+import { toastFrontendError } from "/components/notifications/notification-store.js";+import { store as chatInputStore } from "/components/chat/input/input-store.js";+import { store as sidebarStore } from "/components/sidebar/sidebar-store.js";+import { store as fileBrowserStore } from "/components/modals/file-browser/file-browser-store.js";++const model = {+ kind: "",+ chatId: "",+ menu: null,+ trigger: null,++ async open(event) {+ this.close();+ if (event.defaultPrevented || event.shiftKey) return;+ const target = event.target;+ if (target.closest('input:not([type="checkbox"]), textarea, [contenteditable="true"], [inert]')) return;+ const row = target.closest(".chat-container, .task-container, .file-item");+ if (!row) return;+ const isFile = row.matches(".file-item");+ if (isFile && fileBrowserStore.isPickerMode()) return;+ const trigger = row.querySelector(isFile ? ".dropdown-trigger" : '[aria-haspopup="menu"]');+ if (!trigger || trigger.disabled) return;++ event.preventDefault();+ sidebarStore.menuClose();+ sidebarStore.rowMenuClose();+ fileBrowserStore.closeDropdown();+ // Use the existing row action, including its owning Files host and plugin actions.+ trigger.click();+ this.trigger = trigger;+ this.kind = isFile ? "file" : "sidebar";+ this.chatId = !isFile && sidebarStore.rowMenuKind === "chat"+ ? sidebarStore.rowMenuOpenId.slice("chat:".length) : "";++ const rect = row.getBoundingClientRect();+ const x = event.clientX || rect.left;+ const y = event.clientY || rect.bottom;+ const anchor = { getBoundingClientRect: () => ({ left: x, right: x, top: y, bottom: y }) };+ const position = width => {+ const style = fileBrowserStore.getDropdownStyle(anchor, width, false);+ if (isFile) fileBrowserStore.dropdownStyle = style;+ else sidebarStore.rowMenuStyle = style;+ };+ position(180);+ await globalThis.Alpine.nextTick();+ if (this.trigger !== trigger || !this.isOpen()) return;+ this.menu = Array.from(document.querySelectorAll(isFile ? ".file-actions-menu" : ".sidebar-row-actions-menu"))+ .find(menu => menu.checkVisibility()) || null;+ if (this.menu) {+ position(this.menu.offsetWidth);+ if (!event.pointerType) this.buttons()[0]?.focus({ preventScroll: true });+ }+ },++ isOpen() {+ return this.kind === "file" ? !!fileBrowserStore.openDropdownPath+ : this.kind === "sidebar" && !!sidebarStore.rowMenuOpenId;+ },++ async openChatFiles() {+ const ctxid = this.chatId;+ this.close();+ if (!ctxid) return;+ try {+ const response = await callJsonApi("/plugins/_right-click/chat_files_path", { ctxid });+ if (!response?.ok || !response.path) throw new Error(response?.error || "Could not find the chat's files.");+ await chatInputStore.browseFiles(response.path);+ } catch (error) {+ void toastFrontendError(error?.message || "Could not open chat files.", "Open in Files");+ }+ },++ close(restoreFocus = false) {+ if (this.kind === "file") fileBrowserStore.closeDropdown();+ if (this.kind === "sidebar") sidebarStore.rowMenuClose();+ if (restoreFocus) this.trigger?.focus({ preventScroll: true });+ this.kind = "";+ this.chatId = "";+ this.menu = null;+ this.trigger = null;+ },++ closeOutside(event) {+ if (!this.menu?.contains(event.target)) this.close();+ },++ buttons() {+ return Array.from(this.menu?.querySelectorAll("button:not(:disabled)") || [])+ .filter(button => button.checkVisibility());+ },++ keydown(event) {+ if (!this.isOpen()) return;+ if (event.key === "Escape" || event.key === "Tab") {+ if (event.key === "Escape") {+ event.preventDefault();+ event.stopPropagation();+ }+ this.close(true);+ } else if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {+ event.preventDefault();+ event.stopPropagation();+ const buttons = this.buttons();+ const index = buttons.indexOf(document.activeElement);+ const next = event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1+ : event.key === "ArrowDown" ? (index + 1) % buttons.length+ : (index < 0 ? buttons.length - 1 : (index - 1 + buttons.length) % buttons.length);+ buttons[next]?.focus({ preventScroll: true });+ }+ },+};++export const store = createStore("rightClick", model);diff --git a/plugins/_right-click/webui/thumbnail.webp b/plugins/_right-click/webui/thumbnail.webpnew file mode 100644index 000000000..5a9ee3c8dBinary files /dev/null and b/plugins/_right-click/webui/thumbnail.webp differdiff --git a/webui/components/chat/AGENTS.md b/webui/components/chat/AGENTS.mdindex dd759d07c..635c0c455 100644--- a/webui/components/chat/AGENTS.md+++ b/webui/components/chat/AGENTS.md@@ -31,6 +31,7 @@- While the selected context is running, an empty composer makes the primary button stop the active run; typed text still adds to the queue, and Enter with an empty composer still sends queued messages.- Chat navigation controls must cross virtual message-window boundaries; top and bottom target the full cached history rather than only the mounted DOM slice.- The page-wide attachment drop overlay must activate only for external file drags so internal WebUI drag interactions keep their own targets.+- `chatInput.browseFiles(path)` applies its resolved directory after opening Files, including modal routes that only mount the surface chrome; same-folder navigation remains a no-op.## Work Guidancediff --git a/webui/components/chat/input/input-store.js b/webui/components/chat/input/input-store.jsindex b54e2acaa..1abf9aea7 100644--- a/webui/components/chat/input/input-store.js+++ b/webui/components/chat/input/input-store.js@@ -576,6 +576,7 @@ const model = {} catch (error) {console.error("Error opening Files surface", error);}+ if (opened && path) await fileBrowserStore.navigateToFolder(path);if (!opened) await fileBrowserStore.open(path);},