Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
diff --git a/views-src/src/App.tsx b/views-src/src/App.tsx
index ef0e3e3..15929f1 100644
--- a/views-src/src/App.tsx
+++ b/views-src/src/App.tsx
@@ -716,8 +716,7 @@ export default function App() {
* 目录照旧展开、行照旧高亮,与点击搜索结果一致)。
* 组外绝对路径 → 0.4.0 的外部行为:不进树、不高亮、基点不动。
* 换基点必须先落盘(见 activateRoot)——包含基点由 prefs.projectRoots 推导。
- * 视觉结果与在树里点这个文件一致,因此复用 openEntry 与它的脏缓冲守卫;宿主
- * 请求一律把左侧列表收起并持久化,用户之后重新展开会一直保持到下一次宿主请求。
+ * Host file requests collapse the tree; directory requests keep it open.
*/
const applyHostOpen = useCallback(
(request: HostOpenRequest) => {
@@ -732,15 +731,17 @@ export default function App() {
const base = contained ? contained.root : absolute ? null : primaryRootOf(roots);
const relPath = contained ? contained.rel : rawPath;
- persistPrefs({ treeCollapsed: true });
-
const show = () => {
if (workspaceKey(workspaceRef.current) !== requestedWorkspace) return;
const revision = revisionRef.current;
// 已经是这个文件:不重装文档,也就不必为脏缓冲再问一遍。
- if (relPath === openPathRef.current) return;
+ if (relPath === openPathRef.current) {
+ persistPrefs({ treeCollapsed: true });
+ return;
+ }
// 组外的绝对路径不在树里:不展开、也不高亮(openEntry 会把选中态置空)。
if (!contained && absolute) {
+ persistPrefs({ treeCollapsed: true });
void openEntry({ path: relPath });
return;
}
@@ -754,6 +755,16 @@ export default function App() {
await loadDirectory(parent);
}
if (revision !== revisionRef.current) return;
+ // Classify from the listing returned by the load, not stale render state.
+ const listing = await loadDirectory(parents.at(-1) ?? "");
+ if (revision !== revisionRef.current) return;
+ if (listing?.some((entry) => entry.path === relPath && entry.isDirectory)) {
+ setExpanded((prev) => new Set([...prev, relPath]));
+ persistPrefs({ treeCollapsed: false });
+ await loadDirectory(relPath);
+ return;
+ }
+ persistPrefs({ treeCollapsed: true });
await openEntry({ path: relPath });
})();
};
diff --git a/views-src/src/i18n.ts b/views-src/src/i18n.ts
index 4f4b2d1..c655baf 100644
--- a/views-src/src/i18n.ts
+++ b/views-src/src/i18n.ts
@@ -238,6 +238,7 @@ export const COPY_TABLES = {
errExists: "An entry with that name already exists.",
errName: "That name is not allowed.",
errNotFound: "That path no longer exists.",
+ errIsDirectory: "That path is a directory; folders are browsed in the tree, and only inside the project.",
errUnsupported: "This host does not support that operation.",
errNoBridge: "This page must be opened inside PI-Desktop.",
changes: "Changes",
@@ -498,6 +499,7 @@ export const COPY_TABLES = {
errExists: "同名条目已存在。",
errName: "该名称不被允许。",
errNotFound: "该路径已不存在。",
+ errIsDirectory: "该路径是一个目录;文件夹在目录树里浏览,且只能在项目内。",
errUnsupported: "当前宿主不支持该操作。",
errNoBridge: "本页面需要在 PI-Desktop 中打开。",
changes: "变更",
diff --git a/views-src/src/lib/rpc.ts b/views-src/src/lib/rpc.ts
index 18d4c4b..12d4cc0 100644
--- a/views-src/src/lib/rpc.ts
+++ b/views-src/src/lib/rpc.ts
@@ -471,6 +471,8 @@ export function failureMessage(failure: Failure, t: T): string {
return t("readOnly");
case "CONFLICT":
return t("conflictTitle");
+ case "INVALID_PATH":
+ return failure.message === "path is a directory" ? t("errIsDirectory") : failure.message || failure.code;
case "NOT_FOUND":
return t("errNotFound");
case "UNSUPPORTED":