fix: pass workspace directory in Files API requests (#1588)
* fix: pass effective workspace directory in Files API requests The web Files API used useDirectoryStore.currentDirectory as the workspace root, but the FilesView's effective directory comes from useEffectiveDirectory() which can differ (e.g. worktree sessions). When they diverged the server rejected file reads with 'Path is outside of active workspace'. Add directory override to FileReadOptions so callers can pass the effective directory per-call. The FilesView now passes its root (from useEffectiveDirectory) through readFile, statFile, image/PDF URLs, and the desktop image fallback. The server receives the correct workspace root via x-opencode-directory header or directory query parameter. Fixes #1456 * fix: cover files workspace directory regressions * fix: sync directory store on draft session and forward cache options The content cache wrapper in RuntimeAPIProvider was dropping the options parameter (including the per-call directory override) when making internal statFile and readFreshFile calls during cache validation and misses. This caused the underlying web API to fall back to getDirectory() which reads useDirectoryStore.currentDirectory. Additionally, openNewSessionDraft, setNewSessionDraftTarget, and overrideNewSessionDraftTarget updated the draft's directory without ever syncing useDirectoryStore. Since the web API's getDirectory() reads from that store, it returned the stale previous-project directory during draft sessions, causing 'Path is outside of active workspace' errors when opening files. Forward options through all internal calls in the content cache wrapper, and sync useDirectoryStore via setDirectory() whenever the draft session directory changes. --------- Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
5773297ecf
commit
71bae089a7
@@ -100,20 +100,20 @@ function withContentCache(files: FilesAPI): FilesAPI {
|
||||
if (hit) {
|
||||
// Validate cached entry is still fresh
|
||||
if (files.statFile) {
|
||||
const latest = await files.statFile(path).catch(() => {
|
||||
const latest = await files.statFile(path, options).catch(() => {
|
||||
removeCacheEntry(path);
|
||||
return null;
|
||||
});
|
||||
if (!latest || !statMatches(hit, latest)) {
|
||||
removeCacheEntry(path);
|
||||
return readFreshFile(path);
|
||||
return readFreshFile(path, options);
|
||||
}
|
||||
}
|
||||
touchContentLru(path);
|
||||
return { content: hit.content, path: hit.path };
|
||||
}
|
||||
|
||||
return readFreshFile(path);
|
||||
return readFreshFile(path, options);
|
||||
}
|
||||
: undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user