Skip to content

Conversation

@lucasheriques
Copy link
Contributor

@lucasheriques lucasheriques commented Nov 17, 2025

Summary

Creates the foundation for task-to-directory mappings with localStorage persistence. This store enables tasks to remember which directory they should run in, and allows multiple tasks to share a single clone of a repository.

Part of the task directory mapping refactor - this is PR #2 in a stack of 5 PRs.

Changes

  • New file: src/renderer/stores/taskDirectoryStore.ts
  • Two-level mapping:
    • taskDirectories: Direct task → directory assignments
    • repoDirectories: Repository → directory mappings (shared across tasks)
  • getTaskDirectory(): Checks task mapping first, falls back to repo mapping, auto-saves if found
  • Uses existing expandTildePath utility for tilde expansion
  • Persists to localStorage via Zustand persist middleware

Architecture

When resolving a directory for a task:

  1. Check taskDirectories[taskId] - direct mapping
  2. If not found and task has repo, check repoDirectories[repoKey] - shared clone
  3. If found in step 2, auto-map task to that directory for future lookups
  4. If not found, return null (will prompt user in future PRs)

Next Steps

PR #3 will integrate this store into the task execution flow.

Stack

Copy link
Contributor Author

lucasheriques commented Nov 17, 2025

@lucasheriques lucasheriques changed the title feat: add task directory mapping store Add task directory mapping store Nov 17, 2025
@lucasheriques lucasheriques changed the title Add task directory mapping store chore: Add task directory mapping store Nov 17, 2025
@lucasheriques lucasheriques marked this pull request as ready for review November 17, 2025 14:33
@lucasheriques lucasheriques requested a review from a team as a code owner November 17, 2025 14:33
lucasheriques added a commit that referenced this pull request Nov 17, 2025
When clicking "Run (Local)" without a directory set:
- Tasks WITH repository_config: Prompt "Do you have it locally?"
  → "I have it locally" opens folder picker
  → "Clone for me" triggers clone flow with progress UI
- Tasks WITHOUT repository_config: Prompt "Select working directory"
  → Opens folder picker

Cloud mode changes:
- Disable Cloud mode toggle for tasks without repository_config
- Show tooltip: "Cloud mode requires a connected repository"

