Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(ui): OS-aware directory-browser favorites + clearer hidden toggle & home path (#374)
Call White26a10c93ed8a
diff --git a/ui/src/components/ui/directory-browser.tsx b/ui/src/components/ui/directory-browser.tsxindex 9c93518f3..10a6e1132 100644--- a/ui/src/components/ui/directory-browser.tsx+++ b/ui/src/components/ui/directory-browser.tsx@@ -3,6 +3,7 @@ import {Check,ChevronLeft,ChevronRight,+ Database,Download,Eye,EyeOff,@@ -10,8 +11,10 @@ import {Folder,FolderOpen,FolderPlus,+ HardDrive,Home,Keyboard,+ LayoutGrid,Monitor,RefreshCw,X,@@ -30,6 +33,42 @@ interface DirectoryBrowserProps {onClose: () => void;}+// Per-OS quick-access shortcuts come from the backend (it knows the platform+// and verifies each path exists). Well-known shortcuts get a localized label;+// OS roots like /tmp, /data or a Windows drive are shown by their path. Both+// label and icon are keyed off the backend's stable ``key``.+const FAVORITE_I18N: Record<string, string> = {+ home: 'directoryBrowser.favoritesHome',+ desktop: 'directoryBrowser.favoritesDesktop',+ documents: 'directoryBrowser.favoritesDocuments',+ downloads: 'directoryBrowser.favoritesDownloads',+ applications: 'directoryBrowser.favoritesApplications',+};++const favoriteIcon = (key: string): React.ReactNode => {+ const cls = 'size-3.5';+ switch (key) {+ case 'home':+ return <Home className={cls} />;+ case 'desktop':+ return <Monitor className={cls} />;+ case 'documents':+ return <FileText className={cls} />;+ case 'downloads':+ return <Download className={cls} />;+ case 'applications':+ return <LayoutGrid className={cls} />;+ case 'data':+ return <Database className={cls} />;+ default:+ // root / mnt / media / drive_* → a volume; anything else a plain folder.+ if (key === 'root' || key === 'mnt' || key === 'media' || key.startsWith('drive_')) {+ return <HardDrive className={cls} />;+ }+ return <Folder className={cls} />;+ }+};+// Mirrors design.pen y5cQ5 — macOS Finder-style folder picker: traffic// lights + toolbar (history nav + breadcrumb + show-hidden + new-folder)// + favorites sidebar + folder list + footer (path + cancel + select).@@ -70,10 +109,9 @@ export const DirectoryBrowser: React.FC<DirectoryBrowserProps> = ({const [pathError, setPathError] = useState<string | null>(null);const pathInputRef = useRef<HTMLInputElement | null>(null);- // Which favorites actually resolve on this filesystem. On Linux the- // Desktop/Documents/Downloads shortcuts often don't exist, so we hide- // them rather than handing the user a row that always 404s.- const [favoriteExists, setFavoriteExists] = useState<Record<string, boolean>>({});+ // OS-appropriate quick-access shortcuts, resolved + existence-checked by the+ // backend (macOS Finder entries, Linux /tmp·/data·roots, Windows drives…).+ const [favorites, setFavorites] = useState<{ key: string; path: string }[]>([]);const mountedRef = useRef(true);const reqIdRef = useRef(0);@@ -198,24 +236,19 @@ export const DirectoryBrowser: React.FC<DirectoryBrowserProps> = ({// eslint-disable-next-line react-hooks/exhaustive-deps}, []);- // Probe each non-home favorite once on open. We hit the backend with a- // single browse call per favorite — fast enough since it's only three- // shortcuts — and drop the ones that come back !ok. Home is always- // shown because every user has one.+ // Load OS-appropriate shortcuts once on open. The backend knows the platform+ // and verifies each path, so we render exactly what it returns (no dead rows,+ // no client-side OS guesswork).useEffect(() => {let cancelled = false;- const targets = ['~/Desktop', '~/Documents', '~/Downloads'];- Promise.all(- targets.map((path) =>- api- .browseDirectory(path, false)- .then((res) => ({ path, exists: !!res.ok }))- .catch(() => ({ path, exists: false })),- ),- ).then((results) => {- if (cancelled) return;- setFavoriteExists(Object.fromEntries(results.map((r) => [r.path, r.exists])));- });+ api+ .browseFavorites()+ .then((res) => {+ if (!cancelled && res.ok && res.favorites) setFavorites(res.favorites);+ })+ .catch(() => {+ /* leave favorites empty on failure — the folder list still works */+ });return () => {cancelled = true;};@@ -284,7 +317,10 @@ export const DirectoryBrowser: React.FC<DirectoryBrowserProps> = ({.filter(Boolean);const out: { label: string; path: string; isHome?: boolean }[] = [];if (startsAtHome) {- out.push({ label: '⌂', path: homePath, isHome: true });+ // At home itself, show the full path — a bare ⌂ is cryptic. Collapse to+ // ⌂ only once you're deeper in, where it keeps long paths readable (the+ // full path still lives in the footer and the home crumb's tooltip).+ out.push({ label: segments.length === 0 ? homePath : '⌂', path: homePath, isHome: true });} else {out.push({ label: '/', path: '/' });}@@ -301,20 +337,6 @@ export const DirectoryBrowser: React.FC<DirectoryBrowserProps> = ({const canBack = historyIndex > 0;const canForward = historyIndex < history.length - 1;- // Static shortcuts mirroring Finder's Favorites column. We just hand- // these to the existing `browseDirectory` endpoint — the backend- // expands ``~`` so we don't need to resolve them client-side. Home is- // always shown; the other three are gated by ``favoriteExists`` so- // Linux installations without Desktop/Documents/Downloads don't see- // dead rows.- const allFavorites: { i18nKey: string; path: string; icon: React.ReactNode; always?: boolean }[] = [- { i18nKey: 'directoryBrowser.favoritesHome', path: '~', icon: <Home className="size-3.5" />, always: true },- { i18nKey: 'directoryBrowser.favoritesDesktop', path: '~/Desktop', icon: <Monitor className="size-3.5" /> },- { i18nKey: 'directoryBrowser.favoritesDocuments', path: '~/Documents', icon: <FileText className="size-3.5" /> },- { i18nKey: 'directoryBrowser.favoritesDownloads', path: '~/Downloads', icon: <Download className="size-3.5" /> },- ];- const favorites = allFavorites.filter((fav) => fav.always || favoriteExists[fav.path]);-return (<divclassName="fixed inset-0 z-50 flex items-center justify-center bg-black/50"@@ -421,6 +443,7 @@ export const DirectoryBrowser: React.FC<DirectoryBrowserProps> = ({<buttontype="button"onClick={() => navigate(crumb.path)}+ title={crumb.isHome ? homePath : undefined}className={clsx('shrink-0 rounded px-1 py-0.5 transition hover:bg-foreground/[0.04]',i === breadcrumbs.length - 1 ? 'font-semibold text-cyan' : 'text-muted',@@ -452,6 +475,8 @@ export const DirectoryBrowser: React.FC<DirectoryBrowserProps> = ({<buttontype="button"onClick={toggleHidden}+ aria-pressed={showHidden}+ title={t('directoryBrowser.hiddenFiles')}className={clsx('flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-[11px] font-semibold transition',showHidden@@ -459,8 +484,10 @@ export const DirectoryBrowser: React.FC<DirectoryBrowserProps> = ({: 'border-border-strong text-muted hover:text-foreground',)}>+ {/* Stable label — on/off is conveyed by the Eye/EyeOff icon and the+ cyan (on) vs muted (off) treatment, not by changing the words. */}{showHidden ? <Eye className="size-3" /> : <EyeOff className="size-3" />}- {showHidden ? t('directoryBrowser.showHidden') : t('directoryBrowser.hideHidden')}+ {t('directoryBrowser.hiddenFiles')}</button><button@@ -484,17 +511,23 @@ export const DirectoryBrowser: React.FC<DirectoryBrowserProps> = ({<div className="px-2 pb-1 font-mono text-[9px] font-bold uppercase tracking-[0.16em] text-muted">{t('directoryBrowser.favorites')}</div>- {favorites.map((fav) => (- <button- key={fav.path}- type="button"- onClick={() => navigate(fav.path)}- className="flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-[12px] text-foreground transition hover:bg-foreground/[0.04]"- >- <span className="text-muted">{fav.icon}</span>- <span className="truncate">{t(fav.i18nKey)}</span>- </button>- ))}+ {favorites.map((fav) => {+ // Localized label for well-known shortcuts; the raw path for OS+ // roots (/tmp, /data, drives) so they read clearly.+ const label = FAVORITE_I18N[fav.key] ? t(FAVORITE_I18N[fav.key]) : fav.path;+ return (+ <button+ key={fav.path}+ type="button"+ onClick={() => navigate(fav.path)}+ title={fav.path}+ className="flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-[12px] text-foreground transition hover:bg-foreground/[0.04]"+ >+ <span className="shrink-0 text-muted">{favoriteIcon(fav.key)}</span>+ <span className="truncate">{label}</span>+ </button>+ );+ })}</aside>{/* Folder list */}diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsxindex 142b37b7a..8e34e4a83 100644--- a/ui/src/context/ApiContext.tsx+++ b/ui/src/context/ApiContext.tsx@@ -93,6 +93,7 @@ export type ApiContextType = {getVersion: () => Promise<VersionInfo>;doUpgrade: () => Promise<UpgradeResult>;browseDirectory: (path: string, showHidden?: boolean) => Promise<{ ok: boolean; path?: string; parent?: string | null; dirs?: { name: string; path: string }[]; error?: string }>;+ browseFavorites: () => Promise<{ ok: boolean; system?: string; favorites?: { key: string; path: string }[]; error?: string }>;browseMkdir: (path: string) => Promise<{ path: string }>;listProjects: (includeArchived?: boolean) => Promise<{ projects: WorkbenchProject[] }>;createProject: (payload: { folder_path: string; display_name?: string }) => Promise<WorkbenchProject>;@@ -1114,6 +1115,7 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ childrengetVersion: () => getJson('/api/version'),doUpgrade: () => postJson('/api/upgrade', {}),browseDirectory: (path, showHidden) => postJson('/api/browse', { path, show_hidden: showHidden || false }),+ browseFavorites: () => getJson('/api/browse/favorites'),browseMkdir: (path) => postJson('/api/browse/mkdir', { path }),listProjects: (includeArchived) =>getJson(`/api/projects${includeArchived ? '?include_archived=1' : ''}`),diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 46c7f83c7..e3dabc981 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -1181,8 +1181,7 @@"select": "Select","cancel": "Cancel","empty": "No subdirectories",- "showHidden": "Show hidden",- "hideHidden": "Hide hidden",+ "hiddenFiles": "Hidden files","newFolder": "New Folder","newFolderPlaceholder": "Folder name","createHere": "Create new folder here…",@@ -1191,6 +1190,7 @@"favoritesDesktop": "Desktop","favoritesDocuments": "Documents","favoritesDownloads": "Downloads",+ "favoritesApplications": "Applications","back": "Back","forward": "Forward","newFolderExists": "A folder with that name already exists.",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 738c17429..60ddf8475 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -1181,8 +1181,7 @@"select": "选择此目录","cancel": "取消","empty": "没有子目录",- "showHidden": "显示隐藏",- "hideHidden": "隐藏隐藏",+ "hiddenFiles": "隐藏文件","newFolder": "新建文件夹","newFolderPlaceholder": "文件夹名称","createHere": "在这里新建文件夹…",@@ -1191,6 +1190,7 @@"favoritesDesktop": "桌面","favoritesDocuments": "文稿","favoritesDownloads": "下载",+ "favoritesApplications": "应用程序","back": "后退","forward": "前进","newFolderExists": "已存在同名文件夹。",diff --git a/vibe/api.py b/vibe/api.pyindex cc9b1f2ad..875636286 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -480,6 +480,67 @@ def browse_directory(path: str, show_hidden: bool = False) -> dict:return {"ok": False, "error": str(exc)}+def browse_favorites() -> dict:+ """Return OS-appropriate quick-access directories for the directory picker.++ Each entry is ``{"key": <stable id>, "path": <abs>}``; only directories that+ actually exist are returned, so the UI never renders a dead shortcut. The+ ``key`` lets the UI localize the well-known shortcuts (home/desktop/...),+ while OS-specific roots (``/tmp``, ``/data``, Windows drive letters) are+ shown by their path. Home is always first. Mirrors how Finder/Explorer/most+ Linux file managers seed their sidebar per platform.+ """+ import platform++ home = Path(os.path.expanduser("~"))+ system = platform.system().lower() # 'darwin' | 'linux' | 'windows'++ # (key, path) candidates in display order. Existence is verified below, so+ # OS-specific entries absent on this machine simply drop out of the list.+ candidates: list[tuple[str, Path]] = [("home", home)]+ if system == "darwin":+ candidates += [+ ("desktop", home / "Desktop"),+ ("documents", home / "Documents"),+ ("downloads", home / "Downloads"),+ ("applications", Path("/Applications")),+ ("tmp", Path("/tmp")),+ ]+ elif system == "windows":+ candidates += [+ ("desktop", home / "Desktop"),+ ("documents", home / "Documents"),+ ("downloads", home / "Downloads"),+ ]+ # Drive roots (C:\, D:\, …) as quick jumps to a volume's top level.+ candidates += [(f"drive_{letter.lower()}", Path(f"{letter}:\\")) for letter in "CDEFG"]+ else: # linux / other unix+ candidates += [+ ("desktop", home / "Desktop"),+ ("documents", home / "Documents"),+ ("downloads", home / "Downloads"),+ ("root", Path("/")),+ ("tmp", Path("/tmp")),+ ("data", Path("/data")),+ ("mnt", Path("/mnt")),+ ("media", Path("/media")),+ ]++ seen: set[str] = set()+ favorites: list[dict] = []+ for key, candidate in candidates:+ try:+ abs_path = str(candidate)+ if abs_path in seen or not candidate.is_dir():+ continue+ except OSError:+ continue+ seen.add(abs_path)+ favorites.append({"key": key, "path": abs_path})++ return {"ok": True, "system": system, "favorites": favorites}++def load_config() -> V2Config:return V2Config.load()diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex f1a7b544a..cc7b98fc6 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -2625,6 +2625,14 @@ def browse_directory():)[email protected]("/api/browse/favorites", methods=["GET"])+def browse_favorites():+ """OS-appropriate quick-access directories for the directory picker."""+ from vibe import api++ return jsonify(api.browse_favorites())++# =============================================================================# Workbench: Projects + folder-picker helpers# =============================================================================