diff --git a/AGENTS.md b/AGENTS.md index 76c27eeae..5776ff906 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1031,6 +1031,10 @@ during the wait. - `/api/cwd/validate`, `/api/default-cwd`, and `/api/worktrees` call `allowFileRoot()` when they make a new location browsable. - The session-id → file path cache (`cacheSessionPath`, `lib/session-reader.ts`) on main is filled by main's own scans and by wrappers on the local host; it only serves the readers listed under "Session list caching". +### Explorer hidden items +- The tree skip-list (`IGNORED_NAMES`/`IGNORED_SUFFIXES`) is **duplicated** in `app/api/files/[...path]/route.ts` and `app/api/file-index/route.ts` — edit both or extract a shared module. +- The Explorer's "Show hidden items" toggle sends `?hidden=1`, which bypasses the skip-list for `type=list` only. It deliberately does NOT touch `/api/file-index` — @-mentions and file search keep ignoring those paths. State is AppShell-owned (localStorage `omp-web:show-hidden-files`, off by default); flipping it makes `FileExplorer` drop its cached listings and re-read the visible directories, keeping expansion. + ### Session list caching — new sessions must appear immediately - The sidebar and command palette list sessions per host: `listSessionsAllHosts()` (`lib/hosts/session-index.ts`) calls each host's `listSessions` op and caches it 30 s per host (`LIST_TTL_MS`, the daemon's own TTL). **This machine's list is its daemon's**; a host that fails or is offline keeps its last list. Nothing on main parses session files to build it. - The daemon's `listSessions` is `listAllSessions()` (`lib/session-reader.ts`): a 30 s TTL list cache plus an mtime-keyed directory walk in `lib/omp/session-files.ts` (`listSessionFiles`), both in the daemon process. diff --git a/CHANGELOG.md b/CHANGELOG.md index 28068833e..68e28709d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f - **Session search shows where each session matched.** While searching the sidebar, the arrow beside a session lists its matches one per line, best match first and newest first among equals, ten at a time with **Load more…**. Matches in the messages of the open conversation are highlighted, typos and partial words included (thinking, tool output and math are not searched; link addresses and image descriptions do not count), and clicking a match opens its session, scrolls to it and marks it as the current one, like the browser's find. Closing or clearing the search removes the highlights. Browsers without the CSS Custom Highlight API (before Chrome 105, Safari 17.2 or Firefox 140) still jump to the match but do not paint it. - **Show tool calls outside Process details.** A new setting keeps each tool call's row in the transcript instead of folding it; whether the row opens still follows "Keep tool calls collapsed". - **Never fold tool activity.** A new setting renders every turn flat, with no Process details rows at all. Long turns are paged, and jumping to a search match reveals its message even outside the current page. +- **Show hidden items in the Explorer.** A switch in the file panel's toolbar lists the folders the tree normally hides — `build/`, `dist/`, `node_modules/`, `target/` and the rest — so you can browse into them and open a file from there. It changes only the file tree; search and @-mentions keep ignoring those paths. It is off by default, and your choice is remembered. - **Updates belong to each host.** Settings → Hosts now shows the ompweb daemon and OMP runtime versions, available updates, and update actions for every machine, including This machine. Checks and installations run on that host. An incompatible or unverifiable daemon update stays visible but blocked, with a reason to update the web server first; OMP updates are independent of the link protocol. A daemon update is refused while session processes or subagents run on that host (close them, then start it again), and the host refuses new sessions while it installs. The host update retains a backup and reports progress after reconnect. **System & Updates** is now **System**, containing only the web server's controls; it no longer updates or restarts a host's OMP sessions globally. ### Fixes & Improvements diff --git a/README.ja.md b/README.ja.md index d237626f6..bf84e3ebd 100644 --- a/README.ja.md +++ b/README.ja.md @@ -109,7 +109,7 @@ Linux トレイ、Windows サービス)はインストール時に `OMP_WEB_PA - **セッション管理**: プロジェクトごとに履歴を一覧表示、分岐やフォークにも対応。 - **下書きの復元**: 未送信のテキストを会話または新規セッションのワークスペースごとに保存し、ブラウザストレージが利用可能な場合は、同じタブでの「戻る」「進む」や再読み込み後に復元します(最大 50 件)。画像と添付ファイルはメモリ内にのみ保持されます。 - **ライブタスク&サブエージェント**: Todo リストと稼働中サブエージェントの進捗を折りたたみパネルでリアルタイム表示。 -- **ファイル閲覧・プレビュー**: チャットと並べてファイルを閲覧、コード・Markdown・画像・音声・PDF をプレビュー。 +- **ファイル閲覧・プレビュー**: チャットと並べてファイルを閲覧、コード・Markdown・画像・音声・PDF をプレビュー。「隠し項目を表示」でビルド生成物や依存関係も一覧できます。 - **Git Worktree サポート**: サイドバーから直接 Git ワークツリーを切り替え・管理。 - **GUI 設定管理**: 設定ファイルを直接編集することなく、モデル、API キー、MCP サーバー、スキル、プラグイン、OMP 設定を変更可能。 - **スラッシュコマンド・ショートカット**: `/plan`、`/review`、`/fix`、`/test` などの定型プロンプトと `⌘K` / `Ctrl+K` コマンドパレット。 diff --git a/README.md b/README.md index 4942a613f..42f4b7f83 100644 --- a/README.md +++ b/README.md @@ -654,7 +654,7 @@ Stop it with `Stop-ScheduledTask ompweb-host`, then end the running host with - **Draft Recovery**: Unsent text stays scoped to its conversation or new-session workspace and is restored after Back/Forward navigation or reload in the same tab when browser storage is available (up to 50 drafts). Images and file attachments remain in memory only. - **Live Plans & Subagents**: Collapsible panels pinned above the composer track live todo phases and running subagents (status, tool, retries, tokens/cost, nested tasks) with transcript dialogs and history recovery. - **Tool Preset Picker**: Choose the toolset for new sessions in the composer — `none` / `default` (`read,bash,edit,write`) / `full` (all tools including subagents). Persists to localStorage. -- **File Explorer & Previews**: Browse workspaces side-by-side with chat; preview code, markdown, Mermaid, images, audio, PDFs, and diffs with allow-listed access. +- **File Explorer & Previews**: Browse workspaces side-by-side with chat; preview code, markdown, Mermaid, images, audio, PDFs, and diffs with allow-listed access. The **Show hidden items** switch lists build and dependency folders. - **Git Worktree Support**: Create, switch, and manage Git worktrees directly from the sidebar; sessions and file roots stay grouped by project. - **Remote Hosts**: Link other machines (for example a MacBook) and run sessions there from one ompweb. The sidebar groups sessions by host. See [Run sessions on another machine](#run-sessions-on-another-machine). - **Usage & Analytics**: Dashboard in **Settings → Usage** for tokens, costs, cache savings, and breakdowns by provider / model / day / project with SQLite persistence. diff --git a/README.zh-CN.md b/README.zh-CN.md index e4a4c66aa..270eb859c 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -102,7 +102,7 @@ Windows 服务)仍在安装时接受 `OMP_WEB_PASSWORD`,但在写入配置 - **会话管理**:按项目浏览历史会话,支持会话分叉与分支回溯。 - **草稿恢复**:未发送的文本按会话或新会话的工作区分别保存;浏览器存储可用时,在同一标签页后退、前进或重新加载后可恢复(最多 50 份草稿)。图片和文件附件仅保留在内存中。 - **实时任务与子智能体**:可折叠面板实时展示任务清单(todo)与子智能体进度,并支持查看完整转录。 -- **文件管理与预览**:与对话并排浏览文件,支持代码、Markdown、图片、音频及 PDF 预览。 +- **文件管理与预览**:与对话并排浏览文件,支持代码、Markdown、图片、音频及 PDF 预览。通过「显示隐藏项目」可列出构建产物与依赖目录。 - **Git Worktree 支持**:直接在侧边栏切换与管理 Git 工作树。 - **可视化设置**:在 Web 界面中直接配置模型、API 密钥、MCP 服务器、技能、插件及 OMP 原生设置。 - **快捷指令与命令面板**:内置常用指令(`/plan`、`/review`、`/fix`、`/test` 等)及 `⌘K` / `Ctrl+K` 全局面板。 diff --git a/app/api/files/[...path]/route.ts b/app/api/files/[...path]/route.ts index f219f1e15..9c6458ed3 100644 --- a/app/api/files/[...path]/route.ts +++ b/app/api/files/[...path]/route.ts @@ -26,7 +26,7 @@ import { parseFormDataWithinLimit, parseJsonWithinLimit, RequestBodyTooLargeErro const IGNORED_NAMES = new Set([ "node_modules", ".git", ".next", "dist", "build", "__pycache__", ".turbo", ".cache", "coverage", ".pytest_cache", ".mypy_cache", - "target", "vendor", ".DS_Store", ".git", + "target", "vendor", ".DS_Store", ]); const IGNORED_SUFFIXES = [".pyc"]; @@ -412,6 +412,10 @@ export async function GET( return Response.json({ error: "Invalid file request type", code: "invalid_request_type" }, { status: 400 }); } const sessionId = searchParams.get("sessionId"); + // The explorer's "Show hidden items" toggle: for `type=list` only, skip the + // IGNORED_NAMES/IGNORED_SUFFIXES skip-list so build/ and friends can be + // browsed. Everything else (reads, downloads) never applied it anyway. + const showHidden = searchParams.get("hidden") === "1"; const access = await authorizeFileAccess(segments, sessionId, type !== "list"); if (!access.ok) { @@ -516,7 +520,7 @@ export async function GET( const readDirectorySync = Reflect.get(fs, "readdirSync") as typeof fs.readdirSync; const dirents = readDirectorySync(filePath, { withFileTypes: true }); const entries = dirents - .filter((d) => !IGNORED_NAMES.has(d.name) && !IGNORED_SUFFIXES.some((s) => d.name.endsWith(s))) + .filter((d) => showHidden || (!IGNORED_NAMES.has(d.name) && !IGNORED_SUFFIXES.some((s) => d.name.endsWith(s)))) .flatMap((d) => { const isDir = resolveDirentIsDirectory(d, path.join(filePath, d.name)); return isDir === null diff --git a/components/AppShell.tsx b/components/AppShell.tsx index c6056ccdf..1a2009e84 100644 --- a/components/AppShell.tsx +++ b/components/AppShell.tsx @@ -109,6 +109,9 @@ const EXPAND_THINKING_STORAGE_KEY = "omp-web:expand-thinking"; const PROVIDER_USAGE_VISIBLE_STORAGE_KEY = "omp-web:provider-usage-visible"; const NATIVE_SELECT_ALL_STORAGE_KEY = "omp-web:scope-native-select-all"; const OPEN_URL_AUTOMATICALLY_STORAGE_KEY = "omp-web:open-url-automatically"; +// Off by default, so the Explorer keeps hiding build/, node_modules/ and the +// other IGNORED_NAMES directories until the toolbar switch is flipped. +const SHOW_HIDDEN_FILES_STORAGE_KEY = "omp-web:show-hidden-files"; type AutoNameStatus = @@ -180,6 +183,7 @@ export function AppShell({ appName }: { appName: string }) { const [providerUsageVisible, setProviderUsageVisible] = useState(true); const [scopeNativeSelectAll, setScopeNativeSelectAll] = useState(false); const [openUrlAutomatically, setOpenUrlAutomatically] = useState(false); + const [showHiddenFiles, setShowHiddenFiles] = useState(false); const [sidebarResizing, setSidebarResizing] = useState(false); // Active drag handlers so an unmount mid-drag can detach them. const sidebarResizeHandlersRef = useRef<{ onMove: (ev: MouseEvent) => void; onUp: () => void } | null>(null); @@ -200,6 +204,7 @@ export function AppShell({ appName }: { appName: string }) { setProviderUsageVisible(window.localStorage.getItem(PROVIDER_USAGE_VISIBLE_STORAGE_KEY) !== "false"); setScopeNativeSelectAll(window.localStorage.getItem(NATIVE_SELECT_ALL_STORAGE_KEY) === "true"); setOpenUrlAutomatically(window.localStorage.getItem(OPEN_URL_AUTOMATICALLY_STORAGE_KEY) === "true"); + setShowHiddenFiles(window.localStorage.getItem(SHOW_HIDDEN_FILES_STORAGE_KEY) === "true"); } catch { // Keep the compact default when storage is unavailable. } @@ -268,6 +273,17 @@ export function AppShell({ appName }: { appName: string }) { // The preference still applies for this page load. } }, []); + const handleToggleShowHiddenFiles = useCallback(() => { + setShowHiddenFiles((prev) => { + const next = !prev; + try { + window.localStorage.setItem(SHOW_HIDDEN_FILES_STORAGE_KEY, String(next)); + } catch { + // The preference still applies for this page load. + } + return next; + }); + }, []); // Persist the committed width (after each change; skipped mid-drag, then // written once the drag ends). The first run is skipped so the mount-time // default cannot overwrite the stored width before it is loaded. @@ -2660,6 +2676,8 @@ export function AppShell({ appName }: { appName: string }) { fileSearchOpen={fileSearchOpen} onToggleFileSearch={handleToggleFileSearch} onFileSearchOpenChange={setFileSearchOpen} + showHiddenFiles={showHiddenFiles} + onToggleShowHiddenFiles={handleToggleShowHiddenFiles} explorerUploadBusy={explorerUploadBusy} onUploadBusyChange={setExplorerUploadBusy} explorerGitCount={explorerGitCount} diff --git a/components/FileExplorer.tsx b/components/FileExplorer.tsx index d257878f2..c5ff22684 100644 --- a/components/FileExplorer.tsx +++ b/components/FileExplorer.tsx @@ -57,6 +57,8 @@ interface Props { onRefreshDone?: () => void; fileSearchOpen?: boolean; onFileSearchOpenChange?: (open: boolean) => void; + /** List the IGNORED_NAMES directories (build/, dist/, …) the tree hides by default. */ + showHidden?: boolean; /** Absolute path of the file open in the right panel — rendered selected. */ activeFilePath?: string | null; /** Absolute path to expand, highlight, and scroll into view (one-shot). */ @@ -100,9 +102,9 @@ interface PendingConflict { nonReplaceable: string[]; } -async function fetchEntries(dirPath: string): Promise { +async function fetchEntries(dirPath: string, showHidden: boolean): Promise { const encoded = encodeFilePathForApi(dirPath); - const res = await fetch(`/api/files/${encoded}?type=list`); + const res = await fetch(`/api/files/${encoded}?type=list${showHidden ? "&hidden=1" : ""}`); if (!res.ok) { let message = translate("fileExplorer.loadFailed", { status: res.status }); try { @@ -512,6 +514,7 @@ export const FileExplorer = forwardRef(function FileE onRefreshDone, fileSearchOpen = false, onFileSearchOpenChange, + showHidden = false, activeFilePath = null, revealPath = null, onRevealDone, @@ -549,6 +552,15 @@ export const FileExplorer = forwardRef(function FileE const uploadInputRef = useRef(null); const scrollRef = useRef(null); const loadingPathsRef = useRef>(new Set()); + // Listing generation: advanced whenever every cached listing is dropped + // (cwd change, hidden-items flip). An in-flight fetch carries the + // generation it started on; a response of an older one is discarded, so it + // cannot repopulate the cleared map, resurrect the hidden-item mode it + // listed, or clear the new request's loading state. + const listingGenerationRef = useRef(0); + // Last hidden-items mode the listing cache was built for (see the flip + // effect below); initialised to the mount value so mounting never counts. + const prevShowHiddenRef = useRef(showHidden); const rootRequestRef = useRef(0); const expandedPathsRef = useRef>(new Set()); expandedPathsRef.current = expandedPaths; @@ -707,10 +719,16 @@ export const FileExplorer = forwardRef(function FileE // against duplicate in-flight requests; the state copy drives spinners. const fetchDir = useCallback((dirPath: string) => { if (loadingPathsRef.current.has(dirPath)) return Promise.resolve(); + const generation = listingGenerationRef.current; + // The shared loading bookkeeping belongs to the current generation only: + // a superseded response must neither clear the current request's spinner + // nor touch the ref the new dedupe guard reads. + const isCurrent = () => listingGenerationRef.current === generation; loadingPathsRef.current.add(dirPath); setLoadingPaths((prev) => new Set(prev).add(dirPath)); - return fetchEntries(dirPath) + return fetchEntries(dirPath, showHidden) .then((entries) => { + if (!isCurrent()) return; setChildrenByPath((prev) => { const next = new Map(prev); next.set(dirPath, entries); @@ -719,9 +737,10 @@ export const FileExplorer = forwardRef(function FileE if (dirPath === cwd) setError(null); }) .catch((e) => { - if (dirPath === cwd) setError(e instanceof Error ? e.message : String(e)); + if (isCurrent() && dirPath === cwd) setError(e instanceof Error ? e.message : String(e)); }) .finally(() => { + if (!isCurrent()) return; loadingPathsRef.current.delete(dirPath); setLoadingPaths((prev) => { const next = new Set(prev); @@ -729,7 +748,7 @@ export const FileExplorer = forwardRef(function FileE return next; }); }); - }, [cwd]); + }, [cwd, showHidden]); // Scroll the virtual window so a row is visible, then focus it. The focus // retries across frames: the scroll triggers an async window re-render and @@ -971,6 +990,8 @@ export const FileExplorer = forwardRef(function FileE // Reset expanded state only when cwd changes, not on refreshKey bumps if (cwdChanged) { + // Supersede in-flight listings of the previous directory too. + listingGenerationRef.current += 1; setExpandedPaths(new Set()); setHighlightedPaths(new Set()); setUploadSummary(null); @@ -1003,6 +1024,23 @@ export const FileExplorer = forwardRef(function FileE // eslint-disable-next-line react-hooks/exhaustive-deps }, [cwd, refreshKey, treeRefreshKey]); + // Flipping "Show hidden items" changes what every listing returns, so no + // cached directory listing may survive it: drop the map (the root and every + // expanded directory are then re-fetched by the effects above — the cached + // listings of collapsed directories would otherwise be served stale when + // they expand) and supersede the generation, so listings still in flight + // from the previous mode are discarded instead of repopulating the map. + // Expansion state is deliberately kept. + useEffect(() => { + if (prevShowHiddenRef.current === showHidden) return; + prevShowHiddenRef.current = showHidden; + listingGenerationRef.current += 1; + setChildrenByPath(new Map()); + loadingPathsRef.current = new Set(); + setLoadingPaths(new Set()); + setTreeRefreshKey((key) => key + 1); + }, [showHidden]); + // Fetch any expanded directory that has no listing yet. Clicks, keyboard, // and reveal all funnel through expandedPaths, so this single effect covers // every expansion path — including levels that mount while a reveal diff --git a/components/RightPanel.tsx b/components/RightPanel.tsx index 91aae9403..4d32c6509 100644 --- a/components/RightPanel.tsx +++ b/components/RightPanel.tsx @@ -6,6 +6,7 @@ import { ChevronsDownUp, Copy, Download, + Eye, FileX, Files, Folder, @@ -51,6 +52,9 @@ interface Props { fileSearchOpen: boolean; onToggleFileSearch: () => void; onFileSearchOpenChange: (open: boolean) => void; + /** Explorer tree includes the directories hidden by default (build/, dist/, …). */ + showHiddenFiles: boolean; + onToggleShowHiddenFiles: () => void; explorerUploadBusy: boolean; onUploadBusyChange: (busy: boolean) => void; explorerGitCount: number; @@ -103,6 +107,8 @@ export const RightPanel = memo(function RightPanel({ fileSearchOpen, onToggleFileSearch, onFileSearchOpenChange, + showHiddenFiles, + onToggleShowHiddenFiles, explorerUploadBusy, onUploadBusyChange, explorerGitCount, @@ -228,6 +234,17 @@ export const RightPanel = memo(function RightPanel({ >