[PR #280] feat(spotlight): context-aware Spotlight (selection, source app, fold… #241

Open
opened 2026-10-18 14:07:16 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/desktop/pull/280
Author: @BenAndNuts
Created: 10/14/2026
Status: 🔄 Open

Base: main ← Head: feat/spotlight-context


📝 Commits (1)

  • 9a6d9a6 feat(spotlight): context-aware Spotlight (selection, source app, folder, model, prompt)

📊 Changes

10 files changed (+1460 additions, -52 deletions)

View changed files

📝 package-lock.json (+355 -2)
📝 package.json (+1 -0)
📝 src/main/index.ts (+209 -35)
📝 src/main/utils/index.ts (+12 -0)
➕ src/main/utils/selection.ts (+221 -0)
📝 src/preload/index.ts (+2 -0)
📝 src/preload/spotlight-preload.ts (+22 -2)
📝 src/renderer/src/components/Spotlight.svelte (+443 -13)
📝 src/renderer/src/lib/components/Main/Connections.svelte (+82 -0)
📝 src/renderer/src/lib/components/Main/Settings/General.svelte (+113 -0)

📄 Description

feat(spotlight): context-aware Spotlight (selection, source app, folder, model, prompt)

Description

Spotlight is great for firing a quick question from any app, but today it only takes the clipboard and always lands in a new chat with the default model, no folder and no prompt. When work is organised in folders (system prompt, knowledge, default models), in expert models and in saved prompts, you have to open the main window and set all of that up by hand.

This PR turns Spotlight into a quick launcher into the right Open WebUI context:

1. Selected text (Windows)
Pressing the shortcut captures the text selected in the foreground app, no Ctrl+C needed. The copy is simulated once the shortcut's modifier keys are released (so Alt/Shift/Win don't turn it into another shortcut) and the user's clipboard is restored (text, HTML, RTF, image). Falls back to the existing clipboard auto-paste. New setting: Capture Selected Text (on by default).

2. Source app (Windows)
The bar shows which app the text comes from, with its icon: Working with Microsoft Outlook.

3. Folder / model / prompt pickers
Three compact chips under the input, each opening a filterable, keyboard-driven list (type to filter, ↑/↓, Enter, Esc closes the list before Spotlight):

  • Folder: the user's folders, nested ones as Parent / Child.
  • Model: available models; workspace models built on a base model (their own system prompt) come first with an Expert badge.
  • Prompt: the user's Open WebUI prompts. The prompt replaces {{CLIPBOARD}} with the text, or the text is appended after it. Open WebUI then resolves its other variables ({{USER_NAME}}, dates, input fields) as usual.

4. Defaults
Settings → General → Spotlight Defaults: folder, model and prompt preselected each time Spotlight opens.

5. Send right away or open the chat
Enter or a click on the send button uses the mode chosen in Settings; Shift+Enter or Shift+click uses the other one (the button icon switches while Shift is held):

  • Send: without folder/model, the existing query flow (unchanged). With folder/model, a new chat is opened there and the pre-filled message is submitted once it's in the input. It waits while a dialog (e.g. prompt input variables) is open, never submits a stale draft, and gives up after 20 s leaving the text in place.
  • Open chat: the chat is opened pre-filled for review.

No server-side change. Everything reuses what Open WebUI already supports: /folders/:id, ?models=, ?q= (with submit=false, which 0.11.x honours and 0.12 ignores) and the page:navigate desktop event. Tested against 0.11.4 and 0.12 code paths.

