Aller au contenu
login
arrow_backRetour aux issues
nesquena/hermes-webui #7239

WebUI Artifacts panel lists out-of-workspace write_file outputs but cannot open them

ecoDébutant bug help wanted ux workspace

descriptionDescription

**Summary** The WebUI Artifacts panel can display files written outside the active workspace, but clicking those artifact entries fails with cannot open file. In my case, the agent wrote a durable reference file under ~/.hermes/shared/. The Artifacts panel correctly listed it, but the click handler appears to assume every artifact path can be resolved relative to the current workspace. Because the file is outside the workspace, the existence check fails and the UI reports cannot open file. **Environment** Hermes WebUI Active workspace: /home/hermesuser/workspace Artifact path shown in UI: /home/hermesuser/.hermes/shared/hermes-profile-setup-credentials.md Reproduction In WebUI, start a session with workspace: /home/hermesuser/workspace Ask the agent to save/write a file outside the workspace, for example: /home/hermesuser/.hermes/shared/hermes-profile-setup-credentials.md Observe that the file appears in the top-right Artifacts panel. Click the artifact entry. WebUI shows: cannot open file **Observed DOM** The Artifacts entry renders with the correct absolute file path: ``` htmlCopy hermes-profile-setup-credentials.md /home/hermesuser/.hermes/ shared/ write_file ``` **Suspected cause** static/workspace.js has this flow: ```async function openArtifactPath(path){ if(!path) return; switchWorkspacePanelTab('files'); let rel = String(path) .replace(/\\/g,'/') .replace(/^~\//,'') .replace(/^(?:\.\/)+/,''); const ws = (S.session && S.session.workspace || '').replace(/\\/g,'/'); if(ws){ const normWs = ws.replace(/\/+$/,'') + '/'; if(rel.startsWith(normWs)) rel = rel.slice(normWs.length); else if(rel === ws.replace(/\/+$/,'')) rel = '.'; } if(!rel) rel = '.'; try{ if(!(await _workspacePathExists(rel))){ setStatus(t('file_open_failed')); return; } }catch(_){ setStatus(t('file_open_failed')); return; } openFile(rel); } ``` And _workspacePathExists() checks existence through /api/list for the current session workspace: ``` async function _workspacePathExists(path){ if(!S.session||!path) return false; const parts=String(path).replace(/\\/g,'/').split('/').filter(Boolean); const name=parts.pop(); if(!name) return false; const dir=parts.length?parts.join('/'):'.'; const data=await api(`/api/list?session_id=${encodeURIComponent(S.session.session_id)}&path;=${encodeURIComponent(dir)}`); return (data.entries||[]).some(entry=>entry&&((entry.path===path)||entry.name===name)); } ``` For an artifact at: /home/hermesuser/.hermes/shared/hermes-profile-setup-credentials.md and workspace: /home/hermesuser/workspace the path is not under the workspace, so the prefix-strip does not apply. The code then asks /api/list to list something equivalent to: home/hermesuser/.hermes/shared relative to the workspace, which fails. The UI reports cannot open file. **Expected behavior** Either: Out-of-workspace artifacts should open successfully if they are safe/authorized paths, or Out-of-workspace artifacts should not be rendered as clickable workspace artifacts, or The UI should show a clearer message such as: Artifact exists outside the current workspace and cannot be opened from the workspace file panel. Actual behavior The artifact is displayed as clickable, but clicking it fails with a generic: cannot open file **Suggested fixes** Possible approaches: Option A: Use a safe absolute-path file rea
codeOuvre sur GitHub