fix: resolve file card paths for ~/.rowboat/ files and restrict filepath blocks to existing files

- Resolve workspace-relative and /tmp paths in shell:openPath and shell:readFileBase64 IPC handlers
- Update assistant instructions to only use filepath blocks for files that already exist

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Arjun 2026-02-10 17:31:29 +05:30
parent 1aaa413828
commit a05e9468f3
2 changed files with 10 additions and 2 deletions

View file

@ -462,6 +462,9 @@ export function setupIpcHandlers() {
let filePath = args.path;
if (filePath.startsWith('~')) {
filePath = path.join(os.homedir(), filePath.slice(1));
} else if (!path.isAbsolute(filePath)) {
// Workspace-relative path — resolve against ~/.rowboat/
filePath = path.join(os.homedir(), '.rowboat', filePath);
}
const error = await shell.openPath(filePath);
return { error: error || undefined };
@ -470,6 +473,9 @@ export function setupIpcHandlers() {
let filePath = args.path;
if (filePath.startsWith('~')) {
filePath = path.join(os.homedir(), filePath.slice(1));
} else if (!path.isAbsolute(filePath)) {
// Workspace-relative path — resolve against ~/.rowboat/
filePath = path.join(os.homedir(), '.rowboat', filePath);
}
const stat = await fs.stat(filePath);
if (stat.size > 10 * 1024 * 1024) {

View file

@ -195,9 +195,11 @@ knowledge/People/Sarah Chen.md
~/Desktop/report.pdf
\`\`\`
This renders as an interactive card in the UI. Use this format for:
This renders as an interactive card in the UI that the user can click to open the file. Use this format for:
- Knowledge base file paths (knowledge/...)
- Files on the user's machine (~/Desktop/..., /Users/..., etc.)
- Audio files, images, documents, or any file reference
Never output raw file paths in plain text when they could be wrapped in a filepath block.`;
**IMPORTANT:** Only use filepath blocks for files that already exist. The card is clickable and opens the file, so it must point to a real file. If you are proposing a path for a file that hasn't been created yet (e.g., "Shall I save it at ~/Documents/report.pdf?"), use inline code (\`~/Documents/report.pdf\`) instead of a filepath block. Use the filepath block only after the file has been written/created successfully.
Never output raw file paths in plain text when they could be wrapped in a filepath block unless the file does not exist yet.`;