Implementation

  • main/utils/selection.ts (new): foreground app (name from the exe's FileDescription, icon via app.getFileIcon) and selection capture, through Win32 via koffi (prebuilt N-API binaries, no native build step added).
  • main/index.ts: spotlight:getContext IPC (/api/models, /api/v1/folders/, /api/v1/prompts/, 5 s timeout, allSettled); spotlight:submit takes { folderId, modelId, mode }; init payload carries source app, defaults and mode; shared getAuthToken() helper (voice input now uses it too, same behaviour).
  • Main/Connections.svelte: relays a navigate message to the webview and, in send mode, submits once the text is there.
  • components/Spotlight.svelte: source-app header, chips, picker panel, mode hint (light/dark).
  • Settings/General.svelte: Capture Selected Text (Windows) and Spotlight Defaults.
  • Config: spotlightCaptureSelection, spotlightDefaultFolderId, spotlightDefaultModelId, spotlightDefaultPromptId, spotlightSubmitMode (default send, i.e. today's behaviour).

Known limitations

  • Selection capture and source app are Windows-only for now; macOS/Linux keep the current clipboard behaviour.
  • Screenshots attached in Spotlight still go to a new default chat (images can't travel through a URL).

Checks: svelte-check 0 errors, tsc (node) clean, electron-vite build OK, no new ESLint errors in touched files. Spotlight UI tested in light/dark with a mocked API; the auto-submit script tested against a mock page (submits once the text is set, waits while a dialog is open, ignores a stale draft); manual test on Windows 11 against an Open WebUI server.


Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ShBh89bRFKdYGWJGZE6WjF


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/desktop/pull/280 **Author:** [@BenAndNuts](https://github.com/BenAndNuts) **Created:** 10/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/spotlight-context` --- ### 📝 Commits (1) - [`9a6d9a6`](https://github.com/open-webui/desktop/commit/9a6d9a60f19da49ba622465c45cc2633e774ddd7) feat(spotlight): context-aware Spotlight (selection, source app, folder, model, prompt) ### 📊 Changes **10 files changed** (+1460 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `package-lock.json` (+355 -2) 📝 `package.json` (+1 -0) 📝 `src/main/index.ts` (+209 -35) 📝 `src/main/utils/index.ts` (+12 -0) ➕ `src/main/utils/selection.ts` (+221 -0) 📝 `src/preload/index.ts` (+2 -0) 📝 `src/preload/spotlight-preload.ts` (+22 -2) 📝 `src/renderer/src/components/Spotlight.svelte` (+443 -13) 📝 `src/renderer/src/lib/components/Main/Connections.svelte` (+82 -0) 📝 `src/renderer/src/lib/components/Main/Settings/General.svelte` (+113 -0) </details> ### 📄 Description # feat(spotlight): context-aware Spotlight (selection, source app, folder, model, prompt) ## Description Spotlight is great for firing a quick question from any app, but today it only takes the clipboard and always lands in a new chat with the default model, no folder and no prompt. When work is organised in folders (system prompt, knowledge, default models), in expert models and in saved prompts, you have to open the main window and set all of that up by hand. This PR turns Spotlight into a quick launcher into the right Open WebUI context: **1. Selected text (Windows)** Pressing the shortcut captures the text selected in the foreground app, no Ctrl+C needed. The copy is simulated once the shortcut's modifier keys are released (so Alt/Shift/Win don't turn it into another shortcut) and the user's clipboard is restored (text, HTML, RTF, image). Falls back to the existing clipboard auto-paste. New setting: *Capture Selected Text* (on by default). **2. Source app (Windows)** The bar shows which app the text comes from, with its icon: *Working with Microsoft Outlook*. **3. Folder / model / prompt pickers** Three compact chips under the input, each opening a filterable, keyboard-driven list (type to filter, ↑/↓, Enter, Esc closes the list before Spotlight): - **Folder**: the user's folders, nested ones as `Parent / Child`. - **Model**: available models; workspace models built on a base model (their own system prompt) come first with an *Expert* badge. - **Prompt**: the user's Open WebUI prompts. The prompt replaces `{{CLIPBOARD}}` with the text, or the text is appended after it. Open WebUI then resolves its other variables (`{{USER_NAME}}`, dates, input fields) as usual. **4. Defaults** *Settings → General → Spotlight Defaults*: folder, model and prompt preselected each time Spotlight opens. **5. Send right away or open the chat** *Enter* or a click on the send button uses the mode chosen in Settings; *Shift+Enter* or *Shift+click* uses the other one (the button icon switches while Shift is held): - **Send**: without folder/model, the existing `query` flow (unchanged). With folder/model, a new chat is opened there and the pre-filled message is submitted once it's in the input. It waits while a dialog (e.g. prompt input variables) is open, never submits a stale draft, and gives up after 20 s leaving the text in place. - **Open chat**: the chat is opened pre-filled for review. **No server-side change.** Everything reuses what Open WebUI already supports: `/folders/:id`, `?models=`, `?q=` (with `submit=false`, which 0.11.x honours and 0.12 ignores) and the `page:navigate` desktop event. Tested against 0.11.4 and 0.12 code paths. **Implementation** - `main/utils/selection.ts` (new): foreground app (name from the exe's FileDescription, icon via `app.getFileIcon`) and selection capture, through Win32 via [koffi](https://koffi.dev) (prebuilt N-API binaries, no native build step added). - `main/index.ts`: `spotlight:getContext` IPC (`/api/models`, `/api/v1/folders/`, `/api/v1/prompts/`, 5 s timeout, `allSettled`); `spotlight:submit` takes `{ folderId, modelId, mode }`; init payload carries source app, defaults and mode; shared `getAuthToken()` helper (voice input now uses it too, same behaviour). - `Main/Connections.svelte`: relays a `navigate` message to the webview and, in send mode, submits once the text is there. - `components/Spotlight.svelte`: source-app header, chips, picker panel, mode hint (light/dark). - `Settings/General.svelte`: *Capture Selected Text* (Windows) and *Spotlight Defaults*. - Config: `spotlightCaptureSelection`, `spotlightDefaultFolderId`, `spotlightDefaultModelId`, `spotlightDefaultPromptId`, `spotlightSubmitMode` (default `send`, i.e. today's behaviour). **Known limitations** - Selection capture and source app are Windows-only for now; macOS/Linux keep the current clipboard behaviour. - Screenshots attached in Spotlight still go to a new default chat (images can't travel through a URL). **Checks**: `svelte-check` 0 errors, `tsc` (node) clean, `electron-vite build` OK, no new ESLint errors in touched files. Spotlight UI tested in light/dark with a mocked API; the auto-submit script tested against a mock page (submits once the text is set, waits while a dialog is open, ignores a stale draft); manual test on Windows 11 against an Open WebUI server. <!-- Drag the screenshots here --> ## Related Issues <!-- Fixes #… if an issue exists --> --- ## Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/desktop/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ShBh89bRFKdYGWJGZE6WjF --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/desktop#241
No description provided.