Skip to content

Inspector scope picker: folder-first workspace selection - #81

Open
dix105 wants to merge 10 commits into
v3-harshfrom
feat/inspector-scope-picker
Open

Inspector scope picker: folder-first workspace selection#81
dix105 wants to merge 10 commits into
v3-harshfrom
feat/inspector-scope-picker

Conversation

@dix105

@dix105 dix105 commented May 27, 2026

Copy link
Copy Markdown
Collaborator

What

Implements the planned inspector scope picker — folder-first workspace selection for each chat, with Git as optional metadata.

Scope model

Every chat gets one InspectorScope:

  • unset — show picker (direct chats without stored scope)
  • global — explicit global workspace
  • project — scoped to a project folder

Rules:

  • Topic/project chats always use their project scope
  • Direct chats load stored scope from localStorage (keyed by sessionKey)
  • global is explicit, never a silent fallback
  • Workspace + Git share the same scope

New files

  • inspectorScope.ts — scope type, storage, helpers
  • inspectorScope.test.ts — 7 tests (all passing)
  • InspectorScopePicker.tsx — folder browser picker with:
    • Two-column layout (sources + folder tree)
    • Lazy-loaded folder expansion
    • Search/filter
    • Badges: Project / Git / No Git yet
    • Hidden folder toggle
    • Bottom bar: selected path, status, confirm
  • Middleware /api/folders/tree endpoint — returns folder metadata (hasGit, gitRoot, isProjectRoot, projectId, etc.)

Changes

  • workspace-api.ts: workspaceBasePath(null) now means real global workspace (not localStorage fallback)
  • AppPage.tsx: owns inspector scope state per chat, loads from storage, passes down
  • InspectorPanel/View: accept + forward scope
  • WorkspaceTab/GitTab: show picker when scope is unset

Tests

  • 15 inspector tests passing (7 new scope tests + 8 existing)
  • 1 pre-existing TS error (unrelated workspaceControls prop)

- Add InspectorScope model (unset/global/project) with per-session storage
- Add InspectorScopePicker: folder browser with lazy-load, search, badges
- Add /api/folders/tree middleware endpoint for folder browsing
- Fix workspace-api workspaceBasePath(null) to mean real global workspace
- Wire scope through AppPage -> InspectorPanel -> InspectorView -> tabs
- WorkspaceTab/GitTab show picker when direct chat scope is unset
- Project/topic chat scope always overrides stored direct-chat scope
- Reset git selection when scope changes
- Tests: 7 new tests for scope model (all passing, 15 total inspector)
@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
openclaw-desktop-ui Ignored Ignored Preview May 28, 2026 3:37am

Developer added 9 commits May 27, 2026 17:19
The early return for unset scope was placed BEFORE useState/useEffect
hooks. When switching between tabs with different scope states, React
saw different hook counts and silently broke — the tab highlighted
but content stopped updating.

Moved the guard after all hooks, matching GitTab's correct pattern.
GitTab's handleRepoSelect was setting both workspaceRoot and repoRoot
to the selected repo path. This destroyed the user's original workspace
folder choice when they picked a no-Git folder first, then connected
a different Git repo from the Git tab.

Now only updates repoRoot — workspace folder stays as chosen.
Preserves: Workspace = folder-first, Git = optional metadata.
- Remove Projects quick list from the picker sidebar
- Collapse picker to a single folder list
- Remove Project/Git/No Git badges from folder rows
- Use neutral grey folder icons
- Move Global Workspace into footer action row next to Cancel/Use
- Keep project detection behavior internally without visual noise
Normal chats should not each require connecting Workspace/Git.
They now default to the shared Global Workspace unless that chat
has an explicit stored scope. Project/topic chats remain project-scoped.
- Make workspace picker an explicit change action instead of first-screen blocking
- Add Workspace tab scope header with Global/Chat/Project labels
- Add Change folder and Reset to Global actions where appropriate
- Allow project workspace changes to update the existing project instead of creating a new one
- Reword Git empty states so Git manages repository only
- Add Change repository and Disconnect repository actions
- Preserve rule: Git updates repoRoot only, Workspace owns workspaceRoot
Remove the separate hover-preview closing timer so hover open/close uses the same width and content transition path as the header sidebar toggle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant