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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (claude): reject non-vision fallback, reachable context field, filename + a11y guards
[._.]/ Adam Eivyd95e346cdff1
diff --git a/client/src/components/universe/VisionDescribeModal.jsx b/client/src/components/universe/VisionDescribeModal.jsxindex 5920c2a1a5..84939ca797 100644--- a/client/src/components/universe/VisionDescribeModal.jsx+++ b/client/src/components/universe/VisionDescribeModal.jsx@@ -39,6 +39,10 @@ export default function VisionDescribeModal({ open, kind, entryName, onApply, onconst [images, setImages] = useState([]);const [uploading, setUploading] = useState(false);const [result, setResult] = useState('');+ // Optional "known context" the user can type to disambiguate the subject+ // (e.g. a name the images don't make obvious) — passed straight to the+ // vision prompt.+ const [context, setContext] = useState('');const fileInputRef = useRef(null);const {@@ -79,6 +83,7 @@ export default function VisionDescribeModal({ open, kind, entryName, onApply, onconst res = await describeEntityFromImages({kind,name: entryName || undefined,+ context: context.trim() || undefined,screenshots: images.map((img) => img.filename),providerId: selectedProviderId || undefined,model: selectedModel || undefined,@@ -137,6 +142,7 @@ export default function VisionDescribeModal({ open, kind, entryName, onApply, ontype="button"onClick={() => removeImage(img.filename)}title="Remove image"+ aria-label="Remove image"className="absolute -top-1.5 -right-1.5 bg-port-bg border border-port-border rounded-full p-0.5 text-gray-400 hover:text-port-error"><X size={11} />@@ -177,6 +183,22 @@ export default function VisionDescribeModal({ open, kind, entryName, onApply, on</p>)}+ {/* Optional context to disambiguate the subject for the model. */}+ <div>+ <label htmlFor="vision-describe-context" className="block text-xs text-gray-500 mb-1">+ Known context (optional)+ </label>+ <input+ id="vision-describe-context"+ type="text"+ value={context}+ onChange={(e) => setContext(e.target.value)}+ placeholder={`Anything the images don't make obvious about this ${noun}`}+ maxLength={2000}+ className="w-full px-2 py-1.5 text-xs bg-port-bg border border-port-border rounded text-gray-200"+ />+ </div>+<buttontype="button"onClick={runDescribe}diff --git a/server/routes/universeBuilder.js b/server/routes/universeBuilder.jsindex e0aca26cb4..a3007f7437 100644--- a/server/routes/universeBuilder.js+++ b/server/routes/universeBuilder.js@@ -413,10 +413,19 @@ const describeFromImagesSchema = z.object({});router.post('/describe-from-images', asyncHandler(async (req, res) => {const body = validateRequest(describeFromImagesSchema, req.body ?? {});- // Strip any path components so a crafted filename can't escape the- // screenshots dir when the runner joins it (the upload route already- // sanitizes on write; this guards a hand-crafted request body too).- const screenshots = body.screenshots.map((f) => sanitizeFilename(f));+ // The upload route already sanitizes on write, so a legitimately-uploaded+ // filename round-trips unchanged here. A hand-crafted body with path+ // components is rejected outright (a 400, not a silent rewrite to a name+ // that won't exist on disk — which would surface as a confusing generic+ // "Image not found" from the runner), keeping a traversal attempt+ // distinguishable from a deleted/never-uploaded file.+ const screenshots = body.screenshots.map((f) => {+ const safe = sanitizeFilename(f);+ if (safe !== f) {+ throw new ServerError(`Invalid screenshot filename: ${f}`, { status: 400, code: 'VALIDATION_ERROR' });+ }+ return safe;+ });const result = await describeEntityFromImages({ ...body, screenshots });res.json(result);}));diff --git a/server/services/universeVisionDescribe.js b/server/services/universeVisionDescribe.jsindex b463425659..9aaee3b024 100644--- a/server/services/universeVisionDescribe.js+++ b/server/services/universeVisionDescribe.js@@ -123,6 +123,19 @@ export async function describeEntityFromImages({ kind, name, context, screenshotscreenshots: images,});+ // runPromptThroughProvider's fallback path can swap a failed API provider for+ // a CLI/TUI one, which has no vision path and silently drops the images — so+ // a fallback completion would be prose hallucinated from the text prompt+ // alone, with no signal the references were ignored. Reject that outright+ // (the whole point of resolving an API provider up front was to never+ // describe images from nothing).+ if (result.usedFallback && result.fallbackProvider && result.fallbackProvider.type !== 'api') {+ throw new ServerError(+ 'The vision request fell back to a non-vision provider that cannot read images. Configure a reliable vision-capable API provider and retry.',+ { status: 502, code: 'VISION_FALLBACK_DROPPED_IMAGES' },+ );+ }+const description = stripCodeFences(result.text || '').trim();if (!description) {throw new ServerError('The vision model returned an empty description — try a different model or clearer images.', {diff --git a/server/services/universeVisionDescribe.test.js b/server/services/universeVisionDescribe.test.jsindex f90c84fb6e..6907527048 100644--- a/server/services/universeVisionDescribe.test.js+++ b/server/services/universeVisionDescribe.test.js@@ -57,14 +57,28 @@ describe('describeEntityFromImages', () => {);});- it('reports the fallback provider id when the runner swapped providers', async () => {+ it('reports the fallback provider id when the runner swapped to another API provider', async () => {promptRunner.runPromptThroughProvider.mockResolvedValue({- text: 'x', model: 'gpt-vision', fallbackProvider: { id: 'openai' },+ text: 'x', model: 'gpt-vision', usedFallback: true, fallbackProvider: { id: 'openai', type: 'api' },});const out = await describeEntityFromImages({ kind: 'place', screenshots: ['a.png'] });expect(out.llm).toEqual({ provider: 'openai', model: 'gpt-vision' });});+ it('rejects (VISION_FALLBACK_DROPPED_IMAGES) when the runner fell back to a non-API provider that drops images', async () => {+ promptRunner.runPromptThroughProvider.mockResolvedValue({+ text: 'hallucinated from text alone', model: 'sonnet', usedFallback: true, fallbackProvider: { id: 'claude-code', type: 'cli' },+ });+ await expect(describeEntityFromImages({ kind: 'character', screenshots: ['a.png'] }))+ .rejects.toMatchObject({ code: 'VISION_FALLBACK_DROPPED_IMAGES', status: 502 });+ });++ it('forwards optional context into the vision prompt', async () => {+ await describeEntityFromImages({ kind: 'object', context: 'a relic blade', screenshots: ['a.png'] });+ const { prompt } = promptRunner.runPromptThroughProvider.mock.calls[0][0];+ expect(prompt).toMatch(/Known context.*a relic blade/s);+ });+it('strips code fences the model may wrap the prose in', async () => {promptRunner.runPromptThroughProvider.mockResolvedValue({ text: '```\nfenced prose\n```', model: 'llava' });const out = await describeEntityFromImages({ kind: 'object', screenshots: ['a.png'] });