NousResearch/hermes-agent · warning · Error
r.couldNotPreview(path)
Error message
r.couldNotPreview(path)
What it means
Thrown by the right sidebar file browser's previewFile handler in the desktop app. It resolves a clicked file path against the session's effective cwd via normalizeOrLocalPreviewTarget; a null result means the path cannot be turned into any previewable target (unsupported scheme, unreachable location, unresolvable relative path). The catch converts it into an error notification, so it signals 'this file cannot be previewed from here' rather than crashing.
Source
Thrown at apps/desktop/src/app/right-sidebar/index.tsx:66
rootError,
rootLoading,
setNodeOpen
} = useProjectTree(hasWorkspace ? currentCwd : '')
const cwdName =
effectiveCwd
.split(/[\\/]+/)
.filter(Boolean)
.pop() ?? effectiveCwd
const canCollapse = Object.values(openState).some(Boolean)
const previewFile = async (path: string) => {
try {
const preview = await normalizeOrLocalPreviewTarget(path, effectiveCwd || undefined)
if (!preview) {
throw new Error(r.couldNotPreview(path))
}
openPreview(preview, 'file-browser')
} catch (error) {
notifyError(error, r.previewUnavailable)
}
}
return (
<aside
aria-label={r.aria}
className={cn(
'before:pointer-events-none relative flex h-full w-full min-w-0 flex-col overflow-hidden border-(--ui-stroke-secondary) bg-(--ui-sidebar-surface-background) pt-(--titlebar-height) text-(--ui-text-tertiary)',
panesFlipped
? 'border-r shadow-[inset_-0.0625rem_0_0_color-mix(in_srgb,white_18%,transparent)]'
: 'border-l shadow-[inset_0.0625rem_0_0_color-mix(in_srgb,white_18%,transparent)]'
)}
>View on GitHub (pinned to c896c09c42)
Solutions
- Confirm effectiveCwd is set for the session so relative paths resolve; reopen the workspace if cwd is empty.
- For remote backends, preview only files accessible from the client (mounted path or served URL).
- Refresh the file browser if the file may have been deleted or moved.
- As a developer: pre-filter browser entries with a canPreview check so unpreviewable entries are not clickable.
Example fix
// before
const preview = await normalizeOrLocalPreviewTarget(path, effectiveCwd || undefined)
if (!preview) {
throw new Error(r.couldNotPreview(path))
}
// after — only enable preview for entries the resolver will accept
const preview = await normalizeOrLocalPreviewTarget(path, effectiveCwd || undefined)
if (!preview) {
notifyError(new Error(r.couldNotPreview(path)), r.previewUnavailable)
return
} Defensive patterns
Strategy: try-catch
Validate before calling
const canPreview = (p: string) => p.startsWith('/') || p.startsWith('http') || Boolean(effectiveCwd)
if (!canPreview(path)) return Type guard
const isLocallyResolvable = (p: string, cwd?: string): boolean =>
p.startsWith('/') || /^https?:/.test(p) || Boolean(cwd && !p.startsWith('\\\\')) Try / catch
try {
const preview = await normalizeOrLocalPreviewTarget(path, effectiveCwd || undefined)
if (!preview) throw new Error(r.couldNotPreview(path))
openPreview(preview, 'file-browser')
} catch (error) {
notifyError(error, r.previewUnavailable) // toast, tree stays usable
} Prevention
- Keep session cwd synced so relative paths resolve
- Grey out unpreviewable entries in the tree instead of failing on click
- Refresh the tree when underlying files change
When it happens
Trigger: Clicking a file in the browser tree that is a directory-like entry or unsupported type, a path on a remote backend unreachable from the client, a relative path that fails to anchor because effectiveCwd is empty, or a file deleted between listing and click.
Common situations: Desktop app over SSH/URL backend where the file tree reflects the backend filesystem; workspace roots with symlinks the resolver refuses; empty-cwd sessions (brand-new session before cwd sync).
Related errors
- c.couldNotPreview(attachment.label)
- Could not open preview target: ${item.target}
- Not a directory: ${watchDir}
- Invalid preview URL
- Could not create directory: ${error.message}
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/3a0396d09e7ac78b.
Report an issue: GitHub.