fix(clodex): isolate file tree diff by workspace - #136
Draft
mereyabdenbekuly-ctrl wants to merge 1 commit into
Draft
fix(clodex): isolate file tree diff by workspace#136mereyabdenbekuly-ctrl wants to merge 1 commit into
mereyabdenbekuly-ctrl wants to merge 1 commit into
Conversation
Signed-off-by: Merey Abdenbekuly <234955825+mereyabdenbekuly-ctrl@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
No separate issue: this is a bounded, reproducible local UI bug found during repository review. The regression tests below specify the intended outcome.
Contribution category
Components and registry status:
browser-legacy(apps/browser/**), status remainslegacy, ownerdesktop.Artifact classification: All four changed/new files are PUBLIC CORE: the existing sidebar, its workspace-scoped diff-state helper, and synthetic unit/component tests. No private product code, restricted data, dependency, license, registry-status, or public protocol change.
Verification state:
IMPLEMENTED_UNVERIFIEDpending GitHub CI, desktop visual evidence, and maintainer review. This is a Draft PR, not merge or release authorization.Problem and outcome
Opening project A's Diff and then selecting project B while its Git-summary request is pending retains A's rows and totals. The click handler already uses B's workspace key, so a row from A can open the same relative path in B. A file preview can likewise survive a workspace switch, and removing all workspaces during a request can leave the loading state stuck.
After this change, Diff data and previews are scoped to the workspace that produced them. Switching projects hides the previous project's rows, totals, and preview immediately. Same-workspace refreshes retain their existing summary without flicker. File-tree state is not remounted, preserving the existing cross-workspace clipboard behavior.
Scope boundaries
In scope
file-tree-sidebar.tsx: workspace-scoped diff and preview presentation; existing request cancellation.file-tree-diff-state.ts: pure selection of the current workspace's diff snapshot/loading state.Out of scope
Implementation summary
workspaceKey.FileTreeWorkspaceViewinstance rather than using a keyed remount that would discard its cross-workspace clipboard.Risk assessment
Risk level: Low, limited to transient renderer state and existing async request presentation.
Rollback or recovery plan: Revert the single functional commit
2e81568963180787cb612473db600691d6355be4. No data migration is needed; the previous stale-Diff/preview behavior returns.Source of truth before this PR: Unscoped component-local summary and preview path paired with whichever workspace is currently selected.
Source of truth after this PR: A completed summary/preview plus its originating workspace key; only matching state is presented.
Tests and verification
pnpm install --offline --frozen-lockfile --ignore-scripts --package-import-method=clonepnpm build:packagespnpm --dir apps/browser exec vitest run src/uipnpm --dir apps/browser exec vitest run src/ui/screens/main/file-tree/file-tree-sidebar.test.ts src/ui/screens/main/file-tree/file-tree-diff-state.test.tspnpm --dir apps/browser exec tsc -p tsconfig.ui.json --noEmitpnpm -F clodex typecheck(agent-core/shell rebuilt, then UI/pages/backend/preload/storybook/visual TypeScript)pnpm check, browser typecheck, commitlintpnpm check:boundaries && pnpm check:community-free-boundary && pnpm check:protocol-v0-governance && pnpm check:provenancescripts/security/scan-secrets.sh working-treewith an external temporary report pathgit diff --checkand staged-path inspectionGitHub CI blocker confirmed on this commit: PR lint job and push lint job both report: “The job was not started because your account is locked due to a billing issue.” Local hooks/tests passed, but this does not replace remote CI.
User evidence
Synthetic before/after evidence from the actual sidebar component tests:
The tests also cover out-of-order workspace and revision responses, A -> B -> A switching, current-workspace refresh, fallback selection, request errors, correct target workspace for row clicks, and preservation of the file-view instance. A packaged-desktop screenshot/recording has not been collected; this PR remains Draft while that evidence and CI/review are pending.
Documentation
No user-facing setting, environment variable, external dependency, API, stored format, or migration is introduced. Source comments and regression tests document the invariant. Release notes are deferred to an authorized release.
Upstream and third-party attribution
No external implementation or assets were copied. This is a compatibility fix to the existing public repository, not an independent replacement; existing copyrights, attribution, and licenses are unchanged.
Provenance and AI assistance
Sources used: The public repository's contribution/provenance/boundary rules, existing sidebar and file-tree code, workspace identity contract, Karton procedure proxy, and existing React/Vitest testing setup.
Other implementations inspected: None outside the existing public repository.
AI assistance: OpenAI Codex assisted with diagnosis, the public-core implementation, synthetic regression tests, local verification, independent read-only review, and PR preparation. No private implementation, credentials, customer prompts/data, or restricted fixtures were used for this change.
Contributor checklist
Signed-off-bytrailer.