Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(ui): no web view menu on a right click, a plain one where there is text (W33)

purplef3b38ee07c6d
diff --git a/src/App.tsx b/src/App.tsx
index d3de2d71..2568aa72 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,4 +1,5 @@
import { useEffect } from 'react'
+import { TextContextMenu } from './components/ui/TextContextMenu'
import { MotionConfig } from 'framer-motion'
import { AppShell } from './components/layout/AppShell'
import { useVoiceStore } from './stores/voiceStore'
@@ -91,6 +92,8 @@ function App() {
return (
<MotionConfig reducedMotion="user">
<AppShell />
+ {/* W33: no web view menu on a right click in a release build. */}
+ <TextContextMenu />
</MotionConfig>
)
}
diff --git a/src/components/__tests__/kontextmenue-nachricht-und-modellkarte.test.ts b/src/components/__tests__/kontextmenue-nachricht-und-modellkarte.test.ts
index 23cd806a..04b70954 100644
--- a/src/components/__tests__/kontextmenue-nachricht-und-modellkarte.test.ts
+++ b/src/components/__tests__/kontextmenue-nachricht-und-modellkarte.test.ts
@@ -170,8 +170,9 @@ describe('ein Menü, ein Aufrufweg — Gegenprobe an der Quelle', () => {
it('ModelCard: Knöpfe und Menü lesen aus DEMSELBEN actions-Objekt', () => {
const src = read('components', 'models', 'ModelCard.tsx')
- // A14 brought a fourth action, Remove refusals, through the same object.
- expect(src).toContain('const actions: ModelMenuHandlers = { select: onSelect, info: onInfo, remove: onDelete, removeRefusals: onRemoveRefusals }')
+ // A14 brought a fourth action, Remove refusals, and W33 a fifth, Show in
+ // folder (ComfyUI files), through the same object.
+ expect(src).toContain('const actions: ModelMenuHandlers = { select: onSelect, info: onInfo, remove: onDelete, removeRefusals: onRemoveRefusals, reveal: onReveal }')
expect(src).toContain('actions.removeRefusals?.()')
expect(src).toContain('buildModelCardMenu(actions,')
expect(src).toContain('actions.info()')
diff --git a/src/components/models/LoraManager.tsx b/src/components/models/LoraManager.tsx
index c1efa993..508d78a0 100644
--- a/src/components/models/LoraManager.tsx
+++ b/src/components/models/LoraManager.tsx
@@ -15,6 +15,9 @@ import { parseLocalCharacterLora } from '../../api/trainer'
import { formatBytes } from '../../lib/formatters'
import { ModelEmptyState, SectionHead } from './ModelPageParts'
import { ICON_SM } from '../ui/icon-size'
+import { useState, type MouseEvent as ReactMouseEvent } from 'react'
+import { ContextMenu } from '../ui/ContextMenu'
+import { buildLoraRowMenu } from '../ui/menu-actions'
export interface LoraRow {
name: string
@@ -82,6 +85,28 @@ export function LoraRowDetails({ row }: { row: LoraRow }) {
)
}
+/** W33: the right click on a LoRA row. Returns the row's onContextMenu and
+ * the menu itself (render it once, next to the rows). */
+export function useLoraRowMenu(h: { onDelete: (name: string) => void; onInfo?: (name: string) => void; onEdit?: (name: string) => void; onReveal?: (name: string) => void }) {
+ const [menu, setMenu] = useState<{ name: string; x: number; y: number } | null>(null)
+ const open = (name: string) => (e: ReactMouseEvent) => { e.preventDefault(); setMenu({ name, x: e.clientX, y: e.clientY }) }
+ const element = menu ? (
+ <ContextMenu
+ items={buildLoraRowMenu({
+ reveal: h.onReveal ? () => h.onReveal!(menu.name) : undefined,
+ rename: h.onEdit ? () => h.onEdit!(menu.name) : undefined,
+ info: h.onInfo ? () => h.onInfo!(menu.name) : undefined,
+ remove: () => h.onDelete(menu.name),
+ })}
+ x={menu.x}
+ y={menu.y}
+ label={`Actions for ${menu.name}`}
+ onClose={() => setMenu(null)}
+ />
+ ) : null
+ return { open, element }
+}
+
/** C41: the buttons a LoRA row has beside Details and Delete. */
export function LoraRowActions({ row, onEdit, onToggleHidden, onReveal, buttonClass, iconSize }: {
row: LoraRow
@@ -135,6 +160,7 @@ export function ShowHiddenLoras({ count, show, onShow, className }: { count?: nu
export const LORA_USE_HINT = 'Use them in Create, Advanced settings, Expert, LoRA stack.'
export function LoraManager({ rows, total, searchQuery, onDelete, onInfo, onGetNew, onEdit, onToggleHidden, onReveal, hiddenCount, showHidden, onShowHidden }: LoraManagerProps) {
+ const rowMenu = useLoraRowMenu({ onDelete, onInfo, onEdit, onReveal })
if (total === 0) {
return (
<ModelEmptyState
@@ -165,6 +191,7 @@ export function LoraManager({ rows, total, searchQuery, onDelete, onInfo, onGetN
<div
key={row.name}
data-testid="lora-row"
+ onContextMenu={rowMenu.open(row.name)}
className="lu-tile flex items-center gap-3 px-3.5 py-2.5"
>
<div className="min-w-0 flex-1">
@@ -221,6 +248,7 @@ export function LoraManager({ rows, total, searchQuery, onDelete, onInfo, onGetN
<p className="text-center text-xs text-gray-500 dark:text-gray-400 py-6">No installed LoRAs match "{searchQuery}"</p>
)}
</div>
+ {rowMenu.element}
</section>
)
}
diff --git a/src/components/models/MacLoraLane.tsx b/src/components/models/MacLoraLane.tsx
index 65dd1a87..e317b8ef 100644
--- a/src/components/models/MacLoraLane.tsx
+++ b/src/components/models/MacLoraLane.tsx
@@ -22,7 +22,7 @@ import { deleteMlxLora, mlxLoraAlphaNote, mlxLoraKeysNote, openMlxLoraFolder, ML
import type { MlxLoraFolder } from '../../hooks/useMlxLoras'
import { useLoraNotesStore } from '../../stores/loraNotesStore'
import { usePageMemoryStore } from '../../stores/pageMemoryStore'
-import { LoraRowActions, LoraRowDetails, LoraRowName, ShowHiddenLoras } from './LoraManager'
+import { LoraRowActions, LoraRowDetails, LoraRowName, ShowHiddenLoras, useLoraRowMenu } from './LoraManager'
/** Where a LoRA is used. The names are the labels Create shows: the drawer
* "Advanced settings", the group "Expert", the list "LoRA stack". */
@@ -53,6 +53,9 @@ export function MacLoraLane({ folder, tab, search, searchSubmitToken, onGetNew,
openMlxLoraFolder().catch((e) => setError(e instanceof Error ? e.message : String(e)))
}
+ // W33: right click on a row. Delete opens the same confirmation as the button.
+ const rowMenu = useLoraRowMenu({ onDelete: (name) => setRemoving(name), onEdit, onReveal: () => openFolder() })
+
const remove = async (name: string) => {
setRemoving(null)
try {
@@ -153,7 +156,7 @@ export function MacLoraLane({ folder, tab, search, searchSubmitToken, onGetNew,
const note = mlxLoraKeysNote(row.keys)
const alphaNote = mlxLoraAlphaNote(row.alpha)
return (
- <div key={row.name} data-testid="lora-row" className="lu-tile flex items-center gap-3 px-3.5 py-2.5">
+ <div key={row.name} data-testid="lora-row" onContextMenu={rowMenu.open(row.name)} className="lu-tile flex items-center gap-3 px-3.5 py-2.5">
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<LoraRowName row={row} nameClass="text-xs font-medium text-gray-900 dark:text-gray-100" />
@@ -189,6 +192,7 @@ export function MacLoraLane({ folder, tab, search, searchSubmitToken, onGetNew,
<p className="text-center text-xs text-gray-500 dark:text-gray-400 py-6">No installed LoRAs match "{search}"</p>
)}
</div>
+ {rowMenu.element}
</section>
)}
diff --git a/src/components/models/ModelCard.tsx b/src/components/models/ModelCard.tsx
index 7b8c8361..26cda4e2 100644
--- a/src/components/models/ModelCard.tsx
+++ b/src/components/models/ModelCard.tsx
@@ -55,6 +55,8 @@ interface Props {
/** A14: open the refusal-removal tool for this file. Passed only for LU
* Engine rows whose original weights the file names. */
onRemoveRefusals?: () => void
+ /** W33: show a ComfyUI file in its folder (right click). */
+ onReveal?: () => void
}
// The glyph of each kind of model. Its tone, like every other class of this
@@ -76,7 +78,7 @@ export function createTabForArchitecture(architecture: string | undefined): stri
return null
}
-export function ModelCard({ model, isActive, onSelect, onDelete, onInfo, infoTitle, canDelete = true, onUse, useBusy = false, engineStopped: luEngineRuht = false, onRemoveRefusals }: Props) {
+export function ModelCard({ model, isActive, onSelect, onDelete, onInfo, infoTitle, canDelete = true, onUse, useBusy = false, engineStopped: luEngineRuht = false, onRemoveRefusals, onReveal }: Props) {
const typeInfo = TYPE_CONFIG[model.type] || TYPE_CONFIG.text
const TypeIcon = typeInfo.icon
const look = modelSkin().card
@@ -86,7 +88,7 @@ export function ModelCard({ model, isActive, onSelect, onDelete, onInfo, infoTit
// EIN Satz Aktionen fuer die Karte. Die sichtbaren Knoepfe unten lesen aus
// diesem Objekt, das Kontextmenue bekommt dasselbe Objekt gereicht — es gibt
// also keinen zweiten Aufrufweg, der irgendwann anders werden koennte.
- const actions: ModelMenuHandlers = { select: onSelect, info: onInfo, remove: onDelete, removeRefusals: onRemoveRefusals }
+ const actions: ModelMenuHandlers = { select: onSelect, info: onInfo, remove: onDelete, removeRefusals: onRemoveRefusals, reveal: onReveal }
const refusalsRemoved = 'refusalsRemoved' in model && model.refusalsRemoved === true
// Fremde Kennungen tragen Pfadteile und Dateiendungen mit sich, die kein
// Kunde gewaehlt hat. Der Name selbst bleibt unangetastet (lib/model-label).
diff --git a/src/components/models/ModelManager.tsx b/src/components/models/ModelManager.tsx
index 3cba85a3..ebdee88c 100644
--- a/src/components/models/ModelManager.tsx
+++ b/src/components/models/ModelManager.tsx
@@ -665,6 +665,12 @@ export function ModelManager() {
engineStopped={engineRuht}
onDelete={() => setUninstall(uninstallRequestFor(model))}
onInfo={() => handleInfo(model.name)}
+ // W33: a ComfyUI file can be shown in its folder.
+ onReveal={
+ model.type === 'image' || model.type === 'video'
+ ? () => { revealComfyModel(model.name).catch((e) => setLoraNotice(e instanceof Error ? e.message : String(e))) }
+ : undefined
+ }
// A14: where the file names its original weights
// and is not itself a copy the tool made.
onRemoveRefusals={
diff --git a/src/components/models/skin/ClassicLoraManager.tsx b/src/components/models/skin/ClassicLoraManager.tsx
index 0b80b9fa..6a751b87 100644
--- a/src/components/models/skin/ClassicLoraManager.tsx
+++ b/src/components/models/skin/ClassicLoraManager.tsx
@@ -6,9 +6,11 @@
import { Info, Layers, Trash2 } from 'lucide-react'
import { parseLocalCharacterLora } from '../../../api/trainer'
import { formatBytes } from '../../../lib/formatters'
-import { LORA_USE_HINT, LoraRowActions, LoraRowDetails, LoraRowName, ShowHiddenLoras, type LoraManagerProps } from '../LoraManager'
+import { LORA_USE_HINT, LoraRowActions, useLoraRowMenu, LoraRowDetails, LoraRowName, ShowHiddenLoras, type LoraManagerProps } from '../LoraManager'
export function ClassicLoraManager({ rows, total, searchQuery, onDelete, onInfo, onGetNew, onEdit, onToggleHidden, onReveal, hiddenCount, showHidden, onShowHidden }: LoraManagerProps) {
+ // W33: the same right-click menu as the other skin.
+ const rowMenu = useLoraRowMenu({ onDelete, onInfo, onEdit, onReveal })
if (total === 0) {
return (
<div className="flex flex-col items-center justify-center text-center py-16 px-6 gap-3">
@@ -48,6 +50,7 @@ export function ClassicLoraManager({ rows, total, searchQuery, onDelete, onInfo,
<div
key={row.name}
data-testid="lora-row"
+ onContextMenu={rowMenu.open(row.name)}
className="lu-tile rounded-lg! flex items-center gap-3 px-3 py-2"
>
<div className="min-w-0 flex-1">
@@ -101,6 +104,7 @@ export function ClassicLoraManager({ rows, total, searchQuery, onDelete, onInfo,
<p className="text-center t-micro text-gray-500 dark:text-gray-400 py-6">No installed LoRAs match "{searchQuery}"</p>
)}
</div>
+ {rowMenu.element}
</section>
)
}
diff --git a/src/components/ui/TextContextMenu.tsx b/src/components/ui/TextContextMenu.tsx
new file mode 100644
index 00000000..0a3b38bb
--- /dev/null
+++ b/src/components/ui/TextContextMenu.tsx
@@ -0,0 +1,90 @@
+// W33: the right click of the whole window (see lib/text-context-menu.ts).
+// Mounted once in App. Listens on the document after React's own handlers,
+// so a menu of LU's own (chat message, model, gallery tile) that already
+// called preventDefault is left alone.
+import { useEffect, useState } from 'react'
+import { ContextMenu } from './ContextMenu'
+import type { MenuAction } from './menu-actions'
+import { log } from '../../lib/logger'
+import { isTauri } from '../../api/backend'
+import {
+ TEXT_ACTION_LABEL, editableOf, keepsNativeMenu, readTarget, textMenuActions, type TextAction,
+} from '../../lib/text-context-menu'
+
+interface Open {
+ x: number
+ y: number
+ actions: TextAction[]
+ field: HTMLInputElement | HTMLTextAreaElement | HTMLElement | null
+ range: [number, number] | null
+ selected: string
+}
+
+/** Put the field back as it was at the right click: focus and selection. */
+function restore(o: Open) {
+ const f = o.field
+ if (!f) return
+ f.focus()
+ if (o.range && (f instanceof HTMLInputElement || f instanceof HTMLTextAreaElement)) f.setSelectionRange(o.range[0], o.range[1])
+}
+
+async function run(o: Open, action: TextAction) {
+ try {
+ if (action === 'copy') {
+ await navigator.clipboard.writeText(o.selected)
+ restore(o)
+ return
+ }
+ if (action === 'cut') {
+ await navigator.clipboard.writeText(o.selected)
+ restore(o)
+ // Through the editing command, so the field's undo and React's
+ // onChange see it like typing.
+ document.execCommand('insertText', false, '')
+ return
+ }
+ if (action === 'paste') {
+ const text = await navigator.clipboard.readText()
+ restore(o)
+ document.execCommand('insertText', false, text)
+ return
+ }
+ restore(o)
+ const f = o.field
+ if (f instanceof HTMLInputElement || f instanceof HTMLTextAreaElement) f.select()
+ else document.execCommand('selectAll')
+ } catch (err) {
+ log.warn('text_menu.action_failed', { action, err: String(err) })
+ }
+}
+
+export function TextContextMenu() {
+ const [open, setOpen] = useState<Open | null>(null)
+
+ useEffect(() => {
+ // The app only: in a browser the browser's own menu belongs to the user.
+ if (keepsNativeMenu(import.meta.env.DEV) || !isTauri()) return
+ const onMenu = (e: MouseEvent) => {
+ // A menu of LU's own took this click.
+ if (e.defaultPrevented) return
+ e.preventDefault()
+ const el = e.target instanceof Element ? e.target : null
+ const selected = window.getSelection()?.toString() ?? ''
+ const field = editableOf(el)
+ let range: [number, number] | null = null
+ let fieldSelected = selected
+ if (field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement) {
+ range = [field.selectionStart ?? 0, field.selectionEnd ?? 0]
+ fieldSelected = field.value.slice(range[0], range[1])
+ }
+ const actions = textMenuActions(readTarget(el, fieldSelected))
+ setOpen(actions.length > 0 ? { x: e.clientX, y: e.clientY, actions, field, range, selected: fieldSelected } : null)
+ }
+ document.addEventListener('contextmenu', onMenu)
+ return () => document.removeEventListener('contextmenu', onMenu)
+ }, [])
+
+ if (!open) return null
+ const items: MenuAction[] = open.actions.map((a) => ({ id: a, label: TEXT_ACTION_LABEL[a], run: () => { void run(open, a) } }))
+ return <ContextMenu items={items} x={open.x} y={open.y} label="Text" onClose={() => setOpen(null)} />
+}
diff --git a/src/components/ui/__tests__/right-click-w33.test.tsx b/src/components/ui/__tests__/right-click-w33.test.tsx
new file mode 100644
index 00000000..b9ea0bf2
--- /dev/null
+++ b/src/components/ui/__tests__/right-click-w33.test.tsx
@@ -0,0 +1,116 @@
+// @vitest-environment jsdom
+/**
+ * W33 (Discord, 15.11.2026): a right click in LU opened the web view's own
+ * menu (Print, Reload, Save page as ...). In a release build of the app it is
+ * off. A text field gets Cut, Copy, Paste and Select all, selected text Copy,
+ * everything else nothing. A dev build and the browser keep their own menu.
+ * The Models tab: a LoRA row and an image or video model get a menu of the
+ * actions they already have as buttons.
+ *
+ * Run: npx vitest run src/components/ui/__tests__/right-click-w33.test.tsx
+ */
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
+import { cleanup, render, screen, fireEvent, act } from '@testing-library/react'
+
+const env = vi.hoisted(() => ({ tauri: true }))
+vi.mock('../../../api/backend', async (o) => ({ ...(await o<typeof import('../../../api/backend')>()), isTauri: () => env.tauri }))
+
+import { TextContextMenu } from '../TextContextMenu'
+import { textMenuActions, readTarget, keepsNativeMenu } from '../../../lib/text-context-menu'
+import { buildLoraRowMenu, buildModelCardMenu } from '../menu-actions'
+
+function rightClick(el: Element) {
+ const e = new MouseEvent('contextmenu', { bubbles: true, cancelable: true, clientX: 20, clientY: 20 })
+ act(() => { el.dispatchEvent(e) })
+ return e
+}
+const labels = () => screen.queryAllByRole('menuitem').map((b) => b.textContent)
+
+beforeEach(() => { env.tauri = true; vi.stubEnv('DEV', false) })
+afterEach(() => { cleanup(); vi.unstubAllEnvs(); document.body.innerHTML = '' })
+
+describe('which actions, where', () => {
+ it('a field with a selection: all four; empty field: Paste only; read only: Copy and Select all', () => {
+ expect(textMenuActions({ editable: true, readOnly: false, hasSelection: true, hasText: true })).toEqual(['cut', 'copy', 'paste', 'selectAll'])
+ expect(textMenuActions({ editable: true, readOnly: false, hasSelection: false, hasText: false })).toEqual(['paste'])
+ expect(textMenuActions({ editable: true, readOnly: true, hasSelection: true, hasText: true })).toEqual(['copy', 'selectAll'])
+ })
+ it('selected text on the page: Copy; nothing selected: no menu', () => {
+ expect(textMenuActions({ editable: false, readOnly: true, hasSelection: true, hasText: false })).toEqual(['copy'])
+ expect(textMenuActions({ editable: false, readOnly: true, hasSelection: false, hasText: false })).toEqual([])
+ })
+ it('a password field is no text field here', () => {
+ const pw = document.createElement('input')
+ pw.type = 'password'
+ pw.value = 'secret'
+ expect(readTarget(pw, '').editable).toBe(false)
+ })
+ it('a dev build keeps the web view menu (Inspect), a release build does not', () => {
+ expect(keepsNativeMenu(true)).toBe(true)
+ expect(keepsNativeMenu(false)).toBe(false)
+ })
+})
+
+describe('the right click in the app', () => {
+ it('in the prompt: the web view menu is off and LU shows Cut, Copy, Paste, Select all', () => {
+ render(<><textarea data-testid="prompt" defaultValue="a lighthouse at dusk" /><TextContextMenu /></>)
+ const ta = screen.getByTestId('prompt') as HTMLTextAreaElement
+ ta.focus()
+ ta.setSelectionRange(2, 12)
+ const e = rightClick(ta)
+ expect(e.defaultPrevented).toBe(true)
+ expect(labels()).toEqual(['Cut', 'Copy', 'Paste', 'Select all'])
+ })
+
+ it('Copy puts the selected words on the clipboard', async () => {
+ const writeText = vi.fn(async () => {})
+ Object.assign(navigator, { clipboard: { writeText, readText: vi.fn(async () => '') } })
+ render(<><textarea data-testid="prompt" defaultValue="a lighthouse at dusk" /><TextContextMenu /></>)
+ const ta = screen.getByTestId('prompt') as HTMLTextAreaElement
+ ta.focus()
+ ta.setSelectionRange(2, 12)
+ rightClick(ta)
+ await act(async () => { fireEvent.click(screen.getByRole('menuitem', { name: 'Copy' })) })
+ expect(writeText).toHaveBeenCalledWith('lighthouse')
+ })
+
+ it('on a plain spot: no menu at all, and not the web view one either', () => {
+ render(<><div data-testid="plain">Models</div><TextContextMenu /></>)
+ const e = rightClick(screen.getByTestId('plain'))
+ expect(e.defaultPrevented).toBe(true)
+ expect(screen.queryByRole('menu')).toBeNull()
+ })
+
+ it('a menu of LU\'s own (it already took the click) is left alone', () => {
+ render(<><div data-testid="row" onContextMenu={(e) => e.preventDefault()}>row</div><TextContextMenu /></>)
+ rightClick(screen.getByTestId('row'))
+ expect(screen.queryByRole('menu')).toBeNull()
+ })
+
+ it('NEGATIVE CONTROL: a dev build and the browser keep their own menu', () => {
+ vi.stubEnv('DEV', true)
+ const dev = render(<><textarea data-testid="prompt" defaultValue="x" /><TextContextMenu /></>)
+ expect(rightClick(screen.getByTestId('prompt')).defaultPrevented).toBe(false)
+ dev.unmount()
+ vi.stubEnv('DEV', false)
+ env.tauri = false
+ render(<><textarea data-testid="prompt2" defaultValue="x" /><TextContextMenu /></>)
+ expect(rightClick(screen.getByTestId('prompt2')).defaultPrevented).toBe(false)
+ })
+})
+
+describe('the Models tab', () => {
+ it('a LoRA row: Show in folder, Rename, Details, Delete (with its confirmation)', () => {
+ const remove = vi.fn()
+ const items = buildLoraRowMenu({ reveal: vi.fn(), rename: vi.fn(), info: vi.fn(), remove })
+ expect(items.map((i) => i.label)).toEqual(['Show in folder', 'Rename…', 'Details', 'Delete…'])
+ expect(items.at(-1)?.destructive).toBe(true)
+ items.at(-1)!.run()
+ expect(remove).toHaveBeenCalledOnce()
+ })
+ it('an image or video model gets Show in folder; a chat model does not', () => {
+ const base = { select: vi.fn(), info: vi.fn(), remove: vi.fn() }
+ expect(buildModelCardMenu({ ...base, reveal: vi.fn() }, { isActive: false, canDelete: true }).map((i) => i.label)).toEqual(['Use this model', 'Details', 'Show in folder', 'Delete model'])
+ expect(buildModelCardMenu(base, { isActive: false, canDelete: true }).map((i) => i.label)).not.toContain('Show in folder')
+ })
+})
diff --git a/src/components/ui/menu-actions.ts b/src/components/ui/menu-actions.ts
index dc6eea49..01f7bcf9 100644
--- a/src/components/ui/menu-actions.ts
+++ b/src/components/ui/menu-actions.ts
@@ -95,6 +95,8 @@ export interface ModelMenuHandlers {
readonly remove: () => void
/** A14: only on LU Engine rows whose original weights are known. */
readonly removeRefusals?: () => void
+ /** W33: a ComfyUI file (image or video model) shown in its folder. */
+ readonly reveal?: () => void
}
export interface ModelMenuState {
@@ -108,11 +110,34 @@ export function buildModelCardMenu(h: ModelMenuHandlers, s: ModelMenuState): Men
// nichts tut — die Karte zeigt an derselben Stelle ihr ACTIVE-Etikett.
if (!s.isActive) out.push({ id: 'select', label: 'Use this model', run: h.select })
out.push({ id: 'info', label: 'Details', run: h.info })
+ if (h.reveal) out.push({ id: 'reveal', label: 'Show in folder', run: h.reveal })
if (h.removeRefusals) out.push({ id: 'remove-refusals', label: 'Remove refusals…', run: h.removeRefusals })
if (s.canDelete) out.push({ id: 'delete', label: 'Delete model', run: h.remove, destructive: true })
return out
}
+/* ── LoRA ────────────────────────────────────────────────────────────────── */
+
+/** W33: the right click on a LoRA row in the Models tab. Only actions the
+ * row already has as buttons: its folder, the rename-and-note dialog (C41;
+ * it renames the name LU shows, the file stays), Details, and Delete, which
+ * opens the same confirmation as the row's Delete button. */
+export interface LoraMenuHandlers {
+ readonly reveal?: () => void
+ readonly rename?: () => void
+ readonly info?: () => void
+ readonly remove: () => void
+}
+
+export function buildLoraRowMenu(h: LoraMenuHandlers): MenuAction[] {
+ const out: MenuAction[] = []
+ if (h.reveal) out.push({ id: 'reveal', label: 'Show in folder', run: h.reveal })
+ if (h.rename) out.push({ id: 'rename', label: 'Rename…', run: h.rename })
+ if (h.info) out.push({ id: 'info', label: 'Details', run: h.info })
+ out.push({ id: 'delete', label: 'Delete…', run: h.remove, destructive: true })
+ return out
+}
+
/* ── Platzierung ─────────────────────────────────────────────────────────── */
export interface MenuBox {
diff --git a/src/lib/text-context-menu.ts b/src/lib/text-context-menu.ts
new file mode 100644
index 00000000..331a8cd7
--- /dev/null
+++ b/src/lib/text-context-menu.ts
@@ -0,0 +1,69 @@
+// W33 (Discord, 15.11.2026): a right click anywhere in LU opened the web
+// view's own menu (Print, Reload, Save page as ...). In a release build that
+// menu is off. Where there is text to work with, LU shows a plain menu of its
+// own, the same on Mac, Windows and Linux: in a text field Cut, Copy, Paste
+// and Select all; on selected text elsewhere Copy. A dev build keeps the web
+// view's menu for Inspect. A part of LU with a menu of its own (a chat
+// message, a model, a gallery tile) handles the click first and is left alone.
+
+export type TextAction = 'cut' | 'copy' | 'paste' | 'selectAll'
+
+/** What the right click landed on, read off the DOM (see `readTarget`). */
+export interface TextTarget {
+ /** An input that takes text, a textarea or a contenteditable element. */
+ editable: boolean
+ /** It takes no typing (readonly or disabled). */
+ readOnly: boolean
+ /** Text is selected in it, or on the page. */
+ hasSelection: boolean
+ /** It holds any text at all. */
+ hasText: boolean
+}
+
+const TEXT_INPUT_TYPES = new Set(['text', 'search', 'url', 'tel', 'email', 'number', ''])
+
+/** The actions of the menu, in this order; empty means no menu at all. */
+export function textMenuActions(t: TextTarget): TextAction[] {
+ if (t.editable) {
+ const out: TextAction[] = []
+ if (!t.readOnly && t.hasSelection) out.push('cut')
+ if (t.hasSelection) out.push('copy')
+ if (!t.readOnly) out.push('paste')
+ if (t.hasText) out.push('selectAll')
+ return out
+ }
+ return t.hasSelection ? ['copy'] : []
+}
+
+export const TEXT_ACTION_LABEL: Record<TextAction, string> = {
+ cut: 'Cut',
+ copy: 'Copy',
+ paste: 'Paste',
+ selectAll: 'Select all',
+}
+
+/** The field a right click is in, if it takes text. A password field is left
+ * out: its text is not copied out of it. */
+export function editableOf(el: Element | null): HTMLInputElement | HTMLTextAreaElement | HTMLElement | null {
+ if (!el) return null
+ if (el instanceof HTMLTextAreaElement) return el
+ if (el instanceof HTMLInputElement) return TEXT_INPUT_TYPES.has(el.type) ? el : null
+ const host = el.closest('[contenteditable=""],[contenteditable="true"],[contenteditable="plaintext-only"]')
+ return host instanceof HTMLElement ? host : null
+}
+
+export function readTarget(el: Element | null, selection: string): TextTarget {
+ const field = editableOf(el)
+ if (!field) return { editable: false, readOnly: true, hasSelection: selection.length > 0, hasText: false }
+ if (field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement) {
+ const start = field.selectionStart ?? 0
+ const end = field.selectionEnd ?? 0
+ return { editable: true, readOnly: field.readOnly || field.disabled, hasSelection: end > start, hasText: field.value.length > 0 }
+ }
+ return { editable: true, readOnly: false, hasSelection: selection.length > 0, hasText: (field.textContent ?? '').length > 0 }
+}
+
+/** Does this build keep the web view's own menu? Only a dev build (Inspect). */
+export function keepsNativeMenu(dev: boolean): boolean {
+ return dev
+}