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.

fix(remote): die Bruecke schickt den Grundtext, nie die Person

purple3fdccbc9272f
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index a3f10528..0d9105ef 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -17,6 +17,7 @@ import { useDocsAvailability } from '../../hooks/useDocsAvailability'
import { AgentModeToggle } from './AgentModeToggle'
import { AgentWorkspaceBadge } from './AgentWorkspaceBadge'
import { ErrorBoundary } from '../ui/ErrorBoundary'
+import { CHAT_BASE_SYSTEM_PROMPT } from '../../lib/system-prompt'
import { useSettingsStore } from '../../stores/settingsStore'
import { useDismissOnEscape } from '../../hooks/useDismissOnEscape'
import { ChevronDown, Download, Wrench, Radio, RefreshCw, X } from 'lucide-react'
@@ -201,7 +202,10 @@ export function ChatView() {
.find((c) => c.id === activeConversationId)
if (!activeConv) return
try {
- await remoteRestart(activeConv.model, activeConv.systemPrompt)
+ // Der Grundtext, nie die Person: ein Neustart darf nicht heimlich
+ // dispatchen, was der Dispatch selbst bewusst weglaesst. Siehe
+ // Sidebar.tsx, handleDispatch.
+ await remoteRestart(activeConv.model, CHAT_BASE_SYSTEM_PROMPT)
useRemoteStore.setState({ dispatchedConversationId: activeConversationId })
} catch {
// #29: restart now rethrows. The store's `error` already holds the
diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx
index 0b3c65fd..1d8f6863 100644
--- a/src/components/layout/Sidebar.tsx
+++ b/src/components/layout/Sidebar.tsx
@@ -9,6 +9,7 @@ import { useSettingsStore } from '../../stores/settingsStore'
import { useCodexStore } from '../../stores/codexStore'
import { useRemoteStore, REMOTE_DEV_MODE_ERROR } from '../../stores/remoteStore'
import { workspaceRejectedMessage } from '../../lib/workspace-rejected'
+import { CHAT_BASE_SYSTEM_PROMPT } from '../../lib/system-prompt'
import { backendCall, isTauri } from '../../api/backend'
import { useDismissOnEscape } from '../../hooks/useDismissOnEscape'
import {
@@ -252,12 +253,17 @@ export function Sidebar() {
} catch { /* no-op */ }
}
- // Remote dispatch — same default-OFF rule. The conv stores the global
+ // Remote dispatch: same default-OFF rule. The conv stores the global
// persona prompt for later opt-in via the toggle, but it is NOT sent
- // to the mobile server as the dispatched system prompt. Mobile starts
- // clean (autonomy contract or codex prompt only). Without this, a
+ // to the mobile server as the dispatched system prompt. Without this, a
// global "Devil's Advocate" persona silently hijacked every remote
// session through `dispatchedSystemPrompt` on the mobile side.
+ //
+ // Was hier bis zum 11.09.2026 rausging, war der LEERE String, und damit
+ // war das Handy die einzige Oberflaeche ohne Grundtext: es antwortete aus
+ // der Anbieterhaltung, die laut Messung vom 10.09.2026 sechs
+ // Katalogmodelle die Antwort kostet. Jetzt geht der Grundtext raus, also
+ // Rolle, Verhaltens- und Reichweitenzeile, und weiterhin NIE die Person.
const persona = personasEnabled ? getActivePersona() : null
const convId = createConversation(activeModel, persona?.systemPrompt || '', 'remote')
setView('chat')
@@ -267,7 +273,7 @@ export function Sidebar() {
// immediately (no tunnel to wait for).
useRemoteStore.setState({ awaitingTunnel: mode === 'internet' })
try {
- await dispatch(convId, activeModel, '')
+ await dispatch(convId, activeModel, CHAT_BASE_SYSTEM_PROMPT)
} catch {
// #29: server failed to start (port in use, firewall, etc.). The
// store has the user-facing reason in `error` — drop the orphan
@@ -702,7 +708,7 @@ export function Sidebar() {
// row paints, not the model/system prompt.
const conv = useChatStore.getState().conversations
.find((c) => c.id === dispatchedConversationId)
- restart(conv?.model, conv?.systemPrompt)
+ restart(conv?.model, CHAT_BASE_SYSTEM_PROMPT)
}}
disabled={remoteLoading}
title="Restart server (keeps this chat, issues a new passcode)"
diff --git a/src/stores/__tests__/remote-grundtext.test.ts b/src/stores/__tests__/remote-grundtext.test.ts
new file mode 100644
index 00000000..6e3b574b
--- /dev/null
+++ b/src/stores/__tests__/remote-grundtext.test.ts
@@ -0,0 +1,130 @@
+/**
+ * Die Remote-Bruecke schickt den Grundtext, nie die Person.
+ *
+ * Der Fund, den dieser Test festhaelt (11.09.2026): der Dispatch schickte den
+ * LEEREN String. Das Handy war damit die einzige Oberflaeche ohne Grundtext
+ * und antwortete aus der Anbieterhaltung, die laut Messung vom 10.09.2026
+ * sechs von 46 Katalogmodellen die Antwort kostet. Der Neustartknopf war noch
+ * schiefer: er reichte `conv.systemPrompt` durch, also genau die global
+ * gewaehlte Person, die der Dispatch mit Absicht weglaesst. Ein Neustart hat
+ * damit still eine andere Bruecke aufgebaut als der Dispatch.
+ *
+ * Beides zeigt jetzt auf CHAT_BASE_SYSTEM_PROMPT.
+ *
+ * Run: npx vitest run src/stores/__tests__/remote-grundtext.test.ts
+ */
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { resolve } from 'node:path'
+import { useRemoteStore } from '../remoteStore'
+import { useMemoryStore } from '../memoryStore'
+import { CHAT_BASE_SYSTEM_PROMPT, CHAT_BASE_ROLE, HOUSE_CONDUCT, HOUSE_SCOPE } from '../../lib/system-prompt'
+
+vi.mock('../../api/backend', () => ({
+ backendCall: vi.fn().mockResolvedValue({}),
+ isTauri: vi.fn(() => true),
+}))
+import { backendCall } from '../../api/backend'
+const mockBackend = backendCall as unknown as ReturnType<typeof vi.fn>
+
+const SRC = resolve(__dirname, '..', '..')
+const lies = (rel: string) => readFileSync(resolve(SRC, rel), 'utf8')
+const zaehle = (heuhaufen: string, nadel: string) => heuhaufen.split(nadel).length - 1
+
+/** Der Systemtext, den die Rust-Seite zu sehen bekommt. */
+function gesendeterSystemtext(): string {
+ const call = mockBackend.mock.calls.find(
+ (c) => c[0] === 'start_remote_server' || c[0] === 'restart_remote_server',
+ )
+ return String((call![1] as Record<string, unknown>).systemPrompt ?? '')
+}
+
+const echteMemoryLesung = useMemoryStore.getState().getMemoriesForPrompt
+
+beforeEach(() => {
+ mockBackend.mockClear()
+ mockBackend.mockResolvedValue({ port: 11435, passcode: '123456' })
+ useRemoteStore.setState({
+ enabled: false, loading: false, error: null, dispatchedConversationId: null,
+ })
+ useMemoryStore.setState({ entries: [], getMemoriesForPrompt: echteMemoryLesung })
+})
+
+afterEach(() => {
+ mockBackend.mockReset()
+})
+
+describe('Remote-Bruecke: der Grundtext geht raus', () => {
+ it('a) ohne Person geht der Grundtext samt Reichweitenzeile raus', async () => {
+ await useRemoteStore.getState().dispatch('c1', 'llama3', CHAT_BASE_SYSTEM_PROMPT)
+ const text = gesendeterSystemtext()
+ expect(text).toBe(CHAT_BASE_SYSTEM_PROMPT)
+ expect(zaehle(text, CHAT_BASE_ROLE)).toBe(1)
+ expect(zaehle(text, HOUSE_CONDUCT)).toBe(1)
+ expect(zaehle(text, HOUSE_SCOPE)).toBe(1)
+ })
+
+ it('a2) der Neustart schickt denselben Text wie der Dispatch', async () => {
+ await useRemoteStore.getState().restart('llama3', CHAT_BASE_SYSTEM_PROMPT)
+ expect(gesendeterSystemtext()).toBe(CHAT_BASE_SYSTEM_PROMPT)
+ })
+
+ it('c) mit Memory steht der Grundtext vorn und die Erinnerung dahinter', async () => {
+ useMemoryStore.setState({ getMemoriesForPrompt: () => 'MEM CONTEXT HERE' })
+ await useRemoteStore.getState().dispatch('c1', 'llama3', CHAT_BASE_SYSTEM_PROMPT)
+ const text = gesendeterSystemtext()
+ expect(text.startsWith(CHAT_BASE_SYSTEM_PROMPT)).toBe(true)
+ expect(text).toContain('MEM CONTEXT HERE')
+ expect(text.indexOf(HOUSE_SCOPE)).toBeLessThan(text.indexOf('MEM CONTEXT HERE'))
+ expect(zaehle(text, HOUSE_SCOPE)).toBe(1)
+ })
+})
+
+/**
+ * b) Die Person geht NIE raus. Das entscheiden die Aufrufer, nicht der Store,
+ * deshalb wird hier die Quelle gelesen: ein Test, der nur den Store fragt,
+ * waere gruen, waehrend die Seitenleiste weiter die Person durchreicht.
+ */
+describe('Remote-Bruecke: die Person geht nie raus', () => {
+ it('die Seitenleiste dispatcht den Grundtext, nicht den leeren String und nicht die Person', () => {
+ const quelle = lies('components/layout/Sidebar.tsx')
+ expect(quelle).toContain('dispatch(convId, activeModel, CHAT_BASE_SYSTEM_PROMPT)')
+ expect(quelle).not.toMatch(/dispatch\(convId, activeModel, ''\)/)
+ expect(quelle).not.toMatch(/dispatch\([^)]*persona/)
+ })
+
+ it('der Neustartknopf der Seitenleiste reicht nicht mehr die Person durch', () => {
+ const quelle = lies('components/layout/Sidebar.tsx')
+ expect(quelle).toContain('restart(conv?.model, CHAT_BASE_SYSTEM_PROMPT)')
+ expect(quelle).not.toMatch(/restart\(conv\?\.model, conv\?\.systemPrompt\)/)
+ })
+
+ it('der Neustart in der Chatansicht reicht nicht mehr die Person durch', () => {
+ const quelle = lies('components/chat/ChatView.tsx')
+ expect(quelle).toContain('remoteRestart(activeConv.model, CHAT_BASE_SYSTEM_PROMPT)')
+ expect(quelle).not.toMatch(/remoteRestart\(activeConv\.model, activeConv\.systemPrompt\)/)
+ })
+})
+
+/**
+ * Was die Seite auf dem Handy mit dem Text macht, ist eine handgepflegte
+ * Parallelkopie in reinem JavaScript. Sie wird hier NICHT geaendert, nur
+ * festgehalten, damit der naechste Leser die Grenze kennt: im einfachen Chat
+ * ohne Person wird der gesendete Text benutzt, unter Agent und Codex faellt er
+ * weg, weil dort ein zusaetzlicher Text mit den Werkzeugregeln konkurriert.
+ */
+describe('Remote-Bruecke: was die Handy-Seite daraus macht', () => {
+ const client = readFileSync(resolve(SRC, '..', 'mobile-client', 'client.js'), 'utf8')
+
+ it('benutzt den gesendeten Text im einfachen Chat ohne Person', () => {
+ expect(client).toContain('dispatchedSystemPrompt && !agentOn && !isCodex')
+ expect(client).toContain('parts.push(dispatchedSystemPrompt)')
+ })
+
+ it('laesst ihn unter Agent und Codex weg, das ist der bekannte Rest der Luecke', () => {
+ const bauer = client.slice(client.indexOf('function buildSystemPrompt()'))
+ const bisZumEnde = bauer.slice(0, bauer.indexOf('return parts.join'))
+ // Der Text kommt genau EINMAL vor, im Zweig mit den beiden Verneinungen.
+ expect(zaehle(bisZumEnde, 'parts.push(dispatchedSystemPrompt)')).toBe(1)
+ })
+})