Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (agy): keep number fields editable and the preset label honest

Adam Eivye5d00c8bee50
diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsx
index 39d5e7ff9b..a5e63b06fc 100644
--- a/client/src/components/settings/LocalLlmTab.jsx
+++ b/client/src/components/settings/LocalLlmTab.jsx
@@ -71,6 +71,11 @@ const SPEC_DECODE_PRESETS = [
const DEFAULT_SPEC_PRESET_ID = 'qwen3.8-27b-dspark';
const findSpecPreset = (id) => SPEC_DECODE_PRESETS.find((p) => p.id === id);
+// Defaults for the advanced numeric fields. They are applied when the server is
+// launched rather than on every keystroke: a controlled number input that coerces
+// as you type snaps back to its default the moment you clear it to retype.
+const LLAMA_NUMBER_DEFAULTS = { port: 8080, ctxSize: 32768, nGpuLayers: 99 };
+
const btnClass = 'flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded transition-colors disabled:opacity-50';
const CATEGORY_LABELS = {
@@ -744,6 +749,18 @@ export function LocalLlmTab() {
});
};
+ // Hand-editing a path the preset supplied means the form no longer describes
+ // that preset — say Custom rather than keep claiming the preset is in effect.
+ const setLlamaField = (field, value) => {
+ setLlamaPresetId('custom');
+ setLlamaForm((prev) => ({ ...prev, [field]: value }));
+ };
+
+ // Keep an emptied field empty so it can be retyped; the launch path fills in
+ // the default. `Number('')` is 0, hence the explicit empty check.
+ const setLlamaNumber = (field, raw) =>
+ setLlamaForm((prev) => ({ ...prev, [field]: raw === '' ? '' : Number(raw) }));
+
const activeSpecPreset = findSpecPreset(llamaPresetId);
// Clearing the target path is the one way back to a disabled Start — say why
// rather than leaving a dead button.
@@ -757,10 +774,14 @@ export function LocalLlmTab() {
return;
}
setLlamaLoading(true);
+ const config = { ...llamaForm };
+ for (const [field, fallback] of Object.entries(LLAMA_NUMBER_DEFAULTS)) {
+ if (!Number.isFinite(config[field])) config[field] = fallback;
+ }
try {
- const res = await startLlamaServer(llamaForm);
+ const res = await startLlamaServer(config);
if (res?.success) {
- toast.success(`llama-server started (PID ${res.pid}) on port ${llamaForm.port || 8080}`);
+ toast.success(`llama-server started (PID ${res.pid}) on port ${config.port}`);
}
loadLlamaStatus();
} catch (err) {
@@ -1037,7 +1058,7 @@ export function LocalLlmTab() {
aria-label="Target Base Model (GGUF Path)"
type="text"
value={llamaForm.model}
- onChange={(e) => setLlamaForm((prev) => ({ ...prev, model: e.target.value }))}
+ onChange={(e) => setLlamaField('model', e.target.value)}
placeholder={activeSpecPreset?.model || 'models/your-target-Q4_K_M.gguf'}
className="w-full bg-port-card border border-port-border rounded px-2.5 py-1.5 text-xs text-white placeholder-gray-600 focus:outline-none focus:border-port-accent"
/>
@@ -1049,7 +1070,7 @@ export function LocalLlmTab() {
aria-label="Draft Model (Optional)"
type="text"
value={llamaForm.draftModel}
- onChange={(e) => setLlamaForm((prev) => ({ ...prev, draftModel: e.target.value }))}
+ onChange={(e) => setLlamaField('draftModel', e.target.value)}
placeholder={activeSpecPreset?.draftModel || 'models/your-drafter.gguf'}
className="w-full bg-port-card border border-port-border rounded px-2.5 py-1.5 text-xs text-white placeholder-gray-600 focus:outline-none focus:border-port-accent"
/>
@@ -1065,7 +1086,7 @@ export function LocalLlmTab() {
aria-label="Port"
type="number"
value={llamaForm.port}
- onChange={(e) => setLlamaForm((prev) => ({ ...prev, port: parseInt(e.target.value, 10) || 8080 }))}
+ onChange={(e) => setLlamaNumber('port', e.target.value)}
className="w-full bg-port-card border border-port-border rounded px-2 py-1 text-xs text-white"
/>
</div>
@@ -1076,7 +1097,7 @@ export function LocalLlmTab() {
aria-label="Context Size"
type="number"
value={llamaForm.ctxSize}
- onChange={(e) => setLlamaForm((prev) => ({ ...prev, ctxSize: parseInt(e.target.value, 10) || 32768 }))}
+ onChange={(e) => setLlamaNumber('ctxSize', e.target.value)}
className="w-full bg-port-card border border-port-border rounded px-2 py-1 text-xs text-white"
/>
</div>
@@ -1087,12 +1108,7 @@ export function LocalLlmTab() {
aria-label="GPU Layers (-ngl)"
type="number"
value={llamaForm.nGpuLayers}
- onChange={(e) => setLlamaForm((prev) => {
- // `-ngl 0` is a real setting (CPU-only), so only a cleared
- // field — parseInt's NaN — may fall back to the default.
- const parsed = parseInt(e.target.value, 10);
- return { ...prev, nGpuLayers: Number.isNaN(parsed) ? 99 : parsed };
- })}
+ onChange={(e) => setLlamaNumber('nGpuLayers', e.target.value)}
className="w-full bg-port-card border border-port-border rounded px-2 py-1 text-xs text-white"
/>
</div>
@@ -1103,7 +1119,7 @@ export function LocalLlmTab() {
aria-label="Spec Type"
type="text"
value={llamaForm.specType}
- onChange={(e) => setLlamaForm((prev) => ({ ...prev, specType: e.target.value }))}
+ onChange={(e) => setLlamaField('specType', e.target.value)}
className="w-full bg-port-card border border-port-border rounded px-2 py-1 text-xs text-white"
/>
</div>
diff --git a/client/src/components/settings/LocalLlmTab.test.jsx b/client/src/components/settings/LocalLlmTab.test.jsx
index 44df1d2f14..b68d8f153c 100644
--- a/client/src/components/settings/LocalLlmTab.test.jsx
+++ b/client/src/components/settings/LocalLlmTab.test.jsx
@@ -354,6 +354,60 @@ describe('LocalLlmTab llama-server management', () => {
});
});
+ // Coercing a number input on every keystroke snaps it back to its default the
+ // moment you clear it to retype, so the default is applied at launch instead.
+ it('lets an advanced number field sit empty while retyping and defaults it at launch', async () => {
+ const { getLlamaServerStatus, startLlamaServer } = await import('../../services/api');
+ getLlamaServerStatus.mockResolvedValueOnce({ installed: true, running: false, managed: false });
+ startLlamaServer.mockResolvedValueOnce({ success: true, pid: 21 });
+
+ await renderTab();
+
+ fireEvent.click(await screen.findByRole('button', { name: /Advanced options/ }));
+ const gpuLayers = screen.getByLabelText(/GPU Layers/);
+ fireEvent.change(gpuLayers, { target: { value: '' } });
+ expect(gpuLayers).toHaveValue(null);
+
+ fireEvent.click(screen.getByRole('button', { name: /Start Speculative Server/ }));
+
+ await waitFor(() => {
+ expect(startLlamaServer).toHaveBeenCalledWith(expect.objectContaining({ nGpuLayers: 99 }));
+ });
+ });
+
+ it('keeps an explicit -ngl 0 rather than treating it as unset', async () => {
+ const { getLlamaServerStatus, startLlamaServer } = await import('../../services/api');
+ getLlamaServerStatus.mockResolvedValueOnce({ installed: true, running: false, managed: false });
+ startLlamaServer.mockResolvedValueOnce({ success: true, pid: 22 });
+
+ await renderTab();
+
+ fireEvent.click(await screen.findByRole('button', { name: /Advanced options/ }));
+ fireEvent.change(screen.getByLabelText(/GPU Layers/), { target: { value: '0' } });
+
+ fireEvent.click(screen.getByRole('button', { name: /Start Speculative Server/ }));
+
+ await waitFor(() => {
+ expect(startLlamaServer).toHaveBeenCalledWith(expect.objectContaining({ nGpuLayers: 0 }));
+ });
+ });
+
+ it('drops the preset label to Custom once a preset-supplied path is hand-edited', async () => {
+ const { getLlamaServerStatus } = await import('../../services/api');
+ getLlamaServerStatus.mockResolvedValueOnce({ installed: true, running: false, managed: false });
+
+ await renderTab();
+
+ const presetSelect = await screen.findByLabelText('Preset');
+ expect(presetSelect).toHaveValue('qwen3.8-27b-dspark');
+
+ fireEvent.change(screen.getByLabelText(/Target Base Model \(GGUF Path\)/), {
+ target: { value: 'models/hand-picked.gguf' },
+ });
+
+ expect(presetSelect).toHaveValue('custom');
+ });
+
it('renders install button and triggers install when llama-server is not installed', async () => {
const { getLlamaServerStatus, installLlamaServer } = await import('../../services/api');
getLlamaServerStatus.mockResolvedValueOnce({