diff --git a/src/components/layout/aux-panel-file-tree-tab.tsx b/src/components/layout/aux-panel-file-tree-tab.tsx index b6dd391..b151c1a 100644 --- a/src/components/layout/aux-panel-file-tree-tab.tsx +++ b/src/components/layout/aux-panel-file-tree-tab.tsx @@ -94,7 +94,6 @@ function baseName(path: string): string { const FILE_TREE_ROOT_PATH = "__workspace_root__" const GITIGNORE_MUTED_CLASS = "text-muted-foreground/55" -const FILE_TREE_LAZY_DEBUG_LOG = process.env.NODE_ENV === "development" interface FileActionTarget { kind: "file" | "dir" @@ -129,30 +128,6 @@ function normalizeComparePath(path: string): string { return path.replace(/\\/g, "/").replace(/\/+$/, "") } -function logFileTreeLazyDebug( - message: string, - payload?: Record -) { - if (!FILE_TREE_LAZY_DEBUG_LOG) return - if (payload) { - console.info(`[FileTreeTab/lazy] ${message}`, payload) - return - } - console.info(`[FileTreeTab/lazy] ${message}`) -} - -function logFileTreeWorkspaceDebug( - message: string, - payload?: Record -) { - if (!FILE_TREE_LAZY_DEBUG_LOG) return - if (payload) { - console.info(`[FileTreeTab/workspace] ${message}`, payload) - return - } - console.info(`[FileTreeTab/workspace] ${message}`) -} - function prefixFileTreeNodePaths( nodes: FileTreeNode[], prefix: string @@ -1013,15 +988,6 @@ export function FileTreeTab() { workspaceState.health === "resyncing" && workspaceState.seq === 0 ) setError(workspaceState.health === "degraded" ? workspaceState.error : null) - - logFileTreeWorkspaceDebug("workspace state consumed", { - rootPath: folder?.path ?? "", - seq: workspaceState.seq, - health: workspaceState.health, - treeRoots: workspaceState.tree.length, - gitEntries: workspaceState.git.length, - lazyOverrideDirs: lazyLoadedChildrenByPathRef.current.size, - }) }, [ folder?.path, workspaceState.error, @@ -1037,20 +1003,8 @@ export function FileTreeTab() { if (!rootPath) return const normalizedDirPath = normalizeComparePath(dirPath) if (!normalizedDirPath) return - if (lazyLoadedChildrenByPathRef.current.has(normalizedDirPath)) { - logFileTreeLazyDebug("skip cached", { - rootPath, - dirPath: normalizedDirPath, - }) - return - } - if (lazyLoadingDirPathsRef.current.has(normalizedDirPath)) { - logFileTreeLazyDebug("skip in-flight", { - rootPath, - dirPath: normalizedDirPath, - }) - return - } + if (lazyLoadedChildrenByPathRef.current.has(normalizedDirPath)) return + if (lazyLoadingDirPathsRef.current.has(normalizedDirPath)) return const existingChildren = findDirectoryChildren(nodes, normalizedDirPath) if (existingChildren && existingChildren.length > 0) { @@ -1058,20 +1012,10 @@ export function FileTreeTab() { normalizedDirPath, existingChildren ) - logFileTreeLazyDebug("skip use existing children", { - rootPath, - dirPath: normalizedDirPath, - childrenCount: existingChildren.length, - }) return } lazyLoadingDirPathsRef.current.add(normalizedDirPath) - const startedAt = performance.now() - logFileTreeLazyDebug("request start", { - rootPath, - dirPath: normalizedDirPath, - }) try { const subtree = await getFileTree( joinFsPath(rootPath, normalizedDirPath), @@ -1082,19 +1026,8 @@ export function FileTreeTab() { setNodes((prev) => applyLazyTreeOverrides(prev, lazyLoadedChildrenByPathRef.current) ) - logFileTreeLazyDebug("request success", { - rootPath, - dirPath: normalizedDirPath, - childrenCount: prefixed.length, - durationMs: Math.round(performance.now() - startedAt), - }) } catch { // Ignore lazy load failures and keep current collapsed/empty state. - logFileTreeLazyDebug("request failed", { - rootPath, - dirPath: normalizedDirPath, - durationMs: Math.round(performance.now() - startedAt), - }) } finally { lazyLoadingDirPathsRef.current.delete(normalizedDirPath) } @@ -1107,10 +1040,6 @@ export function FileTreeTab() { for (const path of expandedPaths) { if (path === FILE_TREE_ROOT_PATH) continue if (previousExpanded.has(path)) continue - logFileTreeLazyDebug("expanded path detected", { - rootPath: folder?.path ?? "", - dirPath: path, - }) void loadDirectoryChildren(path) } previousExpandedPathsRef.current = new Set(expandedPaths) diff --git a/src/components/layout/aux-panel-git-changes-tab.tsx b/src/components/layout/aux-panel-git-changes-tab.tsx index 40db0a8..70ef28b 100644 --- a/src/components/layout/aux-panel-git-changes-tab.tsx +++ b/src/components/layout/aux-panel-git-changes-tab.tsx @@ -115,19 +115,6 @@ interface MutableChangeTreeDirNode { const TRACKED_ROOT_PATH = "__working_tree_tracked_root__" const UNTRACKED_ROOT_PATH = "__working_tree_untracked_root__" const UNTRACKED_STATUS = "??" -const GIT_CHANGES_DEBUG_LOG = process.env.NODE_ENV === "development" - -function logGitChangesDebug( - message: string, - payload?: Record -) { - if (!GIT_CHANGES_DEBUG_LOG) return - if (payload) { - console.info(`[GitChangesTab/workspace] ${message}`, payload) - return - } - console.info(`[GitChangesTab/workspace] ${message}`) -} type GitFileState = | "untracked" @@ -545,24 +532,6 @@ export function GitChangesTab() { [expandedUntrackedPaths.size, untrackedTreeNodes.length] ) - useEffect(() => { - logGitChangesDebug("workspace state consumed", { - rootPath: folder?.path ?? "", - seq: workspaceState.seq, - health: workspaceState.health, - gitEntries: workspaceState.git.length, - trackedChanges: trackedChanges.length, - untrackedChanges: untrackedChanges.length, - }) - }, [ - folder?.path, - trackedChanges.length, - untrackedChanges.length, - workspaceState.git.length, - workspaceState.health, - workspaceState.seq, - ]) - const toggleTrackedExpanded = useCallback(() => { if (trackedCanExpand) { setExpandedTrackedPaths(new Set(allTrackedDirectoryPaths)) diff --git a/src/hooks/use-workspace-state-store.ts b/src/hooks/use-workspace-state-store.ts index 739f9d4..66fbbc9 100644 --- a/src/hooks/use-workspace-state-store.ts +++ b/src/hooks/use-workspace-state-store.ts @@ -35,7 +35,6 @@ export interface WorkspaceStateResult extends WorkspaceStateView { const WORKSPACE_PROTOCOL_VERSION = 1 const STORE_EVICT_DELAY_MS = 120_000 const STORE_SHUTDOWN_GRACE_MS = 600 -const WORKSPACE_DEBUG_LOG = process.env.NODE_ENV === "development" const EMPTY_STATE: WorkspaceStateView = { rootPath: "", @@ -56,38 +55,6 @@ function toErrorMessage(error: unknown): string { return String(error) } -function logWorkspaceDebug(message: string, payload?: Record) { - if (!WORKSPACE_DEBUG_LOG) return - if (payload) { - console.info(`[WorkspaceStateStore] ${message}`, payload) - return - } - console.info(`[WorkspaceStateStore] ${message}`) -} - -function summarizeSnapshot(snapshot: WorkspaceSnapshotResponse) { - return { - rootPath: snapshot.root_path, - seq: snapshot.seq, - full: snapshot.full, - deltas: snapshot.deltas.length, - treeRoots: snapshot.tree_snapshot?.length ?? 0, - gitEntries: snapshot.git_snapshot?.length ?? 0, - } -} - -function summarizeEvent(event: WorkspaceStateEvent, localSeq: number) { - return { - rootPath: event.root_path, - kind: event.kind, - eventSeq: event.seq, - localSeq, - requiresResync: event.requires_resync, - payloadKinds: event.payload.map((delta) => delta.kind), - payloadCount: event.payload.length, - } -} - function applyDeltaToState( state: WorkspaceStateView, delta: WorkspaceDelta @@ -198,11 +165,6 @@ class WorkspaceStateStore { this.cancelPendingShutdown() this.cancelEviction() this.refCount += 1 - logWorkspaceDebug("acquire", { - rootPath: this.rootPath, - refCount: this.refCount, - started: this.started, - }) if (this.refCount === 1) { const canReuseLifecycle = this.lifecycleId > 0 && @@ -218,11 +180,6 @@ class WorkspaceStateStore { release = () => { if (this.refCount === 0) return this.refCount -= 1 - logWorkspaceDebug("release", { - rootPath: this.rootPath, - refCount: this.refCount, - started: this.started, - }) if (this.refCount === 0) { const lifecycleId = this.lifecycleId this.scheduleShutdown(lifecycleId) @@ -231,16 +188,9 @@ class WorkspaceStateStore { requestResync = async (reason?: string) => { void reason - if (this.resyncInFlight) { - logWorkspaceDebug("requestResync skip in-flight", { - rootPath: this.rootPath, - reason: reason ?? "unknown", - }) - return this.resyncInFlight - } + if (this.resyncInFlight) return this.resyncInFlight const run = async () => { - const startedAt = performance.now() this.patchState((prev) => ({ ...prev, health: "resyncing", @@ -248,33 +198,17 @@ class WorkspaceStateStore { try { const sinceSeq = this.hasBaselineSnapshot ? this.state.seq : undefined - logWorkspaceDebug("requestResync start", { - rootPath: this.rootPath, - reason: reason ?? "unknown", - sinceSeq: sinceSeq ?? null, - }) const snapshot = await getWorkspaceSnapshot(this.rootPath, sinceSeq) this.patchState((prev) => applySnapshot(prev, snapshot)) if (snapshot.full) { this.hasBaselineSnapshot = true } - logWorkspaceDebug("requestResync success", { - ...summarizeSnapshot(snapshot), - reason: reason ?? "unknown", - durationMs: Math.round(performance.now() - startedAt), - }) } catch (error) { this.patchState((prev) => ({ ...prev, health: "degraded", error: toErrorMessage(error), })) - logWorkspaceDebug("requestResync failed", { - rootPath: this.rootPath, - reason: reason ?? "unknown", - durationMs: Math.round(performance.now() - startedAt), - error: toErrorMessage(error), - }) } } @@ -305,27 +239,13 @@ class WorkspaceStateStore { } try { - const streamStartedAt = performance.now() - logWorkspaceDebug("ensureStarted start stream", { - rootPath: this.rootPath, - lifecycleId, - }) const initialSnapshot = await startWorkspaceStateStream(this.rootPath) if (!this.isLifecycleActive(lifecycleId)) { await stopWorkspaceStateStream(this.rootPath).catch(() => {}) - logWorkspaceDebug("ensureStarted aborted after initial snapshot", { - rootPath: this.rootPath, - lifecycleId, - }) return } this.patchState((prev) => applySnapshot(prev, initialSnapshot)) this.hasBaselineSnapshot = true - logWorkspaceDebug("ensureStarted initial snapshot", { - ...summarizeSnapshot(initialSnapshot), - lifecycleId, - durationMs: Math.round(performance.now() - streamStartedAt), - }) const unlisten = await subscribe( "folder://workspace-state-event", @@ -338,10 +258,6 @@ class WorkspaceStateStore { this.handleEvent(event) } ) - logWorkspaceDebug("ensureStarted subscribe ready", { - rootPath: this.rootPath, - lifecycleId, - }) if (!this.isLifecycleActive(lifecycleId)) { unlisten() @@ -351,35 +267,18 @@ class WorkspaceStateStore { this.unlisten = unlisten this.started = true - const catchUpStartedAt = performance.now() const catchUpSnapshot = await getWorkspaceSnapshot( this.rootPath, this.state.seq ) - if (!this.isLifecycleActive(lifecycleId)) { - logWorkspaceDebug("ensureStarted aborted after catch-up snapshot", { - rootPath: this.rootPath, - lifecycleId, - }) - return - } + if (!this.isLifecycleActive(lifecycleId)) return this.patchState((prev) => applySnapshot(prev, catchUpSnapshot)) - logWorkspaceDebug("ensureStarted catch-up snapshot", { - ...summarizeSnapshot(catchUpSnapshot), - lifecycleId, - durationMs: Math.round(performance.now() - catchUpStartedAt), - }) } catch (error) { this.patchState((prev) => ({ ...prev, health: "degraded", error: toErrorMessage(error), })) - logWorkspaceDebug("ensureStarted failed", { - rootPath: this.rootPath, - lifecycleId, - error: toErrorMessage(error), - }) } } @@ -393,10 +292,6 @@ class WorkspaceStateStore { private shutdown = async (lifecycleId: number) => { void lifecycleId this.started = false - logWorkspaceDebug("shutdown", { - rootPath: this.rootPath, - lifecycleId, - }) const unlisten = this.unlisten this.unlisten = null if (unlisten) { @@ -415,14 +310,7 @@ class WorkspaceStateStore { this.cancelPendingShutdown() this.shutdownTimer = setTimeout(() => { this.shutdownTimer = null - if (this.refCount !== 0) { - logWorkspaceDebug("shutdown grace canceled by new acquire", { - rootPath: this.rootPath, - lifecycleId, - refCount: this.refCount, - }) - return - } + if (this.refCount !== 0) return const dispose = async () => { await this.shutdown(lifecycleId) } @@ -465,26 +353,12 @@ class WorkspaceStateStore { } private handleEvent = (event: WorkspaceStateEvent) => { - logWorkspaceDebug("event received", summarizeEvent(event, this.state.seq)) - if (event.version !== WORKSPACE_PROTOCOL_VERSION) { - logWorkspaceDebug("event version mismatch", { - rootPath: this.rootPath, - eventVersion: event.version, - expectedVersion: WORKSPACE_PROTOCOL_VERSION, - }) void this.requestResync("version_mismatch") return } if (event.requires_resync || event.seq !== this.state.seq + 1) { - logWorkspaceDebug("event requires resync", { - rootPath: this.rootPath, - kind: event.kind, - eventSeq: event.seq, - localSeq: this.state.seq, - requiresResync: event.requires_resync, - }) void this.requestResync("seq_gap_or_hint") return } @@ -502,13 +376,6 @@ class WorkspaceStateStore { health: "healthy", error: null, })) - - logWorkspaceDebug("event applied", { - rootPath: event.root_path, - seq: event.seq, - treeRoots: next.tree.length, - gitEntries: next.git.length, - }) } private patchState = (