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

fix: put the Prompt Manager job skill selection in the URL (#3936)

[._.]/ Adam Eivyb9f261d9d899
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5d0119be08..a94a989c70 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -73,3 +73,4 @@
- Media-library sweeps from two or more full-sync peers no longer race on the same asset file. The in-flight pull guard is keyed by `(peer, kind, filename)` on purpose — a re-render pushed by one peer should still be able to overwrite an older copy another peer served — but that also meant two peers advertising the same filename, which is exactly what a mirrored library looks like, both passed the guard and downloaded and wrote `data/{images,videos,audio,music}/<name>` at the same time. Pulls now serialize on a queue keyed by the destination alone, so the later peer waits its turn rather than writing alongside the first, and the local file is re-checked against the advertised hash once the turn arrives: for every asset kind, not just images, matching bytes mean a hash instead of a second download. The all-peers sweep also picked up a global re-entrancy guard, since a sweep that outran the 60-second tick let the next tick start peer B while peer A was still mid-pull, and the derived `media_assets` reconcile now runs on a single tail with concurrent requests collapsed into one pass instead of stacking overlapping full-table rebuilds.
- "Refresh quota" on the Quota Burn page no longer blanks the page or hides a failed re-scrape. The handler flipped the same `loading` flag as the first read, so every family card, control, and status number was replaced by a full-page "Loading burn plan…" spinner for the length of a 10–20s PTY quota scrape — and because the read's error was swallowed, a scrape that timed out simply put the stale numbers back with nothing saying they were stale. The refresh now reports itself on the button that asked for it (spinning icon, "Refreshing…", disabled) while the plan stays on screen, and a failure raises a toast naming the cause. The unavailable-state Retry button shares the same path; it stays banner-only there, since the banner already names the error.
- A failed job-catalog read on the Quota Burn page no longer empties the config form silently. The fetch was `.catch(() => {})`, so a 500 or a network blip left the catalog at its empty default: the "Add a preset job" picker returned null and vanished, "Add job" sat disabled, and every job row's Job Type / Apps / Universes / Image Modes dropdown rendered blank — with nothing on screen naming a cause, and editing a step in that state saving `jobType: ""` into a 400 that stalls the whole save. The catalog read now keeps its failure in its own state (with a 200 carrying zero job types reported as its own distinct cause rather than as a successful load), and an expanded family card renders an inline warning banner naming it with a "Retry catalog load" button that re-reads the catalog in place — no browser reload, and the plan itself stays on screen throughout.
+- Opening a job skill in the Prompt Manager now shows up in the URL. The Stages and Variables tabs already encode their selection as `?stage=` / `?var=`, but the Job Skills tab kept the open skill in local state, so the editor could not be linked or bookmarked and a reload — or a round-trip through another tab — dropped the user back on the "Select a job skill" placeholder. Selection now lives in `?skill=`, and a `selectedJobSkill`-keyed effect fetches the template and metadata, so `?tab=job-skills&skill=<name>` opens that skill's editor directly and a cleared param resets the panel.
diff --git a/client/src/pages/PromptManager.jsx b/client/src/pages/PromptManager.jsx
index 97b7fa5cc4..9c21e411c6 100644
--- a/client/src/pages/PromptManager.jsx
+++ b/client/src/pages/PromptManager.jsx
@@ -51,8 +51,10 @@ export default function PromptManager() {
};
const selectedStage = searchParams.get('stage');
const selectedVar = searchParams.get('var');
+ const selectedJobSkill = searchParams.get('skill');
const setSelectedStage = (name) => setParam('stage', name);
const setSelectedVar = (key) => setParam('var', key);
+ const setSelectedJobSkill = (name) => setParam('skill', name);
const [stages, setStages] = useState({});
// The CURATED system-stage keys. Served by GET /api/prompts
// (`server/lib/promptSystemStages.js`) rather than mirrored client-side, so
@@ -96,9 +98,8 @@ export default function PromptManager() {
template: ''
});
- // Job skills
+ // Job skills (selection is URL-driven — see selectedJobSkill above)
const [jobSkills, setJobSkills] = useState([]);
- const [selectedJobSkill, setSelectedJobSkill] = useState(null);
const [jobSkillContent, setJobSkillContent] = useState('');
const [jobSkillMeta, setJobSkillMeta] = useState({});
const [jobSkillPreview, setJobSkillPreview] = useState('');
@@ -290,14 +291,22 @@ export default function PromptManager() {
await loadData();
};
- // Job skill functions
- const loadJobSkill = async (name) => {
- setSelectedJobSkill(name);
+ // Fetch the URL-selected job skill's template + meta. Keyed on selectedJobSkill
+ // so a deep link / reload / tab switch restores the open editor; a cleared
+ // param resets it. Mirrors the `selectedStage` effect above.
+ useEffect(() => {
setJobSkillPreview('');
- const res = await getJobSkill(name, { silent: true }).catch(() => ({}));
- setJobSkillContent(res.content || '');
- setJobSkillMeta({ jobName: res.jobName, jobId: res.jobId, category: res.category, interval: res.interval });
- };
+ if (!selectedJobSkill) { setJobSkillContent(''); setJobSkillMeta({}); return; }
+ let cancelled = false;
+ getJobSkill(selectedJobSkill, { silent: true })
+ .then((res) => {
+ if (cancelled || !res) return;
+ setJobSkillContent(res.content || '');
+ setJobSkillMeta({ jobName: res.jobName, jobId: res.jobId, category: res.category, interval: res.interval });
+ })
+ .catch(() => {});
+ return () => { cancelled = true; };
+ }, [selectedJobSkill]);
const saveJobSkill = async () => {
setSaving(true);
@@ -821,7 +830,7 @@ export default function PromptManager() {
{jobSkills.map((skill) => (
<button
key={skill.name}
- onClick={() => loadJobSkill(skill.name)}
+ onClick={() => setSelectedJobSkill(skill.name)}
className={`w-full text-left px-3 py-2 rounded-lg text-sm ${
selectedJobSkill === skill.name
? 'bg-port-accent/20 text-port-accent'
diff --git a/client/src/pages/PromptManager.test.jsx b/client/src/pages/PromptManager.test.jsx
index 462ac1842c..77cc77585c 100644
--- a/client/src/pages/PromptManager.test.jsx
+++ b/client/src/pages/PromptManager.test.jsx
@@ -1,6 +1,6 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent, waitFor, within } from '@testing-library/react';
-import { MemoryRouter } from 'react-router';
+import { MemoryRouter, useLocation } from 'react-router';
import PromptManager from './PromptManager';
// The Stages pane is the subject: 100+ rows with no way to reach one (#3284).
@@ -12,6 +12,8 @@ const getPromptUsage = vi.fn();
const deletePrompt = vi.fn();
const getPromptVariables = vi.fn();
const deletePromptVariable = vi.fn();
+const getJobSkills = vi.fn(() => Promise.resolve({ skills: [] }));
+const getJobSkill = vi.fn(() => Promise.resolve({}));
vi.mock('../services/apiPrompts', () => ({
getPrompts: (...a) => getPrompts(...a),
@@ -25,8 +27,8 @@ vi.mock('../services/apiPrompts', () => ({
createPromptVariable: vi.fn(),
savePromptVariable: vi.fn(),
deletePromptVariable: (...a) => deletePromptVariable(...a),
- getJobSkills: vi.fn(() => Promise.resolve({ skills: [] })),
- getJobSkill: vi.fn(),
+ getJobSkills: (...a) => getJobSkills(...a),
+ getJobSkill: (...a) => getJobSkill(...a),
saveJobSkill: vi.fn(),
previewJobSkill: vi.fn(),
}));
@@ -50,12 +52,21 @@ const STAGES = {
// badges and filters exactly what GET /api/prompts names in `systemStages`.
const SYSTEM_STAGES = ['brain-classifier'];
+// Surfaces the live search string so URL-driven selection can be asserted on.
+const LocationProbe = () => {
+ const { search } = useLocation();
+ return <div data-testid="location-search">{search}</div>;
+};
+
const renderPage = (entry = '/prompts') => render(
<MemoryRouter initialEntries={[entry]}>
<PromptManager />
+ <LocationProbe />
</MemoryRouter>,
);
+const currentSearch = () => screen.getByTestId('location-search').textContent;
+
// File-level defaults so every describe mounts against the same empty-ish page;
// individual suites override only what they assert on.
beforeEach(() => {
@@ -425,3 +436,62 @@ describe('PromptManager variable deletion', () => {
expect(screen.getByText('Delete "House Style"?')).toBeTruthy();
});
});
+
+// Job skill selection lives in `?skill=` so the open editor is deep-linkable and
+// survives a reload or a tab round-trip (#3936).
+describe('PromptManager job skill selection', () => {
+ const SKILLS = [
+ { name: 'code-fixer', jobId: 'job-code-fixer', hasTemplate: true },
+ { name: 'doc-writer', jobId: 'job-doc-writer', hasTemplate: false },
+ ];
+
+ beforeEach(() => {
+ getPrompts.mockReset().mockResolvedValue({ stages: STAGES, systemStages: SYSTEM_STAGES });
+ getJobSkills.mockReset().mockResolvedValue({ skills: SKILLS });
+ getJobSkill.mockReset().mockImplementation((name) => Promise.resolve({
+ content: `# ${name} template`,
+ jobName: `Job ${name}`,
+ jobId: `job-${name}`,
+ category: 'maintenance',
+ interval: 'daily',
+ }));
+ });
+
+ it('writes the picked skill to the URL instead of local state', async () => {
+ renderPage('/prompts?tab=job-skills');
+ await screen.findByText('code-fixer');
+
+ fireEvent.click(screen.getByText('code-fixer'));
+
+ await waitFor(() => expect(currentSearch()).toContain('skill=code-fixer'));
+ expect(currentSearch()).toContain('tab=job-skills');
+ await screen.findByText('Job code-fixer');
+ });
+
+ it('loads the skill named by a deep link on mount', async () => {
+ renderPage('/prompts?tab=job-skills&skill=doc-writer');
+
+ await screen.findByText('Job doc-writer');
+ expect(getJobSkill).toHaveBeenCalledWith('doc-writer', { silent: true });
+ expect(screen.getByDisplayValue('# doc-writer template')).toBeTruthy();
+ });
+
+ it('keeps the open skill editor across a tab round-trip', async () => {
+ renderPage('/prompts?tab=job-skills&skill=code-fixer');
+ await screen.findByText('Job code-fixer');
+
+ fireEvent.click(screen.getByRole('button', { name: /variables/i }));
+ fireEvent.click(screen.getByRole('button', { name: /job skills/i }));
+
+ await screen.findByText('Job code-fixer');
+ expect(currentSearch()).toContain('skill=code-fixer');
+ });
+
+ it('shows the placeholder when no skill is named in the URL', async () => {
+ renderPage('/prompts?tab=job-skills');
+ await screen.findByText('code-fixer');
+
+ expect(getJobSkill).not.toHaveBeenCalled();
+ expect(screen.getByText('Select a job skill to edit its prompt template')).toBeTruthy();
+ });
+});