Technical changes:
- Updated runTask() in taskExecutionStore to prompt before showing error
- Integrated with existing clone flow and progress UI (PR #128)
- Persist selected directories via taskDirectoryStore (PR #130, #131)
- Removed noisy directory source badges (simplified UX)

This creates a frictionless flow where engineers can easily point to
existing repos or clone them on-demand, while still supporting
directory-only tasks for non-git workflows.
lucasheriques added a commit that referenced this pull request Nov 17, 2025
When clicking "Run (Local)" without a directory set:
- Tasks WITH repository_config: Prompt "Do you have it locally?"
  → "I have it locally" opens folder picker
  → "Clone for me" triggers clone flow with progress UI
- Tasks WITHOUT repository_config: Prompt "Select working directory"
  → Opens folder picker

Cloud mode changes:
- Disable Cloud mode toggle for tasks without repository_config
- Show tooltip: "Cloud mode requires a connected repository"

Technical changes:
- Updated runTask() in taskExecutionStore to prompt before showing error
- Integrated with existing clone flow and progress UI (PR #128)
- Persist selected directories via taskDirectoryStore (PR #130, #131)
- Removed noisy directory source badges (simplified UX)

This creates a frictionless flow where engineers can easily point to
existing repos or clone them on-demand, while still supporting
directory-only tasks for non-git workflows.
@lucasheriques lucasheriques force-pushed the feat/task-directory-store branch from eb783d3 to eea62c0 Compare November 17, 2025 21:20
lucasheriques added a commit that referenced this pull request Nov 18, 2025
When clicking "Run (Local)" without a directory set:
- Tasks WITH repository_config: Prompt "Do you have it locally?"
  → "I have it locally" opens folder picker
  → "Clone for me" triggers clone flow with progress UI
- Tasks WITHOUT repository_config: Prompt "Select working directory"
  → Opens folder picker

Cloud mode changes:
- Disable Cloud mode toggle for tasks without repository_config
- Show tooltip: "Cloud mode requires a connected repository"

Technical changes:
- Updated runTask() in taskExecutionStore to prompt before showing error
- Integrated with existing clone flow and progress UI (PR #128)
- Persist selected directories via taskDirectoryStore (PR #130, #131)
- Removed noisy directory source badges (simplified UX)

This creates a frictionless flow where engineers can easily point to
existing repos or clone them on-demand, while still supporting
directory-only tasks for non-git workflows.
@lucasheriques lucasheriques force-pushed the feat/task-directory-store branch from eea62c0 to d0bfba0 Compare November 18, 2025 11:37
Copy link
Contributor Author

lucasheriques commented Nov 18, 2025

Merge activity

  • Nov 18, 11:39 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 18, 11:40 AM UTC: Graphite rebased this pull request as part of a merge.
  • Nov 18, 11:41 AM UTC: @lucasheriques merged this pull request with Graphite.

@lucasheriques lucasheriques changed the base branch from feat/clone-progress-ui to graphite-base/130 November 18, 2025 11:39
@lucasheriques lucasheriques changed the base branch from graphite-base/130 to main November 18, 2025 11:39
- Create taskDirectoryStore with localStorage persistence
- Support two-level mapping (taskId → dir, repoKey → dir)
- Auto-map tasks to existing repo clones
- Use existing expandTildePath utility

Foundation for PR #3 (directory integration).
@lucasheriques lucasheriques force-pushed the feat/task-directory-store branch from d0bfba0 to 7804c3e Compare November 18, 2025 11:40
@lucasheriques lucasheriques merged commit f801277 into main Nov 18, 2025
9 of 10 checks passed
@lucasheriques lucasheriques deleted the feat/task-directory-store branch November 18, 2025 11:41
lucasheriques added a commit that referenced this pull request Nov 18, 2025
## Summary
- Integrates `taskDirectoryStore` into task execution flow
- Tasks now check stored directory mappings before deriving paths from workspace
- Persists directory assignments when repos are set or cloned
- Enables per-task directory customization and repo sharing across tasks

## Changes
- **`taskExecutionStore.ts`**: Updated `initializeRepoPath()` to check `taskDirectoryStore` first, then fall back to workspace-based derivation. Updated `setRepoPath()` to persist task→directory mapping.
- **`cloneStore.ts`**: Updated `handleComplete()` to save repo→directory mapping after successful clone for future task reuse.

## Test Plan
- [ ] Clone a repo for a task → verify mapping is saved
- [ ] Run another task with the same repo → verify it reuses the cloned directory
- [ ] Manually set a directory for a task → verify it persists across app restarts
- [ ] Verify tasks without `repository_config` still work

---
**Stack**: Built on top of:
- PR #128: Clone progress UI
- PR #130: Task directory store foundation
lucasheriques added a commit that referenced this pull request Nov 18, 2025
When clicking "Run (Local)" without a directory set:
- Tasks WITH repository_config: Prompt "Do you have it locally?"
  → "I have it locally" opens folder picker
  → "Clone for me" triggers clone flow with progress UI
- Tasks WITHOUT repository_config: Prompt "Select working directory"
  → Opens folder picker

Cloud mode changes:
- Disable Cloud mode toggle for tasks without repository_config
- Show tooltip: "Cloud mode requires a connected repository"

Technical changes:
- Updated runTask() in taskExecutionStore to prompt before showing error
- Integrated with existing clone flow and progress UI (PR #128)
- Persist selected directories via taskDirectoryStore (PR #130, #131)
- Removed noisy directory source badges (simplified UX)

This creates a frictionless flow where engineers can easily point to
existing repos or clone them on-demand, while still supporting
directory-only tasks for non-git workflows.
lucasheriques added a commit that referenced this pull request Nov 18, 2025
## Summary

Implements the frictionless directory selection flow: when clicking "Run" without a directory set, Array prompts the user to either select an existing directory or clone the repository.

## User Flow

### For tasks WITH `repository_config`:

When user clicks "Run (Local)" without a directory:

1. **Prompt**: "Do you have `org/repo` locally?"
2. **Options**:
    - **"I have it locally"** → Opens native folder picker → Saves mapping → Runs task
    - **"Clone for me"** → Triggers clone with progress UI → Saves mapping → User clicks Run again after clone
    - **"Cancel"** → Returns to task detail

### For tasks WITHOUT `repository_config`:

When user clicks "Run (Local)" without a directory:

1. **Prompt**: "Select a working directory for this task"
2. **Opens folder picker** → Saves mapping → Runs task

### Invalid Directory Handling:

- If user selects an invalid directory → Validation fails silently → Prompt appears again
- No error spam, seamless recovery
- User can clear directory with X button and retry

### Working Directory Field:

- Shows **actual** directory that will be used (not derived fallback)
- Empty with "Not set - click Run to select" when no directory
- Clear button (X) appears only when directory is set

### Cloud Mode Gating:

- Cloud mode toggle is **disabled** for tasks without `repository_config`
- Tooltip explains: "Cloud mode requires a connected repository"

## Benefits

1. **Frictionless onboarding**: No upfront workspace configuration required
2. **Supports existing workflows**: Engineers can point to repos they already have cloned
3. **On-demand cloning**: Clone only when needed, with visual progress
4. **Flexible**: Supports both git-based and directory-only tasks
5. **Persistent**: Directory mappings survive app restarts
6. **Graceful recovery**: Invalid paths automatically re-prompt instead of erroring
7. **Clear UI**: Always shows what will actually be used

## Test Plan

- [x] Task with repo, no directory set → Prompt appears with 3 buttons
- [x] "I have it locally" → Folder picker opens → Selection persists
- [x] "Clone for me" → Clone progress shows → Directory saved after clone
- [x] Task without repo → Prompt shows "Select directory" with 2 buttons
- [x] Cloud mode disabled when no `repository_config` → Tooltip shows
- [x] Select invalid directory → Auto-prompts again (no error spam)
- [x] Clear directory with X button → Working directory shows empty → Run shows prompt
- [x] Working directory field shows actual path only

---

**Stack**: Built on top of:

- PR #128: Clone progress UI
- PR #130: Task directory store foundation
- PR #131: Integrate directory store into execution flow
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.

3 participants