Commit Graph

698 Commits

Author SHA1 Message Date
Gabriel Gordon-Hall
cdfb081cf8 feat: copy-file autocomplete (#2004)
* add repo file search endpoint and use for copy-file autocomplete

* address feedback and fix i18n errors

* remove unused i18n
2026-01-13 17:34:54 +00:00
Louis Knight-Webb
33419c95f7 Improve the preview functionality (vibe-kanban) (#2010)
* preview styles

* All tasks are complete. Let me provide a summary of the changes made:

## Summary

I've implemented the preview functionality improvements as requested:

### Changes Made

**1. Rust Types (`crates/db/src/models/scratch.rs`)**
- Renamed `PreviewUrlOverrideData` → `PreviewSettingsData`
- Added new fields: `screen_size`, `responsive_width`, `responsive_height`
- Updated `ScratchPayload` and `ScratchType` enum to use `PreviewSettings`

**2. New Hook (`frontend/src/hooks/usePreviewSettings.ts`)**
- Created new `usePreviewSettings` hook (replaced `usePreviewUrlOverride`)
- Manages both URL override and screen size settings
- Persists screen size via the scratch system (per-workspace)
- Exports `ScreenSize` and `ResponsiveDimensions` types

**3. PreviewBrowserContainer (`frontend/src/components/ui-new/containers/PreviewBrowserContainer.tsx`)**
- Added URL controls (input, copy, open in new tab, refresh, clear override)
- Added stop button and related handlers
- Added screen size state management
- Added responsive dimensions resize handlers

**4. PreviewBrowser View (`frontend/src/components/ui-new/views/PreviewBrowser.tsx`)**
- Added floating toolbar above the iframe with:
  - URL input with action buttons
  - Screen size toggle (Desktop/Mobile/Responsive icons)
  - Dimensions display for responsive mode
  - Stop button
- Implemented three screen modes:
  - **Desktop**: Full width/height (current behavior)
  - **Mobile**: 390×844px centered with shadow
  - **Responsive**: Draggable resize handles on right, bottom, and corner edges

**5. PreviewControls View (`frontend/src/components/ui-new/views/PreviewControls.tsx`)**
- Simplified to show only logs
- Removed URL input row and all control buttons
- Renamed section header to "Dev Server Logs"

**6. PreviewControlsContainer (`frontend/src/components/ui-new/containers/PreviewControlsContainer.tsx`)**
- Removed all URL-related state and handlers
- Now only manages logs display and process tab switching

All type checks pass. The screen size preference is persisted per-workspace using the existing scratch system.

* Cleanup script changes for workspace dd65dbe3-2e31-4897-8aa4-b2f8f7971ab7

* All ESLint and TypeScript checks pass. The implementation is complete.

## Summary of Changes

**Files Modified:**

1. **`crates/db/src/models/scratch.rs`** - Renamed `PreviewUrlOverrideData` → `PreviewSettingsData` with new fields for screen size persistence

2. **`crates/server/src/bin/generate_types.rs`** - Updated type export to use new name

3. **`shared/types.ts`** - Regenerated with new types (`PreviewSettingsData`, `ScratchType.PREVIEW_SETTINGS`)

4. **`frontend/src/hooks/usePreviewSettings.ts`** (new) - Replaces `usePreviewUrlOverride.ts`, adds screen size management

5. **`frontend/src/hooks/usePreviewUrlOverride.ts`** - Deleted

6. **`frontend/src/components/ui-new/containers/PreviewBrowserContainer.tsx`** - Added URL controls, stop button, and resize state management

7. **`frontend/src/components/ui-new/views/PreviewBrowser.tsx`** - Added floating toolbar with:
   - URL input with copy/open/refresh/clear buttons
   - Screen size toggle (Desktop/Mobile/Responsive icons)
   - Responsive resize handles
   - Stop button

8. **`frontend/src/components/ui-new/containers/PreviewControlsContainer.tsx`** - Simplified to logs only

9. **`frontend/src/components/ui-new/views/PreviewControls.tsx`** - Simplified to logs only

* Cleanup script changes for workspace dd65dbe3-2e31-4897-8aa4-b2f8f7971ab7

* All checks pass. Here's a summary of the changes made:

## Summary of Changes

### 1. Fixed infinite loop bug (`usePreviewSettings.ts`)
- Added `useMemo` to stabilize the `responsiveDimensions` object reference
- This prevents the useEffect in the container from re-triggering on every render

### 2. Updated toolbar to always show with floating style (`PreviewBrowser.tsx`)
- Toolbar is now always visible (not conditional on `isServerRunning && hasUrl`)
- Changed styling from `border-b border-border` to `rounded-md shadow-md m-base` for a floating appearance
- URL input and action buttons are disabled (with `opacity-50 cursor-not-allowed`) when no URL is available
- Start/Stop button in toolbar changes based on server state:
  - Shows "Start" button when server is not running
  - Shows "Stop" button when server is running
- Simplified the empty state content area to just show a message pointing to the toolbar's Start button

* All checks pass. The fix:

1. **Changed from state to refs** for `isResizing` and `resizeDirection` - these now don't trigger re-renders when they change
2. **Added `localDimensionsRef`** to capture the current dimensions for the `handleEnd` callback without adding it to the effect's dependency array
3. **Effect now only depends on `setResponsiveDimensions`** (a stable callback), so event listeners are registered once on mount and cleaned up on unmount
4. **No more race conditions** - the same event handlers persist throughout the entire drag operation

The resize should now:
- Stop immediately when you release the mouse
- Be smooth without choppiness (no effect re-runs during drag)

* The responsive resize fix is complete. Here's a summary of the changes made:

**In `PreviewBrowserContainer.tsx`:**
1. Added `isResizing` state to track when resizing is active (for UI purposes)
2. Added `setResponsiveDimensionsRef` to store the callback in a ref, preventing the resize effect from re-running when the callback identity changes
3. Changed the resize effect to use an empty dependency array (`[]`) since all external values are now accessed via refs
4. Updated `handleResizeStart` to set `isResizing(true)`
5. Updated `handleEnd` to set `isResizing(false)` and use `setResponsiveDimensionsRef.current`
6. Passed `isResizing` prop to the `PreviewBrowser` view

**In `PreviewBrowser.tsx`:**
1. Added `isResizing` prop to the interface and destructured it
2. Applied `pointer-events-none` class to the iframe when `isResizing` is true - this prevents the iframe from capturing mouse events during resize, ensuring smooth dragging

These changes fix both issues:
- **Resize not stopping**: The effect no longer re-registers listeners when `setResponsiveDimensions` changes
- **Choppy dragging**: The iframe no longer captures mouse events during resize

* All checks pass. The fix is complete. The resize now uses delta-based calculation:

1. **`startPosRef`**: Captures the mouse position when resize starts
2. **`startDimensionsRef`**: Captures the iframe dimensions when resize starts
3. **`handleMove`**: Calculates delta (current position - start position) and applies it to the starting dimensions
4. **`handleEnd`**: Clears both refs when resize ends

This approach works regardless of where the iframe is positioned in the container, fixing both:
- The mouse jump offset (no longer tries to position based on container edge)
- The 50% distance issue (delta is 1:1 with mouse movement)

* Cleanup script changes for workspace dd65dbe3-2e31-4897-8aa4-b2f8f7971ab7

* Done. The resize should now move at 1:1 with the cursor. Since the centered element grows on both sides equally, doubling the delta ensures the edge under the cursor moves the full distance you drag.

* Done! I've added a minimal dark phone frame around the iframe when in mobile mode. The changes:

- **Mobile mode** now wraps the iframe in a phone skeleton with:
  - Dark bezel (`bg-gray-900`)
  - Rounded outer corners (`rounded-[3rem]`)
  - Padding for bezel width (`p-3`)
  - Shadow (`shadow-xl`)
  - Rounded inner screen area (`rounded-[2.5rem]`)

- **Desktop and responsive modes** remain unchanged

You can test it by running `pnpm run dev:qa` and switching to mobile view in the preview browser.

* styles

* I've completed the implementation. Here's a summary of the changes:

## Summary

Created two new reusable button components and updated PreviewBrowser.tsx to standardize button styles:

### New Components

1. **`IconButton.tsx`** (`frontend/src/components/ui-new/primitives/IconButton.tsx`)
   - Standalone icon button with consistent styling
   - Supports `default` and `tertiary` variants
   - Includes proper hover states (`bg-secondary/50`), disabled states, and transitions

2. **`IconButtonGroup.tsx`** (`frontend/src/components/ui-new/primitives/IconButtonGroup.tsx`)
   - Container component for grouped icon buttons with shared border
   - `IconButtonGroupItem` for individual buttons with `active` state support
   - Consistent styling with border, padding, and hover/active states

### Updated PreviewBrowser.tsx

- **URL action buttons** (Clear, Copy, Open in new tab, Refresh): Now use `IconButton` component with consistent hover backgrounds
- **Screen size toggle** (Desktop, Mobile, Responsive): Now uses `IconButtonGroup` and `IconButtonGroupItem` with proper active state styling
- **Start/Stop button**: Kept using `PrimaryButton` (already consistent)

### Visual Consistency Achieved

All toolbar buttons now share:
- Consistent padding (`p-half`)
- Consistent hover states (`bg-secondary/50` background)
- Consistent active states (`bg-secondary` background) for toggles
- Consistent disabled states (`opacity-40 cursor-not-allowed`)
- Consistent icon sizing (`size-icon-sm`) with `weight="bold"`
- Consistent border radius (`rounded-sm`)

* Done. The URL action buttons (Copy, Open in new tab, Refresh) are now grouped in an `IconButtonGroup` with a shared border, matching the visual style of the screen size toggle group.

The toolbar now has three visually consistent button groups:
1. **URL input** with optional clear override button
2. **URL actions group** (Copy, Open in new tab, Refresh) - bordered group
3. **Screen size toggle group** (Desktop, Mobile, Responsive) - bordered group
4. **Start/Stop button** (PrimaryButton)

* Done. All changes have been implemented:

1. **Added `iconClassName` prop to `IconButtonGroupItem`** - Supports passing custom classes to the icon (e.g., `animate-spin` for the spinner)

2. **Moved Clear button into URL Actions group** - The Clear Override button (X icon) is now inside the `IconButtonGroup` with Copy, Open, and Refresh buttons

3. **Replaced Pause button with `IconButtonGroupItem`** - The stop/pause button now uses the same `IconButtonGroup` styling as the other toolbar buttons, with spinner animation support when stopping

The toolbar now has consistent visual styling with three button groups:
- **URL Actions**: Clear (conditional), Copy, Open in new tab, Refresh
- **Screen Size Toggle**: Desktop, Mobile, Responsive
- **Stop button**: Pause icon (when server is running)
- **Start button**: Kept as `PrimaryButton` since it has a text label

* Cleanup script changes for workspace dd65dbe3-2e31-4897-8aa4-b2f8f7971ab7

* Done. The Start/Stop button is now a single `IconButtonGroup` with one `IconButtonGroupItem` that:
- Shows Play icon when server is stopped, Pause icon when running
- Shows Spinner icon with animation when starting or stopping
- Has the same size as all other toolbar button groups

* Cleanup script changes for workspace dd65dbe3-2e31-4897-8aa4-b2f8f7971ab7

* Done. Fixed the spinning Play icon bug by making the `iconClassName` logic match the icon selection logic exactly. Now `animate-spin` is only applied when actually showing the `SpinnerIcon`.

* Done. The entire toolbar (URL input, URL actions, screen size toggle) is now disabled when the dev server isn't running. Only the Play/Start button remains enabled so users can start the server.

* The changes compile correctly. Here's a summary of what was fixed:

## Summary

Fixed the "Fix Script" button showing at the wrong time in `PreviewBrowser.tsx`.

**Changes made:**

1. **`PreviewBrowser.tsx`** - Added `hasFailedDevServer?: boolean` prop and updated the condition on line 345 from `{handleFixDevScript && (` to `{hasFailedDevServer && handleFixDevScript && (`

2. **`PreviewBrowserContainer.tsx`** - Added failed dev server detection logic (lines 45-51) that checks for processes with `status === 'failed'` or `status === 'completed'` with non-zero exit code, and passed the `hasFailedDevServer` prop to the view

The "Fix Script" button will now only appear when the last dev server process actually failed, not when it was successful or killed.

* update styles

* All tasks completed. Here's a summary of the changes made:

## Summary

### 1. `IconButtonGroup.tsx` (lines 3, 50-65)
- Added import for `Tooltip` component
- Modified `IconButtonGroupItem` to wrap buttons with `<Tooltip>` when `title` prop is provided
- Removed native `title` attribute from button (tooltip handles it now)

### 2. `en/tasks.json` (lines 125-134)
Added new i18n keys under `preview.toolbar`:
- `clearUrlOverride`: "Clear URL override"
- `desktopView`: "Desktop view"
- `mobileView`: "Mobile view (390x844)"
- `responsiveView`: "Responsive view (resizable)"
- `startDevServer`: "Start dev server"

Added new `preview.loading` section:
- `startingServer`: "Starting dev server..."
- `waitingForServer`: "Waiting for server..."

### 3. `PreviewBrowser.tsx` (lines 160-254, 342-344)
Replaced all hardcoded strings with i18n translations using `t()`:
- URL action buttons (clear override, copy, open in tab, refresh)
- Screen size toggle buttons (desktop, mobile, responsive)
- Start/stop server button
- Loading state messages

All icon buttons now have proper accessible tooltips via the `Tooltip` component instead of native browser `title` attributes, and all strings are internationalized.

* style

* All i18n issues have been fixed. Here's a summary of the changes made:

**1. Added missing translation keys to all non-English locales (es, ja, ko, zh-Hans, zh-Hant):**
- `preview.loading.startingServer`
- `preview.loading.waitingForServer`
- `preview.toolbar.clearUrlOverride`
- `preview.toolbar.desktopView`
- `preview.toolbar.mobileView`
- `preview.toolbar.responsiveView`
- `preview.toolbar.startDevServer`

**2. Fixed hardcoded strings in `PreviewBrowser.tsx`:**
- Replaced dimension separator `x` with HTML entity `&times;`
- Internationalized the "no dev script" setup message with 3 new i18n keys:
  - `preview.noServer.setupTitle`
  - `preview.noServer.editDevScript`
  - `preview.noServer.learnMore`

**3. Added the 3 new keys to all locale files (en, es, ja, ko, zh-Hans, zh-Hant)**

The `check-i18n.sh` script now passes with:
- 128 violations (down from 131 on main - a net improvement!)
- No duplicate keys
- Translation keys consistent across all locales
2026-01-13 14:55:57 +00:00
Anastasiia Solop
a3cdca742a Add conflict detection and resolution dialog to rebase/merge flow (Vibe Kanban) (#2001)
* I've implemented the changes to the rebase/merge flow in the new workspaces UI. Here's a summary of what was done:

## Summary of Changes

### 1. Created `ResolveConflictsDialog` component
**File:** `frontend/src/components/ui-new/dialogs/ResolveConflictsDialog.tsx`

A new dialog that:
- Shows when conflicts are detected before rebase/merge operations
- Displays the list of conflicted files (up to 5, with a count for additional)
- Asks the user whether to resolve conflicts in:
  - **Current session** (default when a session exists)
  - **New session** (toggle switch, similar to StartReviewDialog)
- When creating a new session, allows selecting agent/profile
- Sends the conflict resolution instructions to the agent automatically

### 2. Updated `GitRebase` action
**File:** `frontend/src/components/ui-new/actions/index.ts`

- Now checks for existing conflicts before opening the RebaseDialog
- If conflicts exist (`is_rebase_in_progress` or `conflicted_files.length > 0`), shows the ResolveConflictsDialog instead
- If no conflicts, proceeds with normal rebase flow

### 3. Updated `GitMerge` action
**File:** `frontend/src/components/ui-new/actions/index.ts`

- Same conflict detection logic as GitRebase
- If conflicts exist, shows the ResolveConflictsDialog
- If no conflicts, proceeds with normal merge confirmation flow

### 4. Added translations
**File:** `frontend/src/i18n/locales/en/tasks.json`

Added new translation keys under `resolveConflicts.dialog`:
- `title`: "Resolve Conflicts"
- `description`: "Conflicts were detected. Choose how you want the agent to resolve them."
- `sessionLabel`: "Session"
- `existingSession`: "Continue in current session"
- `newSession`: "New Session"
- `resolve`: "Resolve Conflicts"
- `resolving`: "Starting..."

### How it works

1. When a user clicks **Rebase** or **Merge** in the RepoCard dropdown
2. The system fetches the branch status to check for conflicts
3. If conflicts exist:
   - The `ResolveConflictsDialog` opens
   - User can choose to resolve in current session or new session
   - Clicking "Resolve Conflicts" sends pre-built conflict resolution instructions to the agent
4. If no conflicts:
   - Normal flow continues (RebaseDialog for rebase, ConfirmDialog for merge)

* The type check passes. Now the flow will be:

1. User clicks Rebase → RebaseDialog opens
2. User selects branch and clicks Rebase
3. If conflicts occur during rebase:
   - The error is caught with type `merge_conflicts` or `rebase_in_progress`
   - RebaseDialog closes
   - ResolveConflictsDialog opens with conflict details
4. If no conflicts → Rebase succeeds and dialog closes

This handles the first-time rebase scenario where conflicts are detected *after* the rebase attempt, not before.

* Cleanup script changes for workspace f54c4bcf-8b64-4260-8cae-c8d0bda2a350

* The type check passes. The key changes I made:

1. **Await query invalidation**: Changed from fire-and-forget `invalidateQueries` to awaiting them with `Promise.all()`. This ensures the sessions list is refreshed before we try to select the new session.

2. **Select session after queries refresh**: Moved the `selectSession` call to after the queries have been invalidated and refetched, so the new session exists in the list.

3. **Simplified the boolean logic**: Used a single `creatingNewSession` variable instead of computing the condition twice.

This should fix the issue where the previous session "disappears" - it was likely being overwritten by the auto-select behavior in `useWorkspaceSessions` that fires when sessions change. Now we wait for that to settle before selecting the new session.

* The type check passes. Here's a summary of the updated flow:

## Updated Flow

### Merge Action:
1. **Check for existing conflicts** → If conflicts exist, show ResolveConflictsDialog
2. **Check if branch is behind** → If `commits_behind > 0`, show "Rebase Required" dialog that offers to open RebaseDialog
3. **Otherwise** → Show normal merge confirmation dialog

### Rebase Action:
1. **Check for existing conflicts** → If conflicts exist, show ResolveConflictsDialog
2. **Otherwise** → Show RebaseDialog
3. **If rebase fails with conflicts** → RebaseDialog catches the error and shows ResolveConflictsDialog

This way:
- Clicking Merge when behind will prompt to rebase first (avoiding the "Branches diverged" error)
- Clicking Rebase when conflicts already exist will show the resolve dialog immediately
- If rebase creates new conflicts, the RebaseDialog will catch it and show the resolve dialog

* Both the type check and i18n lint pass now. The i18n issues in the ResolveConflictsDialog have been fixed by:

1. Added new translation keys in `tasks.json`:
   - `filesWithConflicts_one`: "{{count}} file has conflicts"
   - `filesWithConflicts_other`: "{{count}} files have conflicts"
   - `andMore`: "...and {{count}} more"

2. Updated `ResolveConflictsDialog.tsx` to use `t()` function with these keys instead of hardcoded strings.

* All checks pass. The i18n translations have been added to all 5 locale files (es, ja, ko, zh-Hans, zh-Hant) for the `resolveConflicts.dialog.*` keys:

- `title` - Resolve Conflicts
- `description` - Conflicts were detected...
- `sessionLabel` - Session
- `existingSession` - Continue in current session
- `newSession` - Start a new session
- `resolve` - Resolve Conflicts
- `resolving` - Starting...
- `filesWithConflicts_one` - {{count}} file has conflicts
- `filesWithConflicts_other` - {{count}} files have conflicts
- `andMore` - ...and {{count}} more

All checks now pass:
- `./scripts/check-i18n.sh`  - No missing translation keys
- `pnpm run lint`  - Both frontend and backend linting pass
- `pnpm run check`  - TypeScript and Rust type checks pass
2026-01-13 12:34:28 +01:00
Gabriel Gordon-Hall
57e802e2c9 per-repo diff stats (#1961) 2026-01-13 09:32:16 +00:00
Anastasiia Solop
118650872b fix styling of diffs in conversation (#1998) 2026-01-13 07:49:45 +01:00
Louis Knight-Webb
4a0fad03c2 Display GitHub PR comments inline in diff view (Vibe Kanban) (#1991)
* The GitHub comments integration is now complete. Here's a summary of what was implemented:

## Summary

The GitHub PR comments integration for the new UI (ui-new) is now complete. All tasks have been implemented:

### Files Modified:
1. **`useUiPreferencesStore.ts`** - Added persistence key for `showGitHubComments` toggle
2. **`WorkspaceContext.tsx`** - Extended with PR comments data, helpers (`getGitHubCommentsForFile`, `gitHubFileCommentCounts`), and toggle state
3. **`CommentCard.tsx`** (new) - Shared primitive for displaying comments with three variants: `user`, `github`, `input`
4. **`GitHubCommentRenderer.tsx`** (new) - Read-only renderer for GitHub comments with GitHub logo, author, timestamp, and external link
5. **`ReviewCommentRenderer.tsx`** - Refactored to use `CommentCard` primitive
6. **`CommentWidgetLine.tsx`** - Refactored to use `CommentCard` primitive
7. **`DiffViewCardWithComments.tsx`** - Integrated GitHub comments into diff view, showing both user and GitHub comments with separate counts in the header
8. **`FileTreeNode.tsx`** - Added GitHub comment badge showing count next to files
9. **`FileTree.tsx`** - Added toggle button in header to show/hide GitHub comments
10. **`FileTreeContainer.tsx`** - Wired up the context to pass toggle state and comment counts to FileTree
11. **`common.json`** (i18n) - Added translation keys for show/hide GitHub comments

### Features:
- GitHub PR comments displayed inline next to relevant code in diff views
- Toggle button in file tree to show/hide GitHub comments (persisted)
- Comment count badges on files in the file tree
- Visual differentiation: user comments have orange styling (`bg-brand/20 border-brand`), GitHub comments have neutral styling (`bg-secondary border-border`)
- User comments take priority when both exist on the same line

* Cleanup script changes for workspace 881e2956-9cca-406d-835f-7ea8acbe550e

* All checks pass. Let me show a summary of the changes made:

## Summary of Fixes

All code review feedback has been addressed:

| # | Fix | File | Change |
|---|-----|------|--------|
| 1 | Date parsing | `GitHubCommentRenderer.tsx:9-27` | Replaced `try/catch` with `isNaN(date.getTime())` check |
| 2 | Comment priority | `DiffViewCardWithComments.tsx:258-260` | Added comment explaining user comments take priority |
| 3 | SplitSide.new | `WorkspaceContext.tsx:163-165` | Added comment explaining why `SplitSide.new` is correct |
| 4 | Multi-repo TODO | `WorkspaceContext.tsx:133-134` | Added TODO about supporting multiple repos |
| 5 | Loading state | `FileTreeContainer.tsx`, `FileTree.tsx` | Passed `isGitHubCommentsLoading` prop and added `opacity-50 animate-pulse` to button |

Type checks pass. Ready for commit.

* Fixed! The `FileTree.tsx` now uses the correct `Tooltip` component from `@/components/ui-new/primitives/Tooltip` instead of the old `@/components/ui/tooltip`.

Changes made:
- Updated import to use `import { Tooltip } from '../primitives/Tooltip'`
- Simplified the tooltip usage from the compound component pattern (`Tooltip` + `TooltipTrigger` + `TooltipContent`) to the simpler API (`<Tooltip content="...">...</Tooltip>`)

* The path matching bug has been fixed. Here's a summary of the changes:

## Summary of Bug Fix

**Problem**: GitHub comments weren't displaying because paths didn't match.
- GitHub API returns paths like: `frontend/src/components/ui-new/actions/index.ts`
- Diff paths are prefixed with repo name: `vibe-kanban/frontend/src/components/ui-new/actions/index.ts`

**Solution**: Use `endsWith` matching instead of exact string equality.

### Files Changed:

1. **`WorkspaceContext.tsx`**:
   - Added `pathMatches` helper function that checks if paths match using `endsWith`
   - Updated `getGitHubCommentsForFile` to use `pathMatches`
   - Replaced `gitHubFileCommentCounts: Record<string, number>` with `getGitHubCommentCountForFile: (filePath: string) => number` function that also uses `pathMatches`

2. **`FileTree.tsx`**:
   - Changed prop from `fileCommentCounts?: Record<string, number>` to `getGitHubCommentCountForFile?: (filePath: string) => number`
   - Updated usage from `fileCommentCounts?.[node.path]` to `getGitHubCommentCountForFile?.(node.path)`

3. **`FileTreeContainer.tsx`**:
   - Updated to pass the new `getGitHubCommentCountForFile` function instead of `gitHubFileCommentCounts` Record

* Cleanup script changes for workspace 881e2956-9cca-406d-835f-7ea8acbe550e

* Fixed! The `renderExtendLine` function now includes a null check for `lineData.data` to prevent the TypeError when switching diff modes. The fix adds:

```typescript
// Guard against undefined data (can happen when switching diff modes)
if (!lineData.data) return null;
```

This prevents the crash when the `@git-diff-view` library passes undefined data during mode transitions.

* Done! GitHub comments will now be shown by default. The change was a simple one-liner in `WorkspaceContext.tsx`:

```typescript
// Before:
false // Default to hidden

// After:
true // Default to shown
```

* The proper fix is complete. Here's a summary of the changes:

## Summary: Comments on deleted lines fix

**Problem**: GitHub comments on deleted lines weren't showing because we were placing all comments on `SplitSide.new`.

**Solution**: Pass through the `side` field from GitHub's API which indicates whether the comment is on the "LEFT" (old/deleted) or "RIGHT" (new/added) side.

### Files Changed:

1. **`crates/services/src/services/git_host/types.rs`**
   - Added `side: Option<String>` field to `UnifiedPrComment::Review` variant

2. **`crates/services/src/services/git_host/github/mod.rs`**
   - Pass `c.side` through when creating `UnifiedPrComment::Review`

3. **`crates/services/src/services/git_host/azure/cli.rs`**
   - Added `side: None` to Azure DevOps (doesn't have this info)

4. **`shared/types.ts`** (regenerated)
   - Now includes `side: string | null` in the review comment type

5. **`frontend/src/contexts/WorkspaceContext.tsx`**
   - Updated normalization to use `comment.side === 'LEFT' ? SplitSide.old : SplitSide.new`

6. **`frontend/src/components/ui-new/containers/DiffViewCardWithComments.tsx`**
   - Updated `extendData` building to place GitHub comments on the correct side (`oldFileData` or `newFileData`) based on `comment.side`

* The refactoring is complete. Here's a summary of the changes:

**Created new file:** `frontend/src/hooks/useGitHubComments.ts`
- Contains the `NormalizedGitHubComment` interface
- Contains all GitHub comments logic: fetching, toggle state, normalization, path matching helpers

**Updated:** `frontend/src/contexts/WorkspaceContext.tsx`
- Removed ~70 lines of GitHub comments logic
- Now imports and uses `useGitHubComments` hook
- Re-exports `NormalizedGitHubComment` type for consumers that import it from the context

The context file is now smaller and more focused on workspace management, while the GitHub comments functionality is encapsulated in its own dedicated hook.

* Cleanup script changes for workspace 881e2956-9cca-406d-835f-7ea8acbe550e

* Done. Removed the duplicate `formatRelativeTime` function from `GitHubCommentRenderer.tsx` and replaced it with an import from the existing `@/utils/date` utility.

* The i18n check now passes. All translation keys are consistent across locales. I added the missing `showGitHubComments` and `hideGitHubComments` translations to:
- Spanish (es)
- Japanese (ja)
- Korean (ko)
- Simplified Chinese (zh-Hans)
- Traditional Chinese (zh-Hant)
2026-01-12 23:47:53 +00:00
Louis Knight-Webb
bd034da2db Navigate away when deleting the currently selected workspace (Vibe Kanban) (#1984)
* Done! I've implemented the feature. Here's a summary of the changes to `vibe-kanban/frontend/src/components/ui-new/actions/index.ts`:

1. **Added `getNextWorkspaceId` helper function** (lines 184-196) - A reusable function that finds the next workspace to navigate to when removing a workspace from the active list

2. **Refactored `ArchiveWorkspace`** - Now uses the helper function instead of inline logic

3. **Updated `DeleteWorkspace`** - Added navigation logic that:
   - Only triggers when deleting the currently viewed workspace
   - Navigates to the next workspace in the list (or previous if at end)
   - Falls back to `/workspaces/create` if no other workspaces exist

* Cleanup script changes for workspace a60eb506-5db1-4ba7-8ee6-26592885587b
2026-01-12 23:39:42 +00:00
Louis Knight-Webb
c7cf72a57f Allow manual URL override in dev server preview (Vibe Kanban) (#1989)
* The implementation is complete and tested. Here's a summary of the changes made:

I've implemented an editable URL bar in the Preview Controls that allows users to override the auto-detected dev server URL on a per-workspace basis.

| File | Changes |
|------|---------|
| `crates/db/src/models/scratch.rs` | Added `PreviewUrlOverrideData` struct and `PreviewUrlOverride` variant to `ScratchPayload` enum |
| `crates/server/src/bin/generate_types.rs` | Registered `PreviewUrlOverrideData::decl()` for TypeScript type generation |
| `shared/types.ts` | Auto-generated with new `PreviewUrlOverrideData` type and updated `ScratchPayload` union |
| `frontend/src/hooks/usePreviewUrlOverride.ts` | **New file** - Custom hook for managing URL override persistence via scratch system |
| `frontend/src/components/ui-new/containers/PreviewControlsContainer.tsx` | Added URL override hook integration, merged auto-detected with override URL |
| `frontend/src/components/ui-new/views/PreviewControls.tsx` | Replaced static `<span>` with editable `<input>`, added clear override button (X icon) |

- **Editable URL bar**: Users can type a custom URL to override the auto-detected one
- **Per-workspace persistence**: Override URL saved in the scratch system using workspace ID
- **Debounced saves**: Changes are debounced (300ms) before saving to avoid excessive API calls
- **Clear override button**: X button appears when override is active, allowing revert to auto-detected URL
- **Visual distinction**: Override URLs show in normal text color, auto-detected in dim text

* Cleanup script changes for workspace 3f3c315d-5cc2-43b0-9043-117c857f38b4

* The URL input fix is complete. Here's a summary of what was implemented:

**Feature: Editable URL bar with per-workspace persistence**

1. **New scratch type** - Added `PreviewUrlOverride` to the Rust scratch system for persisting URL overrides per workspace

2. **New hook** - Created `usePreviewUrlOverride.ts` that wraps the scratch system with debounced saves (300ms delay)

3. **Container integration** - Updated `PreviewControlsContainer.tsx` to use the override URL when set, falling back to auto-detected URL

4. **View updates** - Updated `PreviewControls.tsx` with:
   - Editable input field instead of read-only display
   - Clear button (X icon) to revert to auto-detected URL
   - Local state management to prevent WebSocket updates from disrupting typing

**Bug fix for typing issue:**
- Added local state (`localValue`) and ref (`inputRef`) to track input value locally
- The effect only syncs from server when input is not focused, preventing cursor jumping and character loss during typing

* ESLint and Clippy both pass now. The fix moved the state management from the presentational view component (`PreviewControls.tsx`) to the container component (`PreviewControlsContainer.tsx`), which aligns with the codebase's architecture pattern of keeping views stateless.

* I can see projects now. Let me click on the first project to access a workspace where I can test the URL override feature:

* TypeScript check passes now. The fix was changing `RefObject<HTMLInputElement | null>` to `RefObject<HTMLInputElement>` in the props interface - the `null` is already implied in how React refs work.
2026-01-12 23:36:15 +00:00
Louis Knight-Webb
d9fa2d1fa5 Always show a panel (#1988)
## Summary

**Fixed:** Invalid layout state where only left and right sidebars are visible (no main content area).

### Changes Made:

**1. `frontend/src/stores/useLayoutStore.ts`**
- Added `setMainPanelVisible` setter function to the type and implementation
- Added `useIsRightMainPanelVisible` derived selector hook that checks if Changes/Logs/Preview panel is visible

**2. `frontend/src/components/ui-new/containers/WorkspacesLayout.tsx`**
- Imported `useIsRightMainPanelVisible` from the layout store
- Added `setMainPanelVisible` to the destructured store values
- Replaced verbose `isChangesMode || isLogsMode || isPreviewMode` checks with the helper
- Added guard effect that ensures the left main panel (chat) is visible when the right main panel is hidden - this prevents the invalid state after page reload

The guard effect automatically opens the main panel whenever the layout would otherwise show only sidebars:

```typescript
// Ensure left main panel (chat) is visible when right main panel is hidden
// This prevents invalid state where only sidebars are visible after page reload
useEffect(() => {
  if (!isMainPanelVisible && !isRightMainPanelVisible) {
    setMainPanelVisible(true);
  }
}, [isMainPanelVisible, isRightMainPanelVisible, setMainPanelVisible]);
```
2026-01-12 23:18:14 +00:00
Louis Knight-Webb
aad1bd092b WYSIWYG editor will retain focus when the user clicks the '+' button in the sidebar. (#1987) 2026-01-12 23:09:19 +00:00
Louis Knight-Webb
25c8ab29a9 Fix workspace actions in summary (#1986)
## Summary

Fixed the "workspace not found" error when performing actions on non-selected workspaces.

**Root cause**: The `getWorkspaceFromCache()` function only checked the React Query cache, but only the currently selected workspace had its full data cached.

**Solution**: Modified the helper function to fetch from the API when data isn't in cache.

**File modified**: `frontend/src/components/ui-new/actions/index.ts`

**Changes**:
1. Renamed `getWorkspaceFromCache` → `getWorkspace` and made it async
2. Added fallback to `attemptsApi.get(workspaceId)` when cache miss occurs
3. Updated all 6 call sites to use `await getWorkspace()`:
   - `RenameWorkspace` (line 215)
   - `PinWorkspace` (line 229)
   - `ArchiveWorkspace` (line 246)
   - `DeleteWorkspace` (line 281)
   - `OpenInOldUI` (line 489)
   - `GitCreatePR` (line 630)
2026-01-12 23:02:56 +00:00
Louis Knight-Webb
b87fb13e87 Dev server starting state (#1985)
**Changes:**
1. Added `useState` and `useEffect` to imports
2. Added `pendingStart` state to track when mutation has started but no running process exists yet
3. Added `useEffect` that clears `pendingStart` when `runningDevServers.length > 0`
4. Added `onMutate` callback to set `pendingStart = true` when mutation starts
5. Updated `onError` to clear `pendingStart` on failure
6. Updated `isStarting` return value to `startMutation.isPending || pendingStart`

**How it works:**
- When the user clicks "Start", `onMutate` fires immediately and sets `pendingStart = true`
- This makes `isStarting = true`, showing the "starting" state in the UI
- The `pendingStart` state persists even after the API request completes
- Only when a running dev server process appears in the data (via the `useEffect`), `pendingStart` is cleared
- If the mutation fails, `onError` clears `pendingStart` immediately

This ensures the "starting" state is visible until the dev server process actually appears, rather than just during the brief API request time.
2026-01-12 22:58:14 +00:00
GitHub Action
6d5c8ac486 chore: bump version to 0.0.150 2026-01-12 21:53:09 +00:00
Louis Knight-Webb
7bc52ac8c5 Re-run setup and cleanup scripts (#1981)
## Summary

I've implemented the "re-run setup/cleanup script" functionality in the new UI command bar. The changes include:

### Files Modified

1. **`frontend/src/components/ui-new/actions/index.ts`**
   - Added `isAttemptRunning: boolean` to `ActionVisibilityContext` interface (line 109)
   - Added `RunSetupScript` and `RunCleanupScript` workspace actions (lines 737-777)
   - Both actions use the existing `attemptsApi.runSetupScript/runCleanupScript` methods
   - Actions are disabled when `isAttemptRunning` is true
   - Error handling for `no_script_configured` and `process_already_running` errors

2. **`frontend/src/components/ui-new/actions/useActionVisibility.ts`**
   - Import `useExecutionProcessesContext`
   - Added `isAttemptRunningVisible` to the hook call
   - Added `isAttemptRunning: isAttemptRunningVisible` to the returned context

3. **`frontend/src/components/ui-new/actions/pages.ts`**
   - Added a new "Scripts" group to the `workspaceActions` page containing both actions

### Testing

The dev server is running at:
- Frontend: http://localhost:3000/
- Backend: http://127.0.0.1:3001

To test:
1. Navigate to the new UI (`/workspaces`)
2. Select a workspace
3. Open the command bar (CMD+K)
4. Navigate to "Workspace Actions"
5. You should see a "Scripts" group with "Run Setup Script" and "Run Cleanup Script" options
2026-01-12 21:00:47 +00:00
Alex Netsch
20b99300fe Add session-level review endpoint with StartReviewDialog (Vibe Kanban) (#1849)
* All checks pass. Let me provide a summary of what was implemented:

I've implemented the review endpoint as planned. Here's what was created:

1. **`crates/executors/src/actions/review.rs`** - New action type with:
   - `RepoReviewContext` struct (repo_id + commit_hashes)
   - `ReviewRequest` struct (executor_profile_id, context, additional_prompt, working_dir)
   - `Executable` trait impl that calls `executor.spawn_review()`

2. **`crates/server/src/routes/task_attempts/review.rs`** - Endpoint handler with:
   - `StartReviewRequest` for the API
   - `RepoReviewContext` (endpoint-specific copy)
   - `ReviewError::ProcessAlreadyRunning`
   - `start_review` handler that:
     - Verifies no running processes on workspace
     - Creates fresh session
     - Builds ReviewRequest action
     - Starts execution with `ExecutionProcessRunReason::CodingAgent`

1. **`crates/executors/src/executors/mod.rs`**:
   - Added `spawn_review()` to `StandardCodingAgentExecutor` trait with default prompt-based implementation
   - Added `build_review_prompt()` helper function

2. **`crates/executors/src/actions/mod.rs`**:
   - Added `pub mod review;`
   - Added `ReviewRequest` to `ExecutorActionType` enum
   - Updated `base_executor()` match

3. **`crates/services/src/services/container.rs`**:
   - Updated match in `try_start_next_action` to handle `ReviewRequest`

4. **`crates/server/src/routes/task_attempts.rs`**:
   - Added `pub mod review;`
   - Added `.route("/review", post(review::start_review))`

5. **`crates/server/src/bin/generate_types.rs`**:
   - Added new types to export list

**`POST /task-attempts/{id}/review`**

Request:
```json
{
  "executor_profile_id": { "executor": "CLAUDE_CODE", "variant": null },
  "context": [{ "repo_id": "uuid", "commit_hashes": ["abc123"] }],
  "additional_prompt": "Focus on security issues"
}
```

Response: `ExecutionProcess` on success, `ReviewError` on failure.

To add native review for an executor (e.g., Codex), just override `spawn_review()` in that executor's `StandardCodingAgentExecutor` impl. No changes needed to action or endpoint.

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

All checks pass now. The duplicate type issue is fixed - we're using a single `RepoReviewContext` type from the executors crate.

All checks pass now. Both frontend lint (ESLint) and backend lint (Clippy) are passing.

Found and fixed the real issue. The problem was in `crates/services/src/services/container.rs` - the log normalization was only set up for `CodingAgentInitialRequest` and `CodingAgentFollowUpRequest`. `ReviewRequest` was falling through to the default case and returning `None`, so no normalizer was started for review processes.

Fixed in two places:
1. **Line 787-791**: Added `ReviewRequest` handling in `stream_normalized_logs` (for historic logs)
2. **Line 1149-1151**: Added `ReviewRequest` handling in `start_execution` (for live logs)

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Backend changes for the `use_all_workspace_commits` flag are complete. Here's what was implemented:

Added `use_all_workspace_commits` flag to `StartReviewRequest` for automatically populating review context.

1. **`crates/db/src/models/execution_process_repo_state.rs`**
   - Added `find_initial_commits_for_workspace()` - query to get the earliest `before_head_commit` for each repo in a workspace

2. **`crates/server/src/routes/task_attempts/review.rs`**
   - Added `use_all_workspace_commits: bool` field to `StartReviewRequest` (defaults to `false`)
   - When flag is `true` and `context` is `None`, auto-populates context with initial commits from workspace execution processes

3. **`crates/executors/src/executors/mod.rs`**
   - Updated `build_review_prompt()` to detect single-commit context (indicating initial commit)
   - When single commit per repo, prompts agent to "Review all changes made since the following base commit(s)" with git diff hint

4. **`crates/services/src/services/git.rs`**
   - Added `get_commits_since_branch()` method (may be useful for future use)

5. **`shared/types.ts`**
   - Generated TypeScript type includes `use_all_workspace_commits: boolean`

When frontend calls `POST /task-attempts/{id}/review` with:
```json
{
  "executor_profile_id": { "executor": "CLAUDE_CODE", "variant": null },
  "use_all_workspace_commits": true
}
```

The backend will:
1. Find the earliest execution process for the workspace
2. Get the `before_head_commit` for each repo (the commit before agents started making changes)
3. Pass that to the prompt builder which tells the agent to review all changes since that commit

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Frontend UI implementation is complete. Here's a summary of what was added:

Added simple frontend UI to test the review endpoint.

1. **`frontend/src/lib/api.ts`**
   - Added `startReview` method to `attemptsApi`
   - Imports `StartReviewRequest`, `ReviewError` types

2. **`frontend/src/hooks/useStartReview.ts`** (NEW)
   - Hook that calls `attemptsApi.startReview` with `use_all_workspace_commits: true`
   - Invalidates `processes` and `branchStatus` queries on success

3. **`frontend/src/hooks/index.ts`**
   - Exports `useStartReview`

4. **`frontend/src/components/ui/actions-dropdown.tsx`**
   - Added "Start Review" menu item in the attempt actions section
   - Uses the user's default executor profile from config
   - Shows loading state while starting review

5. **`frontend/src/i18n/locales/en/tasks.json`**
   - Added translation keys: `startReview`, `startingReview`

From the workspace actions dropdown (three dots menu), click "Start Review" to start a code review session using all workspace commits as context.

Done! The fix has been implemented. The review endpoint now uses `Session::find_latest_by_workspace_id` to find an existing session for the workspace, and only creates a new session if none exists. This means review logs will now appear in the same conversation view as other coding agent runs.

**Change summary:**
- Modified `crates/server/src/routes/task_attempts/review.rs` (lines 79-93)
- Instead of always creating a new session, it now checks for an existing session first using `Session::find_latest_by_workspace_id`
- This matches the pattern used by dev server, setup scripts, and other similar endpoints

Done! The fix is now in place. The change adds `ReviewRequest` to the action type filter in `useConversationHistory.ts` so review processes are included in the conversation view, and handles the content extraction appropriately (using `additional_prompt` for reviews instead of `prompt`).

**Change summary:**
- Modified `frontend/src/hooks/useConversationHistory.ts` (lines 226-244)
- Added `ReviewRequest` to the action type filter
- Used conditional to extract content from `additional_prompt` for reviews (with fallback "Review the code changes") vs `prompt` for coding agent requests

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

Done! All fixes are now in place:

1. **`useConversationHistory.ts` - `flattenEntries()`** (line 177-184): Added `ReviewRequest` to the filter so review processes are included in the flattened entries
2. **`useConversationHistory.ts` - `flattenEntriesForEmit()`** (line 226-244): Already fixed earlier - handles `ReviewRequest` and extracts `additional_prompt` for user message content
3. **`ProcessesTab.tsx`** (line 223-228): Added `ReviewRequest` to the ProfileVariantBadge conditional so the agent badge shows for review processes

* Done. Changes made:

1. **`crates/executors/src/actions/review.rs`**: Added `prompt: String` field to `ReviewRequest`

2. **`crates/server/src/routes/task_attempts/review.rs`**:
   - Import `build_review_prompt`
   - Build the full prompt from context and additional_prompt before creating the action

3. **`frontend/src/hooks/useConversationHistory.ts`**: Simplified content extraction to just use `actionType.prompt` for all action types (since `ReviewRequest` now has a prompt field too)

4. **Regenerated TypeScript types** - `ReviewRequest` in `shared/types.ts` now includes the `prompt` field

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Done. Here's a summary of the changes:

**Backend:**
1. **`crates/executors/src/actions/review.rs`**:
   - Added `CommitRange` enum with three variants: `FromBase`, `Specific`, and `Range`
   - Updated `RepoReviewContext` to use `repo_name: String` and `commits: CommitRange` instead of `commit_hashes`

2. **`crates/executors/src/executors/mod.rs`**:
   - Updated `build_review_prompt` to format output with repo names and handle all `CommitRange` variants

3. **`crates/server/src/routes/task_attempts/review.rs`**:
   - Simplified `StartReviewRequest` (removed `context` field, kept `use_all_workspace_commits`)
   - Updated handler to look up repo names via `Repo::find_by_ids` and use `CommitRange::FromBase`

4. **`crates/server/src/bin/generate_types.rs`**: Added `CommitRange` to exported types

**Frontend:**
- **`frontend/src/hooks/useStartReview.ts`**: Removed `context: null` since that field no longer exists

The prompt will now look like:
```
Please review the code changes.

Repository: vibe-kanban
Review all changes from base commit abc123 to HEAD.
Use `git diff abc123..HEAD` to see the changes.
```

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Codex review support (vibe-kanban e7996a18)

## Context

We've added a review endpoint (\`POST /task-attempts/{id}/review\`) that starts a code review session. Currently it uses a default prompt-based implementation via \`spawn\_review()\` on \`StandardCodingAgentExecutor\`, which builds a prompt and delegates to \`spawn()\`.

## Goal

Implement native Codex review support by overriding \`spawn\_review()\` in the Codex executor to use Codex's native review mechanism instead of the prompt-based approach.

## Current Implementation

### Backend Types

\*\*\`CommitRange\` enum\*\* (\`crates/executors/src/actions/review.rs\`):

\`\`\`rust

pub enum CommitRange {

    FromBase { commit: String },

    Specific { commits: Vec<String> },

    Range { from: String, to: String },

}

\`\`\`

\*\*\`RepoReviewContext\`\*\*:

\`\`\`rust

pub struct RepoReviewContext {

    pub repo\_id: Uuid,

    pub repo\_name: String,

    pub commits: CommitRange,

}

\`\`\`

### Trait Method

\*\*\`spawn\_review()\`\*\* in \`StandardCodingAgentExecutor\` trait (\`crates/executors/src/executors/mod.rs\`):

\`\`\`rust

async fn spawn\_review(

    &self,

    current\_dir: &Path,

    context: Option<&[RepoReviewContext]>,

    additional\_prompt: Option<&str>,

    env: &ExecutionEnv,

) -> Result<SpawnedChild, ExecutorError> {

    // Default: build prompt and delegate to spawn()

    let prompt = build\_review\_prompt(context, additional\_prompt);

    self.spawn(current\_dir, &prompt, env).await

}

\`\`\`

## Tasks

1. Research Codex's native review API/mechanism (if it has one)
2. Override \`spawn\_review()\` in \`CodexExecutor\` to use native review if available
3. Fall back to prompt-based approach if native review isn't supported

* Done. Here's a summary of the changes:

1. **Removed dead code** from `crates/executors/src/executors/codex/review.rs`:
   - Deleted the `map_to_review_target()` function (was ~120 lines)
   - Removed unused imports (`CommitRange`, `RepoReviewContext`)

2. **Codex now uses `ReviewTarget::Custom`** with the pre-built prompt, which ensures the displayed prompt matches what Codex actually receives.

The build passes and TypeScript types have been regenerated.

* Use custom review target for codex

* Done. Here's a summary of the changes:

## Summary

Moved the review endpoint from workspace-level to session-level:

### Changes

1. **Created `crates/server/src/routes/sessions/review.rs`**
   - New review endpoint at `POST /sessions/{id}/review`
   - Takes `Extension<Session>` instead of `Extension<Workspace>`
   - Looks up `agent_session_id` from previous executions using `find_latest_coding_agent_turn_session_id()`
   - Passes `agent_session_id` to `ReviewAction` for session resumption

2. **Updated `crates/server/src/routes/sessions/mod.rs`**
   - Added `pub mod review;`
   - Added route `.route("/review", post(review::start_review))`

3. **Updated `crates/server/src/routes/task_attempts.rs`**
   - Removed `pub mod review;`
   - Removed `.route("/review", post(review::start_review))`

4. **Deleted `crates/server/src/routes/task_attempts/review.rs`**

5. **Updated `crates/server/src/bin/generate_types.rs`**
   - Changed path from `task_attempts::review` to `sessions::review`

### API Change

- **Old**: `POST /api/task-attempts/{workspace_id}/review`
- **New**: `POST /api/sessions/{session_id}/review`

This ensures vk sessions and agent sessions are 1:1:
- Existing session → resumes agent session if available
- New session → fresh agent session

* Done! Here's a summary of all the frontend changes:

- Added `startReview` to `sessionsApi` using new endpoint `POST /api/sessions/${sessionId}/review`
- Removed `startReview` from `attemptsApi`

- Changed parameter from `attemptId` to `sessionId` and added optional `workspaceId` for query invalidation
- Changed API call from `attemptsApi.startReview` to `sessionsApi.startReview`

- Added `MagnifyingGlassIcon` import
- Added `onStartReview` and `isReviewStarting` to `SessionProps` interface
- Added "Start Review" menu item in the session dropdown

- Added `useStartReview` hook import and usage
- Added `handleStartReview` callback function
- Passed `onStartReview` and `isReviewStarting` to `SessionChatBox`

- Removed `useStartReview` import
- Removed `useUserSystem` import (now unused)
- Removed `startReview` hook usage
- Removed `handleStartReview` function
- Removed "Start Review" menu item from the dropdown

* Done. The fix adds the `ReviewRequest` case to `latest_executor_profile_for_session()` in `crates/db/src/models/execution_process.rs:688-690`.

The backend check passes. Follow-ups after reviews should now work correctly since the executor profile can be extracted from `ReviewRequest` just like from the other request types.

* Done. Removed `CommitRange` enum entirely. Changes:

1. **`crates/executors/src/actions/review.rs`** - Deleted `CommitRange` enum, changed `RepoReviewContext.commits` to `RepoReviewContext.base_commit: String`

2. **`crates/server/src/routes/sessions/review.rs`** - Updated construction to use `base_commit: initial_commit` instead of `commits: CommitRange::FromBase { commit: initial_commit }`

3. **`crates/executors/src/executors/mod.rs`** - Simplified `build_review_prompt()` to directly use `repo.base_commit` instead of matching on the enum

4. **`crates/server/src/bin/generate_types.rs`** - Removed `CommitRange::decl()` from type exports

5. **`shared/types.ts`** - Regenerated, `CommitRange` type is now gone

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Done. Simplified the review context building:

**Changes:**

1. **`crates/db/src/models/execution_process_repo_state.rs`** - Replaced `find_initial_commits_for_workspace` with `find_initial_commit_for_repo` that takes a specific repo_id and uses ORDER BY + LIMIT 1 instead of GROUP BY/HAVING.

2. **`crates/server/src/routes/sessions/review.rs`** - Simplified the context building:
   - Get workspace repos first (has repo names via `display_name`)
   - For each repo, get initial commit
   - Build context directly - no more HashMap joining, no more separate `Repo::find_by_ids` call

The new code is much easier to follow: get repos → for each, get initial commit → build context.

* Done. Addressed all 23 review comments:

1. Removed comment from `SessionChatBoxContainer.tsx` (line 161)
2. Removed doc comments from `RepoReviewContext` and `ReviewRequest` structs in `review.rs`
3. Removed module doc comment from `codex/review.rs`
4. Removed comment from `codex.rs` about Custom review target
5. Removed doc comments from `spawn_review` trait method in `mod.rs`
6. Removed doc comment from `build_review_prompt` function
7. Removed all comments from `sessions/review.rs` (doc comments and inline comments)
8. Removed unused `get_commits_since_branch` function from `git.rs` (~45 lines of dead code)

* Done. Added the review toggle button:

**Changes:**

1. **`SessionChatBox.tsx`**
   - Added `ReviewModeProps` interface with `isActive`, `onToggle`, `isSubmitting`
   - Added `reviewMode` prop to `SessionChatBoxProps`
   - Added toggle button next to attach button (MagnifyingGlassIcon) - highlighted when active
   - Updated placeholder to show "Enter review instructions..." when in review mode
   - Removed old `onStartReview` and `isReviewStarting` from SessionProps
   - Removed "Start Review" dropdown menu item

2. **`SessionChatBoxContainer.tsx`**
   - Added `useState` for `isReviewMode`
   - Updated `handleSend` to call `startReviewMutation` with `additionalPrompt` when in review mode
   - Reset review mode after successful review start
   - Pass `reviewMode` props to SessionChatBox
   - Removed old `handleStartReview` callback

Now the user can:
1. Click the magnifying glass toggle next to attach
2. Enter review instructions in the text area
3. Click send → starts review with the prompt

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

TypeScript and Rust both compile. The changes are:
1. Button shows "Review" when review mode is active
2. Toggle icon uses `!text-accent-foreground` to force override the `text-low` class from the base component, along with `bg-accent rounded-sm` for the background highlight

Done. Changed `!text-accent-foreground` to `!text-normal` which uses the design system's proper text color for active/selected states. The `!` prefix forces the override of the base `text-low` class. Both TypeScript and Rust compile successfully.

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

All done. TypeScript and Rust compile successfully. Here's a summary of the changes:

**Created:**
- `frontend/src/components/dialogs/tasks/StartReviewDialog.tsx` - New dialog with:
  - Agent/variant selection (using ExecutorProfileSelector)
  - Review comments preview (if any)
  - Additional instructions textarea
  - Start Review / Cancel buttons

**Modified:**
- `frontend/src/components/dialogs/index.ts` - Added export for StartReviewDialog
- `frontend/src/components/ui-new/primitives/SessionChatBox.tsx`:
  - Changed `ReviewModeProps` from toggle state to simple callback (`onReviewClick`, `isDisabled`)
  - Removed toggle styling and review mode button text
  - Button now just opens the dialog
- `frontend/src/components/ui-new/containers/SessionChatBoxContainer.tsx`:
  - Removed `isReviewMode` state and `startReviewMutation`
  - Added `handleReviewClick` callback that opens `StartReviewDialog`
  - Disabled review button when in new session mode or no session exists

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

Done. TypeScript and Rust compile successfully. Summary of changes:

**`StartReviewDialog.tsx`:**
- Added "New Session" toggle (defaults ON when no session exists, disabled when no session to toggle from)
- Added conditional `AgentSelector` - only shown when creating a new session
- Always shows `ConfigSelector` for variant selection
- Handles session creation inline when toggle is on or no session exists
- Updated `onSuccess` callback to return new session ID when created

**`SessionChatBox.tsx`:**
- Removed `isDisabled` from `ReviewModeProps` interface
- Removed `reviewMode.isDisabled` from button disabled logic

**`SessionChatBoxContainer.tsx`:**
- Updated `handleReviewClick` to allow opening dialog without sessionId
- Updated `onSuccess` callback to select the new session if one was created
- Removed `isDisabled` from reviewMode prop

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

Done. Made `reviewMode` required and removed the conditional - the review button is now always shown.

Done. Now the StartReviewDialog:
- Shows `ExecutorProfileSelector` (Agent + Configuration side by side, like CreateAttemptDialog) when "New Session" toggle is ON
- Shows just `ConfigSelector` (variant only) when "New Session" toggle is OFF

TypeScript and Rust compile successfully. The Switch layout has been fixed to match the TaskFormDialog pattern:
- Switch is now on the LEFT of the label
- Uses `gap-2` instead of `justify-between`
- Has proper dark mode styling with `data-[state=checked]:bg-gray-900 dark:data-[state=checked]:bg-gray-100`
- Label has `cursor-pointer` for better UX

Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

Done. The Switch is now moved to the footer (bottom of the dialog), matching the TaskFormDialog pattern:
- Switch on the left side of the footer
- Cancel and Start Review buttons on the right side
- Added `disabled:opacity-50` for better visibility when disabled in dark mode

Done. All changes complete:

1. **Removed header** - No more "Start Review" title or description
2. **Removed labels from selectors** - `showLabel={false}` for both `ExecutorProfileSelector` and `ConfigSelector`
3. **Fixed footer layout** - Cancel button on left, Switch + "New Session" + "Start Review" button grouped on right (matching TaskFormDialog)
4. **TypeScript compiles** - Both frontend and backend checks pass

Done. Changes made:

1. **Moved selector to bottom** - Now the order is: Additional Instructions textarea → Review comments preview → Error → Profile/Config selector → Footer

2. **Fixed Switch visibility** - Changed from `data-[state=checked]:bg-gray-900 dark:data-[state=checked]:bg-gray-100` to `bg-muted-foreground/30 data-[state=checked]:bg-foreground` using semantic colors

3. **TypeScript compiles** - Both frontend and backend checks pass

Done. The Switch className now uses `!` important modifiers to override the component's hardcoded background colors:
- `!bg-muted-foreground/30` - visible gray background when unchecked (overrides `bg-input`)
- `data-[state=checked]:!bg-foreground` - foreground color when checked (overrides `bg-foreground`)

Done. Changed the Switch className to use `!bg-muted` which should provide better contrast against the dialog's `bg-primary` background.

Done. Changed the Switch className to use `!bg-border` which should provide some contrast against the dialog's `bg-primary` background (25% lightness vs 18% lightness).

* Fix duplicate routes

* I've analyzed the problem. Here's my understanding:

**The issue:** After rebasing, stored commit SHAs (`after_head_commit`) become invalid because rebasing rewrites history with new SHAs.

**Your suggestion (`git diff A^..B`):** This still has the same problem - after rebase, commit `A` doesn't exist with that SHA anymore. `A^` requires resolving commit `A` first.

**My recommended fix:** Instead of using stored commit SHAs, use the **branch name** as the base:
- `git diff {target_branch}..HEAD` instead of `git diff {commit_sha}..HEAD`
- This is always valid regardless of rebasing
- Matches user intent: "show all changes on this workspace branch vs base"

This would require changes to:
1. `review.rs` - use `workspace.target_branch` instead of querying `find_first_commit_for_repo`
2. `build_review_prompt` - update to use branch name
3. `RepoReviewContext` - change `base_commit` to `base_branch`

**Questions:**
1. Is using `target_branch` the right base? Or do you need something more granular like "changes since session X"?
2. Should we keep `before_head_commit`/`after_head_commit` for per-execution tracking, or simplify?

* Done. Here's a summary of the changes:

## Changes Made

### 1. `crates/services/src/services/git/cli.rs`
- Made `merge_base` method public (was `fn`, now `pub fn`)

### 2. `crates/services/src/services/git.rs`
- Added new public method `get_fork_point()` that wraps the CLI `merge_base` function
- This method uses `git merge-base --fork-point` which survives rebasing by consulting the reflog

### 3. `crates/server/src/routes/sessions/review.rs`
- Removed import of `ExecutionProcessRepoState` (no longer needed)
- Added `PathBuf` import
- Changed from querying stored `after_head_commit` SHAs to computing fork-point dynamically
- Now uses `WorkspaceRepo::find_repos_with_target_branch_for_workspace` to get per-repo target branches
- Computes `get_fork_point(repo_path, target_branch, workspace.branch)` for each repo

## How It Works Now

Instead of storing commit SHAs that become invalid after rebasing:
```rust
// Old (broken after rebase):
let base_commit = ExecutionProcessRepoState::find_first_commit_for_repo(...)
```

We now compute the fork-point dynamically:
```rust
// New (survives rebasing):
let base_commit = deployment.git().get_fork_point(
    &repo_path,
    &repo.target_branch,  // e.g., "main"
    &workspace.branch,     // e.g., "vk/task-123"
)
```

This uses `git merge-base --fork-point` which consults the reflog to find where the branch originally diverged, regardless of subsequent rebases.

* Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Removed the unused `find_first_commit_for_repo` function. Everything still compiles.

* All comments removed and code still compiles.

* Fixed. The changes:

1. Added `effective_dir` method to `ReviewRequest` in `crates/executors/src/actions/review.rs`
2. Updated `container.rs` to use `request.effective_dir(&workspace_root)` instead of `workspace_root.clone()` for `ReviewRequest`

Now the log normalization for reviews will use the correct working directory, matching how the agent is actually spawned.

* Fixed. Now the workspace is re-fetched after `ensure_container_exists` to get the updated `container_ref`.

* Fixed. Now using the `container_ref` returned directly from `ensure_container_exists` instead of re-fetching the workspace.

* Fixed the naming:
- `workspace_path` - the container_ref path containing all repos
- `worktree_path` - the path to a specific repo's worktree within the workspace

* Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Done. I've added an "Include git context" checkbox to the StartReviewDialog:

- Added state `includeGitContext` defaulting to `true`
- Added a checkbox UI with label "Include git context"
- The checkbox value is passed to the API as `use_all_workspace_commits`

The checkbox appears after the error message area and before the executor profile selector. Users will see it checked by default, making it clear that git context is being included without needing to add it themselves in the prompt.

* I've completed the i18n task. Here's a summary of what was done:

1. **Added i18n support to `StartReviewDialog.tsx`**:
   - Imported `useTranslation` from `react-i18next`
   - Replaced all hardcoded strings with translation keys:
     - "Additional Instructions (optional)" → `t('startReviewDialog.additionalInstructions')`
     - "Review Comments (...)" → `t('startReviewDialog.reviewComments', { count: ... })`
     - "Include git context" → `t('startReviewDialog.includeGitContext')`
     - "New Session" → `t('startReviewDialog.newSession')`
     - "Cancel" → `t('common:buttons.cancel')`
     - "Starting..." / "Start Review" → `t('actionsMenu.startingReview')` / `t('actionsMenu.startReview')`

2. **Added translations to all locale files** (`en`, `es`, `ja`, `ko`, `zh-Hans`, `zh-Hant`):
   - Added `startReviewDialog` object with `additionalInstructions`, `reviewComments`, `includeGitContext`, and `newSession` keys
   - Added `actionsMenu.startReview` and `actionsMenu.startingReview` to all non-English locales

3. **Verified with i18n check script**: All checks pass - no new literal strings introduced, no duplicate keys, and translation keys are consistent across all locales.

* Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* All checks pass. I've added a description below the "Include git context" checkbox:

**English:** "Tells the agent how to view all changes made on this branch"

The description appears as smaller muted text below the checkbox, explaining to users what the option does - it instructs the agent how to see all the changes on this branch (via the git diff command we inject). This helps users understand they don't need to manually ask the agent about branch changes.

* Done. Here's a summary of the changes:

1. **Replaced conditional rendering** with always showing both `AgentSelector` and `ConfigSelector`

2. **Agent selector is disabled** when `createNewSession` is false (locked to the session's executor)

3. **Fixed the variant retention bug** by adding `handleNewSessionChange` that resets `selectedProfile` to `defaultProfile` when toggling "New Session" off - this ensures the variant matches the locked executor

* Types

* Removed the unused `useStartReview` hook and its export from `hooks/index.ts`.

* All checks pass. Here's a summary of the changes made:

**`frontend/src/components/ui-new/actions/index.ts`:**
1. Added `HighlighterIcon` to the Phosphor icons import (line 33)
2. Added `StartReviewDialog` import (line 49)
3. Added `StartReview` action definition (lines 293-304) with:
   - `id: 'start-review'`
   - `label: 'Start Review'`
   - `icon: HighlighterIcon`
   - `requiresTarget: true`
   - Visibility when workspace exists
   - Execute function that opens `StartReviewDialog`

**`frontend/src/components/ui-new/actions/pages.ts`:**
1. Added `{ type: 'action', action: Actions.StartReview }` as the first item in the `workspaceActions` page group (line 105)

The "Start Review" action with the highlighter icon will now appear in the workspace actions menu (accessed via CMD+K or the three-dots menu on a workspace).

* All checks pass. Done. Here's a summary of the additional change:

**`frontend/src/components/ui-new/primitives/SessionChatBox.tsx`:**
- Changed `MagnifyingGlassIcon` to `HighlighterIcon` in the import (line 12)
- Updated the `ToolbarIconButton` to use `HighlighterIcon` instead of `MagnifyingGlassIcon` (line 635)

The review button in the text input now shows the highlighter icon instead of the magnifying glass.

* All checks pass. Here's a summary of the changes:

**`frontend/src/components/ui-new/primitives/Toolbar.tsx`:**
- Added proper disabled styling to `ToolbarIconButton` (`opacity-40 cursor-not-allowed`)

**`frontend/src/components/ui-new/primitives/SessionChatBox.tsx`:**
- Removed `HighlighterIcon` import (no longer hardcoded)
- Added `Icon` type import
- Replaced `ReviewModeProps` with generic `ToolbarActionProps` interface (`icon`, `label`, `onClick`)
- Changed `reviewMode` prop to `toolbarActions?: ToolbarActionProps[]`
- Updated footer to render toolbar actions dynamically from the array

**`frontend/src/components/ui-new/containers/SessionChatBoxContainer.tsx`:**
- Added `HighlighterIcon` import
- Changed `reviewMode` prop to `toolbarActions` array with the review action

The button is now:
1. Generic - accepts any action with icon/label/onClick
2. Shows proper disabled state (opacity + cursor)
3. Extensible - you can add more toolbar actions by adding to the array

* All checks pass. Now toolbar actions work identically to navbar actions:

**Summary of changes:**

1. **`SessionChatBox.tsx`**:
   - Changed `toolbarActions` prop from simple `{icon, label, onClick}[]` to `{actions, context, onExecuteAction}` structure
   - Uses `ActionDefinition[]` from the actions system
   - Uses `isActionEnabled()` to derive disabled state from action context
   - Uses `isSpecialIcon()` to filter out non-standard icons
   - Handles `label` being either a string or function

2. **`SessionChatBoxContainer.tsx`**:
   - Added `useActions()` and `useActionVisibilityContext()` hooks
   - Created `handleToolbarAction` callback that routes actions through `executeAction`
   - Created `toolbarActionsList` array containing `Actions.StartReview`
   - Passes the full action context to `SessionChatBox`

Now adding a new action to the conversation input works the same as navbar:

```typescript
// Just add to the array
const toolbarActionsList = useMemo(
  () => [Actions.StartReview, Actions.SomeOtherAction],
  []
);
```

The action's `isVisible`, `isEnabled`, icon, label, and execute logic all come from the central `Actions` definition in `index.ts`.

* Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Done. The "Start Review" action with the highlighter icon now appears in both the navbar (left side) and the chat input toolbar.

* Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Done. Removed `StartReview` from the navbar and added `ToggleChangesMode` to the conversation input toolbar alongside `StartReview`.

* Done.

* Removed the review-specific branch so the handler is generic, matching other containers. The toolbar action now just respects `requiresTarget`.

Details and context:
- Simplified the action handler in `frontend/src/components/ui-new/containers/SessionChatBoxContainer.tsx:444` to rely solely on the generic `action.requiresTarget` path.
- This aligns with `frontend/src/components/ui-new/containers/NavbarContainer.tsx:66`, where all actions flow through the same generic logic.

Next steps:
1) If you want, I can run a quick lint/typecheck on the frontend (`pnpm run check`) to confirm.

* Aligned the chatbox to use the shared visibility system, like the navbar, so action availability is handled by the same logic and execution stays generic.

Details and context:
- Filtered `toolbarActionsList` through `isActionVisible` with the shared `actionCtx` so Start Review only appears when it’s supposed to.
- Kept the execution handler generic so it just respects `requiresTarget`.

Files:
- `frontend/src/components/ui-new/containers/SessionChatBoxContainer.tsx`

Next steps:
1) If you want me to run a quick frontend typecheck (`pnpm run check`), say the word.

* Cleanup script changes for workspace 38f8b607-9fdc-43dc-afa3-16e8f5e9cbd3

* Updated the Start Review dialog so it derives the active session and a default executor profile from workspace context + config, which restores preselection and enables the “new session” toggle when a session exists. This keeps the chatbox action generic while fixing the dialog behavior.

Details and context:
- Added workspace context awareness and default profile derivation (mirrors Create Attempt’s logic).
- Uses the resolved session id to enable/disable the toggle and to decide whether a new session is required.
- Keeps user selection override behavior intact.

File:
- `frontend/src/components/dialogs/tasks/StartReviewDialog.tsx`

If you want, I can also add a quick regression check or walk through the UI flow with you.

* Fixed the lint issue and clippy qa-mode compile warning, then reran the requested commands. The Start Review dialog now uses `resolvedSessionId` consistently in its callback, and review log normalization handles qa-mode without unused vars.

Files updated:
- `frontend/src/components/dialogs/tasks/StartReviewDialog.tsx`
- `crates/services/src/services/container.rs`

Commands run:
- `npm run lint`
- `npm run format`
- `npm run check`

* Renamed the match binding to `_request` so we don’t need the no-op line, and removed the comment you flagged.

Notes:
- The `let _ = request;` was only there to silence an unused-var warning under the `qa-mode` cfg. Using `_request` is the standard way to mark it intentionally unused.

Files:
- `crates/services/src/services/container.rs`
- `frontend/src/components/ui-new/containers/SessionChatBoxContainer.tsx`

Want me to rerun `npm run lint` since this touched the linted files?

* Split the `ReviewRequest` arm by cfg so qa-mode uses `_request` and non-qa uses `request` normally—no dummy line needed.

File:
- `crates/services/src/services/container.rs`

* Done. The fix adds `ReviewRequest` to the match statement that creates `CodingAgentTurn` records. Now when a review is started, a `coding_agent_turn` row will be created with the review prompt, and the `agent_session_id` will be stored when Codex reports it. Subsequent follow-ups will find this session ID and correctly use `CodingAgentFollowUpRequest` instead of starting a fresh session.

* Done. Now if a new `ExecutorActionType` variant is added, the compiler will error on this match and force the developer to decide whether it should create a `CodingAgentTurn` record.

* Adjusted `sessionsApi.startReview` to return the unwrapped payload like other session calls, and aligned the `handleApiResponse` generic so callers get an `ExecutionProcess` instead of a misleading `ApiResponse`. This fixes the runtime mismatch and keeps the API consistent.

Updated `frontend/src/lib/api.ts`.

If you want, I can:
1) run `pnpm run check` to validate types, or
2) scan for any other session APIs with inconsistent `handleApiResponse` generics.

* All checks pass. Summary of changes:

1. **Removed tooltip from dialog button** - Dialog buttons don't use tooltips in this codebase
2. **Added `getTooltip` to the `StartReview` action definition** in `actions/index.ts` - This is the pattern used for action tooltips ("Ask the agent to review your changes")
3. **Removed `submitTooltip` from all locale files** since it's no longer used
4. **Added missing `title` and `description` to zh-Hant locale**

* Done. Now when a new session is created, the dialog will call `selectSession(targetSessionId)` to switch to the newly created session before closing.
2026-01-12 19:28:55 +00:00
Louis Knight-Webb
7bb16a798e The frontend TypeScript check passed without errors. (#1978)
The implementation is complete. The change removes the Bash-only restriction so that any tool with output (including MCP tools like `mcp:dev-manager:stop`) can now be clicked to view their results in the logs panel.

**Summary of changes:**
- **File:** `vibe-kanban/frontend/src/components/ui-new/NewDisplayConversationEntry.tsx`
- **Change:** Simplified `hasOutput` check in `ToolSummaryEntry` from `isBash && content && content.trim().length > 0` to just `content && content.trim().length > 0`
- **Effect:** MCP tool entries (and any other tool with output) are now clickable to view their JSON results in the logs panel
2026-01-12 17:49:52 +00:00
Alex Netsch
1ffb70869e Revert "Fix workspace sidebar ordering to use updated_at instead of created_at (Vibe Kanban) (#1965)" (#1974)
This reverts commit 8dc07ee2b2.
2026-01-12 17:17:48 +00:00
Louis Knight-Webb
572e9706e5 Prevent WorkspacesSidebar re-render on workspace switch (Vibe Kanban) (#1973)
* The refactoring is complete. Here's a summary of what was changed:

## Summary

**File modified:** `vibe-kanban/frontend/src/components/ui-new/containers/WorkspacesLayout.tsx`

**Change:** Restructured `renderContent()` so that `WorkspacesSidebar` is rendered **outside** the `ExecutionProcessesProvider`.

### Before:
```tsx
<ExecutionProcessesProvider key={`${selectedWorkspace?.id}-${selectedSessionId}`}>
  <ReviewProvider>
    <Allotment>
      <Allotment.Pane>{renderSidebar()}</Allotment.Pane>  // Inside provider
      <Allotment.Pane>...</Allotment.Pane>
      <Allotment.Pane>...</Allotment.Pane>
      <Allotment.Pane>...</Allotment.Pane>
    </Allotment>
  </ReviewProvider>
</ExecutionProcessesProvider>
```

### After:
```tsx
<Allotment>
  <Allotment.Pane>{renderSidebar()}</Allotment.Pane>  // OUTSIDE provider - won't remount

  <ExecutionProcessesProvider key={`${selectedWorkspace?.id}-${selectedSessionId}`}>
    <ReviewProvider>
      <>
        <Allotment.Pane>...</Allotment.Pane>
        <Allotment.Pane>...</Allotment.Pane>
        <Allotment.Pane>...</Allotment.Pane>
      </>
    </ReviewProvider>
  </ExecutionProcessesProvider>
</Allotment>
```

**Result:** When switching workspaces, the `ExecutionProcessesProvider`'s key changes, which unmounts/remounts only panes 2-4. The sidebar pane stays mounted and won't re-render unnecessarily.

* The implementation is complete. Here's a summary of what was changed:

## Summary

**File modified:** `vibe-kanban/frontend/src/components/ui-new/containers/WorkspacesLayout.tsx`

### Changes:

1. **Created nested Allotments structure:**
   - **Outer Allotment** (2 panes): Sidebar + Content container
   - **Inner Allotment** (3 panes): Main + Changes/Logs + Git Panel

2. **Separated resize handlers:**
   - `handleOuterPaneResize`: Handles sidebar width only
   - `handleInnerPaneResize`: Handles main, changes/logs, and git panel widths

3. **Removed old `handlePaneResize`** which was designed for the flat 4-pane structure

### Result:
```
Outer Allotment
├── Sidebar Pane (OUTSIDE providers - won't remount)
└── Content Pane
    └── ExecutionProcessesProvider (keyed)
        └── ReviewProvider
            └── Inner Allotment
                ├── Main Pane
                ├── Changes/Logs Pane
                └── Git Panel Pane
```

Now when switching workspaces:
- The `ExecutionProcessesProvider` with its key will remount the inner Allotment (ensuring clean state)
- The sidebar stays mounted because it's outside the keyed provider
- Layout looks the same as before (sidebar on left, 3 panes on right)
2026-01-12 17:14:48 +00:00
GitHub Action
2c474d689c chore: bump version to 0.0.149 2026-01-12 16:57:54 +00:00
Louis Knight-Webb
7b30a4908e Script Fixer Dialog (Vibe Kanban) (#1968)
* All checks pass. Let me provide a summary of what was implemented:

## Summary

I've implemented the Script Fixer Dialog feature. Here's what was created and modified:

### New File Created:
1. **`frontend/src/components/dialogs/scripts/ScriptFixerDialog.tsx`** - A new dialog component that:
   - Shows the current script content in an editable textarea
   - Displays the last execution logs using `VirtualizedProcessLogs`
   - Provides "Save" and "Save and Test" buttons
   - Supports both setup scripts and dev server scripts
   - Handles multi-repo scenarios with a repo selector dropdown

### Files Modified:

**New UI (Setup Script):**
1. **`ChatScriptEntry.tsx`** - Added `onFix` prop and a "Fix Script" button that appears when a script fails
2. **`NewDisplayConversationEntry.tsx`** - Added `ScriptEntryWithFix` wrapper component that provides the fix handler to `ChatScriptEntry`

**Legacy UI (Setup Script):**
3. **`DisplayConversationEntry.tsx`** - Added `ScriptFixButton` component that renders a fix button for failed scripts in the legacy conversation view

**Preview/Dev Server:**
4. **`PreviewPanel.tsx`** - Added "Fix Script" button to the troubleshooting alert when dev server has issues
5. **`PreviewBrowser.tsx`** - Added optional `handleFixDevScript` prop and "Fix Script" button alongside "Start Server"
6. **`PreviewBrowserContainer.tsx`** - Wired up the dialog opening for dev server script fixes
7. **`PreviewControls.tsx`** - Added `onFixScript` prop and "Fix Script" button in the dev server controls
8. **`PreviewControlsContainer.tsx`** - Wired up the dialog opening for the controls

**Translations:**
9. **`tasks.json` (English)** - Added `scriptFixer` translation keys

* Cleanup script changes for workspace 5496d4c0-d1d3-4e6a-b9d0-6a421270eeac

* Type check passes. I've updated the `ScriptFixerDialog` to also start the dev server when "Save and Test" is clicked for dev_server script type.

* Done! I've updated the `ScriptFixerDialog` to:

1. **Keep the dialog open after "Save and Test"** - The dialog no longer closes after clicking "Save and Test", so the user can watch the logs update in real-time as the script executes

2. **Changed "Cancel" to "Close"** - The button now says "Close" (using `t('common:close')`) and is always enabled, making it clear the user can close the dialog at any time

3. **Logs update automatically** - The `useExecutionProcesses` and `useLogStream` hooks will automatically pick up the new execution process and stream its logs in real-time

* Cleanup script changes for workspace 5496d4c0-d1d3-4e6a-b9d0-6a421270eeac

* Done! I've fixed the horizontal overflow by adding `min-w-0` to all flex containers and `overflow-hidden` to the `DialogContent`. This prevents flex children from overflowing their container horizontally.

* The type check passes. The fix has been applied - the width constraints (`max-w-4xl w-[90vw]`) are now on the `Dialog` component instead of `DialogContent`. This will override the default `max-w-xl` from the Dialog component's base className, allowing the dialog to be wider and preventing horizontal overflow.

* Done! I've added the status indicator to the ScriptFixerDialog. Here's what was implemented:

**Changes made:**

1. **`ScriptFixerDialog.tsx`:**
   - Added import for `RunningDots` component
   - Added status computation logic to determine if the process is running, succeeded, failed, or killed
   - Added status indicator UI next to the "Last Execution Logs" label showing:
     - Animated dots + "Running..." when the script is executing
     - Green dot + "Completed successfully" when script succeeded (exit code 0)
     - Red dot + "Failed with exit code X" when script failed
     - Gray dot + "Process was killed" when killed

2. **`tasks.json` (translations):**
   - Added `statusRunning`, `statusSuccess`, `statusFailed`, and `statusKilled` translation keys

The status indicator will update in real-time as the script executes since it's computed from `latestProcess` which is updated via the `useExecutionProcesses` hook.

* Fixed! The issue was that `exit_code` can be `null` when the process completes successfully, and comparing `null !== BigInt(0)` returns `true`, which incorrectly triggered the error state.

The fix:
- Treat `exit_code === null` as success (same as exit code 0)
- Only show error when `exit_code` is explicitly a non-zero value

* Fixed. The issue was that `exit_code` comes back as a regular number `0` from the API, but the TypeScript type says `bigint`. Using `Number(exitCode) === 0` handles both cases correctly and satisfies the type checker.

* Fixed! The translation key was missing the `buttons.` namespace prefix. It now uses `t('common:buttons.close')` which maps to "Close".

* Done. Added `bg-error` and `text-error` classes alongside the `destructive` classes for the error state.

* styles

* Done! I've fixed the issue by passing `sessionId` to the `ScriptFixerDialog` in all three files:

1. **`PreviewPanel.tsx`** - Gets `sessionId` from `devServerProcesses[0]?.session_id`
2. **`PreviewBrowserContainer.tsx`** - Added `devServerProcesses` to destructuring from `usePreviewDevServer` and passes `sessionId`
3. **`PreviewControlsContainer.tsx`** - Already had `devServerProcesses`, just added `sessionId` to the dialog call

Now when you click "Save and Test" for a dev server script, the dialog will receive the session ID, connect to the WebSocket stream, and show the execution logs in real-time.

* rollback trigger the ScriptFixer for old UI

* Done! I've extended the ScriptFixerDialog to support cleanup scripts. Here's a summary of the changes:

**1. `frontend/src/i18n/locales/en/tasks.json`**
- Added `cleanupScriptTitle: "Fix Cleanup Script"` translation key

**2. `frontend/src/components/dialogs/scripts/ScriptFixerDialog.tsx`**
- Updated `ScriptType` from `'setup' | 'dev_server'` to `'setup' | 'cleanup' | 'dev_server'`
- Updated `latestProcess` filter to use `'cleanupscript'` run_reason for cleanup scripts
- Updated script fetching logic to read `cleanup_script` field
- Updated both `handleSave` and `handleSaveAndTest` to save `cleanup_script` field
- Updated execution logic to call `attemptsApi.runCleanupScript(workspaceId)` for cleanup scripts
- Updated dialog title to show "Fix Cleanup Script" for cleanup type
- Updated placeholder text to show `#!/bin/bash\nrm -rf node_modules` for cleanup scripts

**3. `frontend/src/components/ui-new/NewDisplayConversationEntry.tsx`**
- Fixed the scriptType mapping so "Cleanup Script" maps to `'cleanup'` instead of incorrectly mapping to `'setup'`

* All tasks are complete. Here's a summary of the changes I made:

## Summary

I've implemented the ScriptFixerDialog in the old UI for both `DisplayConversationEntry.tsx` and `PreviewPanel.tsx`.

### Changes Made:

**1. `DisplayConversationEntry.tsx`** (`frontend/src/components/NormalizedConversation/DisplayConversationEntry.tsx`):
- Added imports for `ScriptFixerDialog`, `ScriptType`, `useAttemptRepo`, `Button`, and `Wrench` icon
- Added `SCRIPT_TOOL_NAMES` constant to identify script entries
- Added `getScriptType()` helper function to map tool names to script types
- Created `ScriptToolCallCard` component that wraps `ToolCallCard` and adds a "Fix Script" button for failed scripts
- Modified `renderToolUse()` to detect script entries and render them with `ScriptToolCallCard`

**2. `PreviewPanel.tsx`** (`frontend/src/components/panels/PreviewPanel.tsx`):
- Added imports for `ScriptFixerDialog`, `useAttemptRepo`, and `Wrench` icon
- Added `useAttemptRepo(attemptId)` hook to get repos
- Added `handleFixDevScript()` function that opens the ScriptFixerDialog
- Added `canFixDevScript` computed value
- Added "Fix Dev Script" button in the troubleshooting alert next to the "Stop and Edit" button

**3. Translation Keys**:
- Added `conversation.fixScript: "Fix Script"` in `en/common.json`
- Added `preview.troubleAlert.fixScript: "Fix Dev Script"` in `en/tasks.json`

The implementation follows the same pattern as the new UI's `ScriptEntryWithFix` component in `NewDisplayConversationEntry.tsx`, using `useAttemptRepo` hook to fetch repos instead of `useWorkspaceContext` (which is only available in the new design scope).

* Cleanup script changes for workspace 5496d4c0-d1d3-4e6a-b9d0-6a421270eeac

* All tasks are complete. Here's a summary of the fixes made:

## Summary of Changes

### Problem
The "Fix Dev Script" button was only showing in the troubleshooting alert, which only appears when a dev server is **running** but slow to respond. When the dev server script **fails to start** (exits with error), there are no running dev servers, so the user saw `NoServerContent` without any fix option.

### Solution

**1. `PreviewPanel.tsx`** - Added failed dev server detection:
```typescript
const failedDevServerProcess = devServerProcesses.find(
  (p) =>
    p.status === 'failed' ||
    (p.status === 'completed' && p.exit_code !== null && p.exit_code !== 0n)
);
const hasFailedDevServer = Boolean(failedDevServerProcess);
```
And passed `hasFailedDevServer` and `onFixDevScript` to `NoServerContent`.

**2. `NoServerContent.tsx`** - Added new props and "Fix Dev Script" button:
- Added `hasFailedDevServer?: boolean` and `onFixDevScript?: () => void` props
- Added fix button that shows when dev server has failed

**3. Translation Keys** - Added `preview.noServer.fixScript: "Fix Dev Script"` to `en/tasks.json`

Now when a user tries to start a dev server and it fails, they'll see the "Fix Dev Script" button in the `NoServerContent` view, allowing them to open the ScriptFixerDialog to fix the script.

* Done! I've successfully added all the Script Fixer i18n translations to the 5 non-English locale files:

**Summary of changes:**

### common.json files (5 files updated)
Added `fixScript` key to the `conversation` section:
- **es**: `"Corregir Script"`
- **ja**: `"スクリプトを修正"`
- **ko**: `"스크립트 수정"`
- **zh-Hans**: `"修复脚本"`
- **zh-Hant**: `"修復腳本"`

### tasks.json files (5 files updated)
1. Added `fixScript` to `preview.noServer` section
2. Added `fixScript` to `preview.troubleAlert` section
3. Added the entire `scriptFixer` section with 17 keys including:
   - `title`, `setupScriptTitle`, `cleanupScriptTitle`, `devServerTitle`
   - `scriptLabel`, `logsLabel`
   - `saveButton`, `saveAndTestButton`, `saving`, `testing`
   - `noLogs`, `selectRepo`, `fixScript`
   - `statusRunning`, `statusSuccess`, `statusFailed`, `statusKilled`

All type checks (`pnpm run check`) passed successfully.

* Both lint and type check pass now. Here's a summary of the lint fixes I made:

**Fixed lint issues in:**

1. **`ScriptFixerDialog.tsx`** (lines 198 and 253):
   - Added missing `repos` dependency to both `handleSave` and `handleSaveAndTest` useCallback hooks
   - Removed unnecessary `modal` dependency from `handleSaveAndTest`

2. **`NewDisplayConversationEntry.tsx`** (line 658):
   - Used a `useRef` pattern to access `repos` inside the `handleFix` callback without including it in the dependency array, since the `repos` array is recreated on every render from context

* All checks pass. The fix is complete.

**Summary:** The "Fix Script" button in `PreviewControls` will now only appear when the latest dev server process has a status of `'failed'`. When the dev server is running, completed successfully, or was killed by the user, the button will be hidden.
2026-01-12 16:54:38 +00:00
Louis Knight-Webb
6cb45f54c1 Fix search input losing focus when hovering over dropdown items (Vibe Kanban) (#1966)
* Done! Here's a summary of the changes:

## Changes Made

### 1. `Dropdown.tsx` (lines 140-190)
- Added `preventFocusOnHover?: boolean` prop to `DropdownMenuItemProps` interface
- Added `onPointerMove` handler that calls `e.preventDefault()` when `preventFocusOnHover` is true, which stops Radix from stealing focus on hover

### 2. `SearchableDropdown.tsx` (line 110)
- Added `preventFocusOnHover` prop to `DropdownMenuItem`

### 3. `ProjectSelectorContainer.tsx` (lines 181, 208)
- Added `preventFocusOnHover` prop to both `DropdownMenuItem` components (the "Create new project" button and the virtualized project items)

The fix uses `e.preventDefault()` on `onPointerMove` to disable Radix's hover-to-focus behavior, as documented in [Radix UI Issue #2193](https://github.com/radix-ui/primitives/issues/2193). This preserves all other functionality (click, keyboard navigation, selection) while allowing the search input to retain focus when hovering over items.

* Done! I've added the `onPointerLeave` handler to `DropdownMenuItem` alongside the existing `onPointerMove` handler. Both now call `e.preventDefault()` when `preventFocusOnHover` is true.

**Summary of the fix:**
- Added `onPointerLeave` destructuring from props (line 161)
- Added `onPointerLeave` handler that calls `e.preventDefault()` when `preventFocusOnHover` is true (lines 187-194)

Per the [Radix UI Issue #2193](https://github.com/radix-ui/primitives/issues/2193), **both** `onPointerMove` and `onPointerLeave` need `preventDefault()` to fully disable hover-to-focus behavior.
2026-01-12 15:16:33 +00:00
Alex Netsch
8dc07ee2b2 Fix workspace sidebar ordering to use updated_at instead of created_at (Vibe Kanban) (#1965)
* Done. I've updated the workspace sorting in `frontend/src/components/ui-new/hooks/useWorkspaces.ts` to use `updated_at` instead of `created_at`. Both active and archived workspaces will now be sorted by their most recent update time (with pinned workspaces still appearing first). All type checks and lint pass.

* Cleanup script changes for workspace 37e99d73-8ab0-4501-990e-1007d78e44aa
2026-01-12 14:34:29 +00:00
Anastasiia Solop
eff14ef094 Add Push button to Git panel when PR is open with unpushed commits (Vibe Kanban) (#1951)
* The implementation is complete. Here's a summary of what I changed:

## Summary

Added a "Push" button to the workspaces UI Git panel. The changes allow users to push changes when a PR is already open.

### Files Modified:

1. **`frontend/src/components/ui-new/primitives/RepoCard.tsx`** (lines 27-42)
   - Added `'push'` to the `RepoAction` type union
   - Added a new option to `repoActionOptions` array with the Push button configuration using `ArrowUpIcon`

2. **`frontend/src/components/ui-new/actions/index.ts`** (lines 33, 691-707)
   - Imported `ArrowUpIcon` from phosphor-icons
   - Added `GitPush` action definition that:
     - Calls `attemptsApi.push()` with the workspace and repo IDs
     - Handles the `force_push_required` error case
     - Invalidates workspace queries on success to refresh the UI

3. **`frontend/src/components/ui-new/containers/WorkspacesLayout.tsx`** (line 103)
   - Added mapping from `'push'` action to `Actions.GitPush` in the action handler

The Push button now appears in the Git panel dropdown alongside "Open pull request" and "Merge" options.

* The type check passes. Here's a summary of the updated changes:

## Summary

The Push button now appears **next to the PR number** when:
1. A PR is already open (`prStatus === 'open'`)
2. There are new commits ahead (`commitsAhead > 0`)

### Changes Made:

**`frontend/src/components/ui-new/primitives/RepoCard.tsx`**:
- Removed `push` from the `repoActionOptions` dropdown (lines 34-41)
- Added a dedicated Push button in the PR status row (lines 213-222) that:
  - Only appears when `prStatus === 'open'` AND `commitsAhead > 0`
  - Uses brand primary styling (`bg-brand-primary`) to make it prominent
  - Displays with an up arrow icon and "Push" label using existing translation
  - Calls `onActionsClick?.('push')` when clicked

The `GitPush` action and handler mapping from the previous changes remain in place to handle the push operation.

* Done. The Push button now uses the same styling as the "Open PR" button: `bg-panel text-normal hover:bg-tertiary`.

* The type check passes. Here's a summary of the fix:

## Summary

The Push button now correctly uses `remoteCommitsAhead` (unpushed commits to remote) instead of `commitsAhead` (total commits ahead of target branch) to determine when to show.

### Changes Made:

1. **`frontend/src/components/ui-new/views/GitPanel.tsx`**:
   - Added `remoteCommitsAhead: number` to the `RepoInfo` interface
   - Pass `remoteCommitsAhead` to `RepoCard`

2. **`frontend/src/components/ui-new/primitives/RepoCard.tsx`**:
   - Added `remoteCommitsAhead?: number` to `RepoCardProps`
   - Changed the push button condition from `commitsAhead > 0` to `remoteCommitsAhead > 0`

3. **`frontend/src/components/ui-new/containers/WorkspacesLayout.tsx`**:
   - Added `remoteCommitsAhead: repoStatus?.remote_commits_ahead ?? 0` to the `repoInfos` mapping

Now the Push button will:
- Only appear when there's an open PR AND there are unpushed commits (`remote_commits_ahead > 0`)
- Disappear after a successful push (when `remote_commits_ahead` becomes 0)
- Reappear when new commits are made locally that haven't been pushed

* The type check passes. Here's a summary of the changes:

## Summary

The Push button now hides immediately when clicked and only reappears when new commits are available:

### Changes to `RepoCard.tsx`:
- Added `useState` and `useRef` imports
- Added `isPushHidden` state to track when the button should be hidden
- Added `lastRemoteCommitsAhead` ref to track the previous value
- Added `useEffect` that resets `isPushHidden` to `false` when `remoteCommitsAhead` increases (meaning new commits are available)
- Added `handlePushClick` function that hides the button immediately and triggers the push action
- Updated the button condition to include `!isPushHidden`

The button will:
1. Hide immediately when clicked (no double-clicking possible)
2. Stay hidden until `remoteCommitsAhead` increases above the last known value
3. Reappear when new local commits are made that need to be pushed

* Both the linter and type check pass. The linter errors are fixed. Here's a summary of the changes:

## Summary of Linter Fixes

The linter was flagging that `RepoCard` (a presentational component) should not manage state or have side effects. I refactored the code to lift the state up to the container component:

### Changes:

1. **`RepoCard.tsx`** - Made purely presentational:
   - Removed `useState`, `useRef`, `useEffect` imports
   - Removed `remoteCommitsAhead` prop
   - Added `showPushButton` prop (boolean, controlled by parent)
   - Added `onPushClick` callback prop
   - The button now just renders based on `showPushButton` and calls `onPushClick`

2. **`GitPanel.tsx`** - Updated interface and props:
   - `RepoInfo` now has optional `remoteCommitsAhead` and `showPushButton` fields
   - Added `onPushClick` callback to `GitPanelProps`
   - Passes `showPushButton` and `onPushClick` to `RepoCard`

3. **`WorkspacesLayout.tsx`** - State management moved here:
   - Added `hiddenPushRepos` state (Set of repo IDs where push was clicked)
   - Added `lastRemoteCommitsAhead` ref to track previous values
   - Added `useEffect` to reset hidden state when `remoteCommitsAhead` increases
   - Added `repoInfosWithPushButton` memo that computes `showPushButton` for each repo
   - Added `handlePushClick` that hides button immediately and executes push action

* prettier fix

* Done. I've added `GitPush` to the Git actions list in the command bar. It now appears between "Merge" and "Rebase" in the Git Actions menu.

* Both type check and lint pass.

Done! The Push action in the command bar now has the same visibility conditions as in the Git panel - it only appears when:
1. There's a workspace
2. There are git repos
3. There's an open PR (`hasOpenPR`)
4. There are unpushed commits (`hasUnpushedCommits`)

### Summary of changes:

1. **`frontend/src/components/ui-new/actions/index.ts`**:
   - Added `hasOpenPR` and `hasUnpushedCommits` to `ActionVisibilityContext`
   - Updated `GitPush.isVisible` to check these new context properties

2. **`frontend/src/components/ui-new/actions/useActionVisibility.ts`**:
   - Added `useBranchStatus` hook to get branch status data
   - Computed `hasOpenPR` by checking if any repo has an open PR in merges
   - Computed `hasUnpushedCommits` by checking if any repo has `remote_commits_ahead > 0`
   - Added these values to the returned context

* The refactoring is complete. Here's a summary of the changes:

## Summary of Changes

The push button logic has been simplified by using React Query's mutation state instead of manually tracking hidden state with refs and effects.

### Key Changes:

1. **WorkspacesLayout.tsx (`GitPanelContainer`)**:
   - Removed the complex `useEffect` that tracked `lastRemoteCommitsAhead` and managed `hiddenPushRepos` state
   - Removed `hiddenPushRepos` state and `lastRemoteCommitsAhead` ref
   - Added `usePush` hook with callbacks that:
     - On success: awaits query invalidation before clearing the loading state
     - On error: clears the loading state
   - Added simple `pushingRepoId` state to track which repo is being pushed
   - The button now shows loading state during push and automatically disappears after refetch if `remoteCommitsAhead` becomes 0

2. **GitPanel.tsx**:
   - Added `isPushPending?: boolean` to `RepoInfo` interface
   - Passes `isPushPending` to `RepoCard`

3. **RepoCard.tsx**:
   - Added `isPushPending` prop
   - Button shows while either `showPushButton` or `isPushPending` is true
   - Button is disabled and shows spinner with "Pushing..." text when pending
   - Uses existing translation key `git.states.pushing`

### How it works now:

1. User clicks push button
2. Button immediately shows loading state (spinner + "Pushing...")
3. Button is disabled to prevent multiple clicks
4. Push mutation runs
5. On success, query invalidation completes before clearing loading state
6. Once `branchStatus` refetches, if `remoteCommitsAhead` is 0, `showPushButton` becomes false and button disappears
7. On error, loading state clears and button returns to normal

This approach is simpler and more predictable than manually tracking previous values.

* Done. The push button now shows success feedback like the old UI:

## Summary of Changes

The push button now has three states:

1. **Normal**: Shows "Push" with an up arrow icon
2. **Pending**: Shows "Pushing..." with a spinning icon, button is disabled
3. **Success**: Shows "Pushed!" with a green checkmark icon and green background for 2 seconds

The flow is:
1. User clicks "Push"
2. Button immediately shows "Pushing..." with spinner
3. Push completes, queries are invalidated and refetched
4. Button shows green "Pushed!" for 2 seconds
5. Button disappears (if no more commits to push) or returns to normal state

* All code review issues have been addressed:

## Summary of Changes

1. **Unified push logic** - Now uses `executeAction(Actions.GitPush, ...)` instead of calling `usePush` hook directly. This ensures consistent error handling between the button and command bar.

2. **Proper setTimeout cleanup** - Added `successTimeoutRef` with a cleanup effect that clears the timeout when the component unmounts:
   ```typescript
   const successTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);

   useEffect(() => {
     return () => {
       if (successTimeoutRef.current) {
         clearTimeout(successTimeoutRef.current);
       }
     };
   }, []);
   ```

3. **Error feedback** - Added error state handling:
   - New `isPushError` prop flows through GitPanel to RepoCard
   - Button shows red "Failed" with warning icon when push fails
   - Error state clears after 3 seconds
   - Added `git.states.pushFailed` translation key

4. **Simplified state management** - Changed from separate `pushingRepoId` and `pushSuccessRepoId` to a single `pushStates` record with `PushState` type (`'idle' | 'pending' | 'success' | 'error'`)

* All i18n checks pass now.

* Both code review issues have been addressed:

## Summary of Changes

### 1. Fixed stale closure issue
- Added a `pushStatesRef` that mirrors the `pushStates` state
- Changed the check from `pushStates[repoId]` to `pushStatesRef.current[repoId]`
- Removed `pushStates` from the dependency array

### 2. Added proper error logging and user-facing error message
- Modified `ActionsContext.tsx` to re-throw errors after showing the dialog, so callers can handle them
- Added `console.error('Push failed:', error)` for debugging purposes
- The error dialog is already shown by `executeAction` via `ConfirmDialog`
- The button now properly shows the error state when push fails

* fmt

* The fix is in place. The key change is:

- When we're in a "push flow" (state is `pending`, `success`, or `error`), we set `showPushButton: false` but the button remains visible because of the `isPushPending || isPushSuccess || isPushError` condition in RepoCard
- This prevents the race condition where the query refetch could hide the button before we set the success state

* All checks pass. The changes now:

1. **Reverted ActionsContext** - Removed the re-throw to maintain backwards compatibility
2. **Use `usePush` hook directly** - For proper success/error detection instead of going through `executeAction`
3. **Show error dialog manually** - Using `ConfirmDialog.show()` when push fails
4. **Track current repo with ref** - `currentPushRepoRef` tracks which repo is being pushed so callbacks can update the correct state

* All checks pass. Here's a summary of the force push handling:

## Force Push Functionality

Yes, force push is fully supported. Here's how it works:

**Old UI (`useGitOperations.ts`):**
1. When `usePush` fails with `errorData.type === 'force_push_required'`
2. It automatically shows `ForcePushDialog`
3. The dialog warns the user about the consequences and lets them confirm
4. If confirmed, it calls `useForcePush` to execute the force push

**New UI (now updated):**
1. When the push button is clicked and fails with `force_push_required`
2. The push state is reset to `idle` (so the button returns to normal)
3. `ForcePushDialog` is shown with the attemptId and repoId
4. User can confirm or cancel the force push from the dialog

The `ForcePushDialog` handles its own loading state, success/error feedback, and API call internally via `useForcePush` hook.

* clear pushStates on workspace change

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-12 15:13:57 +01:00
Gabriel Gordon-Hall
ea2a053403 I've made both changes: (#1962)
1. **Moved the Dev Server Script input** to be the first field in the Scripts & Configuration section (in `ReposSettings.tsx`)

2. **Updated the section description** in the English locale to mention "dev server" scripts: the description now reads "Configure dev server, setup, cleanup, and copy files for this repository..."
2026-01-12 12:55:43 +00:00
Alex Netsch
5ab75f0220 Done. I've updated the agent install hints across all 6 locales: (#1960)
**Changes made:**
- `notFound`: Changed from "Not Found" → "Unknown" (and equivalent in other languages)
- `notFoundTooltip`: Changed from "No previous usage detected. Agent may require installation and/or login." → "We couldn't verify this agent is set up, but go ahead and try it."

**Files modified:**
- `frontend/src/i18n/locales/en/settings.json`
- `frontend/src/i18n/locales/es/settings.json`
- `frontend/src/i18n/locales/ja/settings.json`
- `frontend/src/i18n/locales/ko/settings.json`
- `frontend/src/i18n/locales/zh-Hans/settings.json`
- `frontend/src/i18n/locales/zh-Hant/settings.json`

The new wording is softer and encourages users to just try the agent rather than assuming it's not installed.
2026-01-12 12:16:52 +00:00
Louis Knight-Webb
cf5b04d3b8 Increase max height of chat box (#1957)
I've successfully implemented the change to allow the `ChatBoxBase.tsx` to expand vertically up to 50% of the window height.

**Change made in** `vibe-kanban/frontend/src/components/ui-new/primitives/ChatBoxBase.tsx:144`:

```tsx
// Before:
className="min-h-0 max-h-[min(15rem,20vh)] overflow-y-auto"

// After:
className="min-h-0 max-h-[50vh] overflow-y-auto"
```

**What this does:**
- The old constraint `max-h-[min(15rem,20vh)]` limited the editor to whichever was smaller: 15rem or 20% of viewport height
- The new constraint `max-h-[50vh]` allows the editor to grow up to 50% of the viewport height
- The editor still starts small and only expands as content is added (due to `min-h-0`)
- `overflow-y-auto` ensures scrolling when content exceeds the max height

**Verification:**
-  TypeScript check passes (`pnpm run check`)
-  ESLint passes (`pnpm run lint`)
- The dev server was started and the change was tested in the browser (though the browser MCP encountered an issue during extended testing)
2026-01-12 12:16:12 +00:00
Louis Knight-Webb
8e7eb54313 Solve task follow up section infinite loop (#1955)
**Root cause:** The `switch` statement was missing a `default` case. When `typ.type` didn't match any handled case, the loop continued forever because `curr` was never updated.

**Changes made:**

1. **`vibe-kanban/frontend/src/utils/executor.ts`** (line 59-60): Added `default:` to fall through with `ScriptRequest`, advancing to the next action for any unhandled types.

2. **`vibe-kanban/frontend/src/components/tasks/TaskFollowUpSection.tsx`**:
   - Removed duplicate local `extractProfile` function (17 lines)
   - Added import from `@/utils/executor`
   - Updated usage to `extractProfileFromAction`

3. **`vibe-kanban/frontend/src/components/NormalizedConversation/RetryEditorInline.tsx`**:
   - Removed duplicate local `extractProfile` function (17 lines)
   - Added import from `@/utils/executor`
   - Updated usage to `extractProfileFromAction`

Both type checks (TypeScript and Rust/cargo) pass successfully.
2026-01-12 11:04:06 +00:00
Gabriel Gordon-Hall
8fa5b9d098 feat: remove agent_working_dir from settings (#1874)
* remove configurable agent_working_dir

(cherry picked from commit 285b3e04abceeb8e4a4ee1be16e3de97a8f32299)

* calculate agent_working_dir on create and start task

* i18n
2026-01-12 09:14:48 +00:00
Pedro Paixao
b6518fd930 fix: update font-feature-settings in diff-style-overrides.css (#1827)
* fix: update font-feature-settings in diff-style-overrides.css

Changed the font-feature-settings property for the diff-tailwindcss-wrapper to disable ligatures by setting it to "liga" off, ensuring consistent text rendering across different components.

* chore: run formatter

---------

Co-authored-by: Pedro <>
2026-01-12 08:48:35 +01:00
Louis Knight-Webb
d0a67aedf2 STDERR logs will now display in red using the correct Tailwind color class from the new design system. (#1927) 2026-01-11 09:12:09 +00:00
Anastasiia Solop
3d631defb4 Fix vertical scroll in the right panels in workspaces UI (#1925) 2026-01-11 09:21:44 +01:00
Gabriel Gordon-Hall
c5554610a9 feat: Repo level management (#1828)
* move dev server scripts onto project repos

* wip: move scripts onto Repo structs

* wip: repo settings page

* i18n and fixes

* fix refresh

* i18n

* nits

* clickable repo cards

* view logs for all dev servers

* updates to workspaces

* Let's make some changes to the way applications are tested: (vibe-kanban 4592de6c)

- When the user starts a dev server, we should automatically open the `PreviewPanel.tsx`
- In the preview panel, if no dev server script is set for any of the repos in the workspace show a message along these lines:

Vibe Kanban can run dev servers to help you test your changes. You can set this up in the repo settings area. You can learn more about testing applications here: https://www.vibekanban.com/docs/core-features/testing-your-application

- We should also not show the `PreviewControlsContainer.tsx` if none of the repos have a dev server script

`vibe-kanban/frontend/src/components/panels/PreviewPanel.tsx`

`vibe-kanban/frontend/src/components/ui-new/actions/index.ts`

`vibe-kanban/frontend/src/components/ui-new/containers/PreviewControlsContainer.tsx`

---------

Co-authored-by: Louis Knight-Webb <louis@bloop.ai>
2026-01-11 08:03:19 +00:00
Louis Knight-Webb
4e20df9823 Improve executor profile selection with save-as-default toggle and variant ordering (Vibe Kanban) (#1912)
* All implementations are complete. Here's a summary of the changes:

## Summary of Changes

### 1. `frontend/src/utils/executor.ts`
- Added `areProfilesEqual()` function to compare two `ExecutorProfileId` objects, treating `null`/`undefined` variant as equivalent to `"DEFAULT"`
- Updated `getVariantOptions()` to sort variants with DEFAULT first, then alphabetically

### 2. `frontend/src/components/ui-new/containers/CreateChatBoxContainer.tsx`
- Added `saveAsDefault` state (default: `false`)
- Added `hasChangedFromDefault` memo to detect when user has changed from their saved default
- Added `useEffect` to reset toggle when profile matches default again
- Updated `handleExecutorChange` to:
  - Use saved variant when switching TO the user's default executor
  - Fall back to DEFAULT variant otherwise
- Updated `handleSubmit` to save profile as default when toggle is checked
- Added `saveAsDefault` prop to `CreateChatBox`

### 3. `frontend/src/components/ui-new/primitives/CreateChatBox.tsx`
- Added `SaveAsDefaultProps` interface
- Added `saveAsDefault` prop to `CreateChatBoxProps`
- Rendered checkbox toggle in `headerLeft` (after executor dropdown) when `saveAsDefault.visible` is true

### 4. `frontend/src/i18n/locales/en/tasks.json`
- Added `"saveAsDefault": "Save as default"` translation key under `conversation`

* Cleanup script changes for workspace 143d0206-8a21-454b-96ad-ce53cbcfc24a

* All translations have been added:

| Language | Translation |
|----------|-------------|
| English (en) | "Save as default" |
| Spanish (es) | "Guardar como predeterminado" |
| Japanese (ja) | "デフォルトとして保存" |
| Korean (ko) | "기본값으로 저장" |
| Simplified Chinese (zh-Hans) | "设为默认" |
| Traditional Chinese (zh-Hant) | "設為預設" |
2026-01-10 12:26:17 +00:00
Louis Knight-Webb
d3dc1439cc Add PostHog analytics event for new UI access (Vibe Kanban) (#1895)
* Done. I've added PostHog analytics tracking to `NewDesignScope.tsx` that fires a `ui_new_accessed` event once per session when users visit any `/workspaces` route.

The implementation:
- Fires the event only once per session (using a `useRef` that resets on page refresh)
- Respects the user's analytics opt-in/opt-out preferences (handled by PostHog SDK)
- Located in `NewDesignScope` which wraps all new UI routes

* Use sessionStorage for true once-per-session tracking

The useRef approach only prevented duplicates within a single mount
lifecycle. If the user navigated away from /workspaces and back, the
component would remount and the ref would reset, firing the event again.

sessionStorage persists for the entire browser tab lifetime, ensuring
the event fires exactly once per session.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Revert to useRef for tracking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 12:02:09 +00:00
Louis Knight-Webb
4120678cf7 Done. The fix adds two lines to the GitCreatePR action in actions/index.ts: (#1911)
1. Fetches the workspace repos via `attemptsApi.getRepos(workspaceId)`
2. Finds the specific repo and passes its `target_branch` to `CreatePRDialog.show()`

This matches the pattern already used by the `GitRebase` action in the same file. Now when you create a PR from the workspaces (ui-new) layout, the base branch will correctly default to the workspace's target branch instead of the main repo's currently checked-out branch.
2026-01-10 12:01:49 +00:00
Louis Knight-Webb
e2fad0e10c The TypeScript check passed with no errors. The debounce pattern from VirtualizedProcessLogs.tsx has been successfully rolled out to ConversationList.tsx. (#1909)
## Summary

Added 100ms debounce to `ConversationList.tsx` matching the pattern in `VirtualizedProcessLogs.tsx`:

1. **Added refs** (lines 94-99): `pendingUpdateRef` to store pending updates and `debounceTimeoutRef` to track the timeout
2. **Modified `onEntriesUpdated`** (lines 115-149): Now stores updates in the ref and debounces state updates with a 100ms delay
3. **Added cleanup effect** (lines 107-113): Clears any pending timeout on unmount to prevent memory leaks
2026-01-10 11:18:44 +00:00
Louis Knight-Webb
a92c35d42e The TypeScript check passed with no errors. (#1910)
## Summary

I've implemented the fix for showing the left sidebar when entering `WorkspacesLayout.tsx` when no changes/preview/logs panel is open:

**Changes made to `vibe-kanban/frontend/src/components/ui-new/containers/WorkspacesLayout.tsx`:**

1. Added `setSidebarVisible` to the destructured values from `useLayoutStore()` (line 161)

2. Added a new `useEffect` (lines 333-338) that shows the sidebar whenever no panel is open:
   ```typescript
   useEffect(() => {
     if (!isChangesMode && !isLogsMode && !isPreviewMode) {
       setSidebarVisible(true);
     }
   }, [isChangesMode, isLogsMode, isPreviewMode, setSidebarVisible]);
   ```

This ensures that when the component mounts or when all panels are closed, the sidebar will automatically become visible.
2026-01-10 11:17:44 +00:00
Louis Knight-Webb
5ee40bf322 Improve diff viewer color styling for better theme support (Vibe Kanban) (#1894)
* improve diff styles

* diffs

* review comment styles
2026-01-10 11:10:02 +00:00
GitHub Action
bd09ba8bd0 chore: bump version to 0.0.148 2026-01-09 18:36:00 +00:00
Solomon
a9bc5f23e7 fix: empty process list regression (#1896)
* fix: empty process list regression

* tyecheck fix
2026-01-09 18:34:31 +00:00
Louis Knight-Webb
9aef10a1bb Done. I added min-w-0 to the URL bar container on line 68. This allows the flex container to shrink below its content size, enabling the truncate class on the URL text to work properly and prevent overflow. (#1892) 2026-01-09 17:20:13 +00:00
Louis Knight-Webb
6e3421c820 Fix CommandBar input and navigation issues with state machine refactor (Vibe Kanban) (#1885)
* Done! I've removed all 7 `shortcut` properties from the action definitions in `index.ts`:

- `NewWorkspace`: removed `shortcut: 'N'`
- `Settings`: removed `shortcut: ','`
- `ToggleSidebar`: removed `shortcut: '['`
- `ToggleGitPanel`: removed `shortcut: ']'`
- `ToggleChangesMode`: removed `shortcut: 'C'`
- `ToggleLogsMode`: removed `shortcut: 'L'`
- `TogglePreviewMode`: removed `shortcut: 'P'`

The `ActionDefinition` type (and its base `ActionBase` interface) were left unchanged as requested.

* fix tailwind nto auto creating styles

* I've successfully completed all the changes. Here's a summary of what was done:

## Summary of Changes

### 1. `ActionExecutorContext` (index.ts)
- Made all properties non-optional
- Removed `gitRepoId` from context (now passed as action parameter)
- Properties now use `| null` for values that may not exist

### 2. New `GitActionDefinition` Type (index.ts)
- Added new action type with `requiresTarget: 'git'`
- Git actions now explicitly require `repoId` as a parameter

### 3. Git Actions Updated (index.ts)
- `GitCreatePR`, `GitMerge`, `GitRebase`, `GitChangeTarget` now use `requiresTarget: 'git'`
- Each action's `execute` function takes `repoId` as third parameter
- Simplified implementations (no more fallback repo fetching logic)

### 4. `ActionsContext` Provider (ActionsContext.tsx)
- Now calls `useDevServer()` to get dev server state
- Provides all required context properties
- `executeAction` handles three action types: global, workspace, and git
- Removed `contextOverride` pattern

### 5. `ContextBarContainer` (ContextBarContainer.tsx)
- Simplified significantly - no longer builds extended context
- Uses executor context directly from provider
- Removed `containerPath` prop

### 6. `ActionVisibilityContext` (index.ts + useActionVisibility.ts)
- Made `editorType`, `devServerState`, `runningDevServerId` required
- Visibility hook now provides all values from hooks

### 7. Updated Call Sites
- `WorkspacesLayout`: Git actions now pass `repoId` as third parameter
- `WorkspacesMain`: Removed `containerPath` prop from ContextBarContainer

* Cleanup script changes for workspace e961e311-6db4-41bf-83a1-ef8dd96eb497

* All changes are complete and type checks pass. Here's a summary of the changes made:

## Summary of Changes

### 1. `ActionExecutorContext` - Made all properties non-optional
- Removed `?` from all properties
- Removed `gitRepoId` (moved to per-action parameter)
- Changed nullable properties to use `| null` type

### 2. New `GitActionDefinition` type
- Added new action type with `requiresTarget: 'git'`
- Takes `repoId` as explicit third parameter

### 3. Git actions updated
- `GitCreatePR`, `GitMerge`, `GitRebase`, `GitChangeTarget` now use `requiresTarget: 'git'`
- Each action's `execute` receives `repoId` as parameter

### 4. `ActionsContext` provider centralized
- Now calls `useDevServer()` to provide dev server state
- Provides all required context properties from hooks
- `executeAction` handles three action types: global, workspace, git
- Removed `contextOverride` pattern

### 5. `ActionVisibilityContext` - Made dev server properties required
- `editorType`, `devServerState`, `runningDevServerId` now required
- `useActionVisibilityContext` hook provides all values

### 6. `ContextBarContainer` simplified
- Removed extended context creation
- Uses executor context directly from provider

### 7. Provider order fix
- Moved `ExecutionProcessesProvider` up to `NewDesignScope`
- Required because `useDevServer` depends on `ExecutionProcessesContext`

### Files Modified:
- `vibe-kanban/frontend/src/components/ui-new/actions/index.ts`
- `vibe-kanban/frontend/src/components/ui-new/actions/useActionVisibility.ts`
- `vibe-kanban/frontend/src/contexts/ActionsContext.tsx`
- `vibe-kanban/frontend/src/components/ui-new/containers/ContextBarContainer.tsx`
- `vibe-kanban/frontend/src/components/ui-new/containers/WorkspacesLayout.tsx`
- `vibe-kanban/frontend/src/components/ui-new/views/WorkspacesMain.tsx`
- `vibe-kanban/frontend/src/components/ui-new/scope/NewDesignScope.tsx`

* The implementation is complete. Let me summarize what was changed:

## Summary of Changes

### `pages.ts`
- Added `'selectRepo'` to `PageId` type for dynamic repo selection page
- Created `StaticPageId` type (excludes `selectRepo`) for static page records
- Added `RepoItem` interface for repo selection items
- Extended `ResolvedGroupItem` union type to include `{ type: 'repo'; repo: RepoItem }`
- Updated `Pages` record and `getPageActions` to use `StaticPageId`

### `CommandBarDialog.tsx`
- Added `repos` from `useWorkspaceContext()`
- Added `pendingGitAction` state to track git actions awaiting repo selection
- Reset `pendingGitAction` when dialog opens/closes
- Modified `getPageWithItems` to generate dynamic `selectRepo` page with repo list
- Updated `handleSelect` to:
  - Execute git actions immediately with single repo
  - Navigate to `selectRepo` page when multiple repos exist
  - Execute pending git action when user selects a repo
- Clear `pendingGitAction` when navigating back from `selectRepo` page

### `CommandBar.tsx`
- Added `FolderIcon` import
- Added rendering for `'repo'` item type with folder icon

## Behavior

1. **Single repo**: When user selects a git action (e.g., "Create Pull Request") and the workspace has only one git repo, the action executes immediately with that repo's ID.

2. **Multiple repos**: When workspace has multiple repos, selecting a git action navigates to a "Select Repository" page where the user can choose which repo to use, then the action executes with the selected repo.

3. **Back navigation**: Pressing back from the repo selection page clears the pending action and returns to the previous page.

* Done! The `CommandBarDialog` has been refactored to use a state machine pattern with `useReducer`. Here's a summary of the changes:

## Summary of Changes

**State Machine Types (lines 38-67):**
- `CommandBarState`: Discriminated union with `browsing` and `selectingRepo` states
- `CommandBarEvent`: `RESET`, `SEARCH_CHANGE`, `GO_BACK`, `SELECT_ITEM`
- `CommandBarEffect`: Side effects returned from reducer (`none` or `execute`)

**Reducer (lines 73-201):**
- Pure function returning `[newState, effect]` tuple
- Handles all state transitions based on current state and event
- Git action flow: single repo → execute, multiple repos → transition to `selectingRepo`

**Component Changes:**
- Replaced 4 `useState` calls with single `useReducer`
- `currentPage` is now derived from state (line 249-250)
- `handleSelect` computes effect from reducer, dispatches event, then handles effect (lines 456-475)
- `goBack` and `handleSearchChange` simply dispatch events (lines 446-453)

**Benefits:**
- All state transitions in one place (the reducer)
- State transitions are pure and testable
- Clear separation between state updates and side effects
- Impossible states are unrepresentable (e.g., can't have `pendingAction` while `browsing`)

* Done! Here's the final result:

## Summary

**Before:** 520 lines in 1 file (after initial state machine refactor)
**After:** 487 lines across 4 files

| File | Lines | Purpose |
|------|-------|---------|
| `CommandBarDialog.tsx` | 101 | Thin orchestration (down from 520) |
| `useCommandBarState.ts` | 177 | State machine hook |
| `useResolvedPage.ts` | 150 | Page building logic |
| `injectSearchMatches.ts` | 59 | DRY search helper |

**Key wins:**
- Main component: **520 → 101 lines** (80% reduction)
- Search injection code: **100 → 59 lines** (4× duplication eliminated)
- Each file has single responsibility
- State machine is testable in isolation
- Page building logic is reusable

* Cleanup script changes for workspace e961e311-6db4-41bf-83a1-ef8dd96eb497

* Done! Here are the final results:

## Final Summary

| File | Before | After | Reduction |
|------|--------|-------|-----------|
| `CommandBarDialog.tsx` | 101 | 106 | +5 (linter formatting) |
| `useCommandBarState.ts` | 177 | 95 | **-82 (46%)** |
| `useResolvedPage.ts` | 150 | 95 | **-55 (37%)** |
| `injectSearchMatches.ts` | 59 | 42 | **-17 (29%)** |
| **Total** | **487** | **338** | **-149 (31%)** |

**Original single file:** 398 lines
**Final 4 files:** 338 lines (15% less code overall)

Key wins:
- Main component is now just 106 lines of thin orchestration
- State machine is flattened (if statements instead of nested switch/case)
- Page resolution is simplified with reused types
- Search injection uses reduce() instead of for-loop
- All files pass type check

* Cleanup script changes for workspace e961e311-6db4-41bf-83a1-ef8dd96eb497

* I've fixed both issues with the CommandBar. Here's a summary of what was wrong and how I fixed it:

## Root Causes

### Issue 1: Nested `<Command>` Components
The `CommandDialog` component was wrapping children in a `<Command>` component, and `CommandBar` also rendered its own `<Command>`. This nested cmdk context caused conflicts with state management.

**Fix:** Removed the `<Command>` wrapper from `CommandDialog` in `Command.tsx:26-44`, and moved the styling classes to `CommandBar`'s `<Command>` component.

### Issue 2: Unstable `dispatch` Function Causing Infinite RESET Loop
In `useCommandBarState.ts`, the `dispatch` function had `[state, repoCount]` in its `useCallback` dependency array. This caused `dispatch` to be recreated on every state change.

In `CommandBarDialog.tsx`, the `useEffect` that resets state when the modal opens had `dispatch` in its dependency array:
```tsx
useEffect(() => {
  if (modal.visible) {
    dispatch({ type: 'RESET', page });
  }
}, [modal.visible, page, dispatch]); // dispatch changes → useEffect runs → RESET
```

This created an infinite loop:
1. User types → state updates → `dispatch` recreated
2. `dispatch` changed → `useEffect` runs → `RESET` dispatched
3. State resets to empty → repeat

**Fix:** Made `dispatch` stable by using refs instead of state in dependencies:
```tsx
const stateRef = useRef<CommandBarState>(browsing(initialPage));
const repoCountRef = useRef(repoCount);

const dispatch = useCallback(
  (event: CommandBarEvent): CommandBarEffect => {
    const [, effect] = reducer(stateRef.current, event, repoCountRef.current);
    rawDispatch(event);
    return effect;
  },
  [] // No dependencies - uses refs for current values
);
```

## Files Changed
1. `vibe-kanban/frontend/src/components/ui-new/primitives/Command.tsx` - Removed nested `<Command>` wrapper from `CommandDialog`
2. `vibe-kanban/frontend/src/components/ui-new/primitives/CommandBar.tsx` - Added styling classes that were on the removed wrapper
3. `vibe-kanban/frontend/src/components/ui-new/dialogs/commandBar/useCommandBarState.ts` - Made `dispatch` stable using refs
2026-01-09 16:25:42 +00:00
Alex Netsch
29595c1929 Add Azure DevOps repository support for PR operations (Vibe Kanban) (#1808)
* All tasks are complete. Let me summarize what was implemented:

I've successfully implemented Azure DevOps repos support alongside the existing GitHub integration. Here's what was done:

- **`mod.rs`** - Defines the `GitHostService` trait and factory functions for creating services
- **`types.rs`** - Unified types: `GitHostProvider`, `RepoInfo`, `GitHostError`, `CreatePrRequest`, `UnifiedPrComment`
- **`detection.rs`** - URL pattern matching for auto-detecting GitHub (including Enterprise) and Azure DevOps
- **`github/mod.rs`** - `GitHubHostService` implementing the trait
- **`github/cli.rs`** - `GhCli` wrapper (moved from old location)
- **`azure/mod.rs`** - `AzureHostService` implementing the trait
- **`azure/cli.rs`** - `AzCli` wrapper for Azure DevOps CLI commands

1. **Auto-detection**: The system detects the provider from the git remote URL:
   - `github.com` → GitHub
   - `github.*.com` → GitHub Enterprise
   - `dev.azure.com`, `*.visualstudio.com`, or URLs with `/_git/` → Azure DevOps

2. **Unified trait interface**: Both providers implement `GitHostService` with methods for:
   - `get_repo_info()` - Get repository identification
   - `check_auth()` - Verify CLI authentication
   - `create_pr()` - Create pull requests
   - `get_pr_status()` - Get PR status by URL
   - `list_prs_for_branch()` - List PRs for a branch
   - `get_pr_comments()` - Get PR comments

3. **Azure CLI commands supported**:
   - `az repos pr create` - Create PRs
   - `az repos pr show` - View PR details
   - `az repos pr list` - List PRs
   - `az repos pr list-threads` - Get PR comments
   - `az account show` - Auth check

- `pr.rs` - Uses auto-detection for PR creation
- `pr_monitor.rs` - Uses provider detection from PR URL
- `task_attempts.rs` - Uses git_host for push auth checking
- `error.rs` - Updated `GitHost` error variant
- `share.rs` - Updated `GitHost` error variant
- `generate_types.rs` - Updated type exports

- Old `crates/services/src/services/github.rs` module and directory (replaced by git_host)

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

All tests pass, including the new URL decoding tests. The fix is complete - the URL-encoded components (like `Vibe%20Kanban%20Test`) will now be properly decoded to `Vibe Kanban Test` before being passed to the Azure CLI.

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

All done! Here's a summary of the changes:

Updated `get_repo_info()` to use the Azure CLI's `az repos show --detect true` command instead of manual URL parsing, similar to how GitHub uses `gh repo view --json owner,name`.

1. **Added `extract_repo_name_from_url()`** - A simple helper that extracts just the repository name from Azure DevOps URLs (looks for `/_git/{repo}` pattern). This is still needed because `az repos show` requires the `--repository` parameter.

2. **Updated `get_repo_info()`** - Now uses `az repos show --repository {name} --detect true --output json` which:
   - Auto-detects organization and project from git config
   - Returns canonical names (properly decoded)
   - Validates the repo exists

3. **Added `extract_org_from_response()`** - Extracts the organization from the `remoteUrl` field in the CLI response, with fallback to URL parsing.

4. **Fixed `run()` method** - Now properly passes the `dir` parameter to `Command::current_dir()` so the `--detect` flag works correctly.

5. **Kept `parse_azure_remote_url()`** - Still used as a fallback for organization extraction and for PR URL parsing.

6. **Added tests** - New tests for `extract_repo_name_from_url()` covering various URL formats.

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

Done! The cleanup is complete. Here's what was removed:

Removed the brittle `parse_azure_remote_url()` function and related code:

1. **Removed `AzureRepoInfo` struct** - No longer needed
2. **Removed `parse_azure_remote_url()` function** - The ~90-line function that manually parsed various Azure DevOps URL formats
3. **Updated `get_repo_info()`** - Changed from fallback (`unwrap_or_else`) to error (`ok_or_else`) when organization can't be extracted from the CLI response
4. **Removed 4 tests** - `test_parse_azure_remote_url_https`, `test_parse_azure_remote_url_visualstudio`, `test_parse_azure_remote_url_ssh`, `test_parse_azure_remote_url_with_spaces`

The code now relies entirely on:
- `extract_repo_name_from_url()` - Simple helper to get repo name from URL (for passing to `az repos show`)
- `az repos show --detect true` - Azure CLI command that auto-detects org/project from git config
- `extract_org_from_response()` - Extracts org from the CLI's `remoteUrl` JSON field

The implementation is complete. Here's a summary of the changes:

Simplified the Azure DevOps integration by using the CLI's `--detect` flag instead of parsing URLs to extract org/project/repo.

1. **`types.rs`** - Changed `RepoInfo::AzureDevOps` to store just `repo_path: PathBuf` instead of `organization`, `project`, and `repo_name`. Removed the unused `repo_name()` method.

2. **`cli.rs`** - Major simplification:
   - Removed URL parsing helpers: `decode_url_component()`, `extract_repo_name_from_url()`, `extract_org_from_response()`
   - `get_repo_info()` now just verifies it's a valid Azure repo via `az repos show --detect true` and returns the path
   - `create_pr()` now takes `repo_path` and uses `--detect true` instead of explicit org/project/repo
   - `list_prs_for_branch()` now takes `repo_path` and uses `--detect true`
   - `get_pr_threads()` now takes `repo_path` and uses `--detect true`
   - `view_pr()` now takes the full PR URL and parses org + PR ID internally
   - `parse_pr_url()` simplified to return just `(org, pr_id)` instead of 4 values
   - Parsing functions simplified to extract URLs from response's `repository.webUrl` field
   - Updated tests for the new API

3. **`mod.rs`** - Updated `AzureHostService` to:
   - Extract `repo_path` from `RepoInfo::AzureDevOps`
   - Pass `repo_path` to CLI methods that need it
   - Pass the PR URL directly to `view_pr()` for `get_pr_status()`

- URL parsing reduced to minimal extraction of org + PR ID from PR URLs (only needed for `get_pr_status()`)
- Repo-based operations don't parse URLs at all - CLI auto-detects via git config
- Much cleaner, less brittle code

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

All done. The implementation is complete:

**Summary of changes:**

1. **`types.rs`**: Updated `RepoInfo::AzureDevOps` to store `organization_url`, `project`, `repo_name` instead of `repo_path`

2. **`cli.rs`**:
   - `get_repo_info()` now parses the JSON response from `az repos show --detect true` to extract repo name, project name, and organization URL
   - Added `extract_org_url()` helper to extract the base org URL from the API URL
   - Updated `create_pr()`, `list_prs_for_branch()`, `get_pr_threads()` to take explicit `organization_url`, `project`, `repo_name` params

3. **`mod.rs`** (`AzureHostService`):
   - `create_pr()`, `list_prs_for_branch()`, `get_pr_comments()` all now extract org/project/repo from `RepoInfo` and pass them to the CLI methods

The key insight was that the `url` field from `az repos show` (e.g., `https://dev.azure.com/{org}/.../_apis/...`) can be truncated to `https://dev.azure.com/{org}` and used directly with the `--organization` flag — minimal URL parsing needed.

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

* Done. Refactored all 4 `serde_json::Value` parsing sites to use typed structs:

**Changes to `cli.rs`:**

1. **Added typed response structs** with `#[derive(Deserialize)]`:
   - `AzRepoShowResponse`, `AzProject` - for `az repos show`
   - `AzPrResponse`, `AzRepository`, `AzCommit` - for PR responses
   - `AzThread`, `AzThreadContext`, `AzFilePosition`, `AzThreadComment`, `AzAuthor` - for thread comments

2. **Updated parsing functions**:
   - `get_repo_info()` - now deserializes into `AzRepoShowResponse`
   - `parse_pr_response()` - now deserializes into `AzPrResponse`
   - `parse_pr_list_response()` - now deserializes into `Vec<AzPrResponse>`
   - `parse_pr_threads()` - now deserializes into `Vec<AzThread>`

3. **Replaced `extract_pr_info()`** with `az_pr_to_info()` that takes the typed struct directly

4. **Removed `serde_json::Value` import** - no longer needed

The code is now cleaner with no `.get().and_then().as_str()` chains, and serde provides better error messages on parse failures.

* Done. Added the missing `--repository` parameter to `get_pr_threads()`:

1. **`cli.rs`**: Added `repo_name: &str` parameter and `--repository` flag to the CLI command
2. **`mod.rs`**: Updated `get_pr_comments()` to extract both `organization_url` and `repo_name` from `RepoInfo` and pass them to the CLI

Done. Here's a summary of the changes:

**Changes made to `crates/services/src/services/git_host/azure/cli.rs`:**

1. **Removed git2 dependency** - No longer imports `git2::Repository`

2. **Added new typed structs** for `az repos list` response:
   - `AzRepoListItem` - with `name`, `project`, and `remote_url` fields
   - `AzRepoProject` - with `name` field

3. **Rewrote `get_repo_info()`** to use `az repos list --detect true`:
   - Runs CLI command from the repo directory to auto-detect org/project
   - Takes the first repo from the list (assuming single repo per directory)
   - Extracts org from `remoteUrl` field

4. **Replaced `parse_azure_remote_url()`** with simpler `extract_org_from_remote_url()`:
   - Only extracts the organization name from the URL
   - Handles both `dev.azure.com` and `visualstudio.com` formats
   - Much simpler than the previous 3-tuple URL parser

5. **Updated tests** - Replaced the old URL parsing tests with new `extract_org_from_remote_url` tests

The key improvement is that `az repos list --detect true` uses the Azure CLI's built-in detection (from git config) to find the org and project, then returns all repo info including project name. This avoids git2 library usage and complex URL parsing entirely.

Done. Here's a summary of all changes:

**Summary of Changes**

1. **`crates/services/src/services/git_host/types.rs`**:
   - Added `project_id` and `repo_id` fields to `RepoInfo::AzureDevOps` enum variant

2. **`crates/services/src/services/git_host/azure/cli.rs`**:
   - Added `id` field to `AzRepoListItem` struct
   - Added `id` field to `AzRepoProject` struct
   - Added `AzThreadsResponse` struct to wrap the `{ "value": [...] }` REST API response
   - Updated `get_repo_info()` to return `project_id` and `repo_id` from `az repos list` output
   - Updated `get_pr_threads()` to:
     - Accept `project_id` and `repo_id` instead of names
     - Use `az rest` with REST API URL instead of non-existent `az repos pr list-threads`
   - Updated `parse_pr_threads()` to unwrap the `value` field from REST API response

3. **`crates/services/src/services/git_host/azure/mod.rs`**:
   - Updated `create_pr` and `list_prs_for_branch` to use `..` pattern for new fields
   - Updated `get_pr_comments()` to extract and pass `project_id` and `repo_id` to CLI

**Key Improvements**:
- Uses UUIDs (`project_id`, `repo_id`) instead of names for REST API calls, avoiding URL encoding issues with names containing spaces like "Vibe Kanban Test"
- Fixed `get_pr_threads()` to use `az rest` since `az repos pr list-threads` doesn't exist as an Azure CLI command
- All unit tests pass

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

Done. The fix adds `--resource 499b84ac-1321-427f-aa17-267ca6975798` to the `az rest` command, which tells it to request an Azure DevOps token instead of a generic Azure token. This should now properly authenticate to the Azure DevOps REST API.

Done. The fix replaces `az rest` with `az devops invoke --area git --resource pullRequestThreads`. This uses the same authentication as other `az repos pr` commands, so it should work without requiring the separate "identity materialization" step.

Done. The fix replaces the single combined string for `--route-parameters` with individual arguments for each `key=value` pair. This matches how the Azure CLI expects the parameters to be passed - each route parameter should be a separate shell argument after the `--route-parameters` flag.

Done. Removed all the requested comments from:
- `crates/server/src/routes/task_attempts.rs` (lines 451, 490)
- `crates/server/src/routes/task_attempts/pr.rs` (lines 283, 516)
- `crates/services/src/services/git_host/azure/cli.rs` (section header comment, doc comments on structs and methods)

* Done. Removed the module-level doc comment and all the method doc comments from the `GitHostService` trait and public functions in `mod.rs`.

Done. Removed the obvious/redundant comments from `types.rs`.

Done. Removed the unnecessary `Arc` usage from all three functions in `mod.rs`. The strings are already cloned when extracted from `RepoInfo`, so we can just clone them directly in the retry closure.

* All tests pass. Fixed the `npm run check` and `npm run lint` issues by:

1. Regenerated TypeScript types from Rust
2. Updated `frontend/src/lib/api.ts` to use `CreatePrApiRequest` instead of `CreateGitHubPrRequest`
3. Updated `CreatePRDialog.tsx` to handle the new error types (`cli_not_installed`/`cli_not_logged_in` with a `provider` field instead of `github_cli_not_installed`/`github_cli_not_logged_in`)
4. Fixed clippy warnings about collapsible if statements in `parse_pr_url()`

* Done. I've made `url`, `diff_hunk`, and `author_association` optional in the `UnifiedPrComment` type:

**Changes made:**

1. **`crates/services/src/services/git_host/types.rs`** - Changed the `UnifiedPrComment` enum:
   - `url: String` → `url: Option<String>`
   - `diff_hunk: String` → `diff_hunk: Option<String>`
   - `author_association: String` → `author_association: Option<String>`

2. **`crates/services/src/services/git_host/azure/cli.rs`** - Updated Azure comment creation to use `None` instead of empty strings

3. **`crates/services/src/services/git_host/github/mod.rs`** - Wrapped GitHub values in `Some()`

4. **`frontend/src/components/ui/github-comment-card.tsx`** - Updated interface to allow `url?: string | null` and `diffHunk?: string | null`

5. **`frontend/src/components/ui/wysiwyg/nodes/github-comment-node.tsx`**:
   - Updated `NormalizedComment` interface
   - Fixed click handler to check `if (data.url)` before opening
   - Removed `data.url` from validation (only `id`, `comment_type`, `author`, `body` required)

All checks pass (`pnpm run check`, `pnpm run lint`, `cargo test --workspace`).

* Done. All three changes are complete:

1. **Removed unnecessary temp file** in `azure/cli.rs:create_pr()` - was writing body to temp file then immediately reading it back. Now just passes `body` directly to `OsString`.

2. **Added structs for JSON parsing** in `github/cli.rs:parse_pr_comments()` - replaced manual `item.get("field")...` parsing with `GhCommentsWrapper` and `GhCommentResponse` structs using serde.

3. **Added structs for JSON parsing** in `github/cli.rs:parse_pr_review_comments()` - replaced manual parsing with `GhReviewCommentResponse` struct.

All checks pass (`pnpm run check`, `pnpm run lint`, `cargo test --workspace`).

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

Done. Both changes are complete:

1. **Inlined single-field structs** - Consolidated `GhCommentAuthor` and `GhReviewCommentUser` into a single `GhUserLogin` struct that's reused by both `GhCommentResponse` and `GhReviewCommentResponse`.

2. **Converted `extract_pr_info` to struct parsing** - Added `GhPrResponse` and `GhMergeCommit` structs. Replaced the manual `Value::get()` parsing with serde deserialization. The new `pr_response_to_info()` helper converts the parsed struct to `PullRequestInfo`. Also removed the now-unused `serde_json::Value` import.

All checks pass (`pnpm run check`, `pnpm run lint`, `cargo test --workspace`).

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

* Done. I've updated `detection.rs` to use `GitCli` instead of `git2`:

1. **Added `get_remote_url` method to `GitCli`** (`git/cli.rs`) - Uses `git remote get-url <remote>` to get the URL
2. **Updated `detect_provider`** (`git_host/detection.rs`) - Now uses `GitCli::get_remote_url()` instead of `git2::Repository`

This keeps the codebase consistent with the pattern of using `GitCli` for git operations rather than mixing `git2` directly in various modules.

All checks pass (`pnpm run check`, `pnpm run lint`, `cargo test --workspace`).

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

* Done! The refactor is complete. Here's a summary of the changes:

**New Architecture:**

1. **`ProviderKind` enum** (was `GitHostProvider`) - The discriminant for provider types (GitHub, AzureDevOps, Unknown)

2. **`GitHostProvider` trait** (was `GitHostService`) - The interface that provider implementations must satisfy

3. **`GitHubProvider` struct** (was `GitHubHostService`) - GitHub implementation

4. **`AzureDevOpsProvider` struct** (was `AzureHostService`) - Azure DevOps implementation

5. **`GitHostService` struct** (new) - Main entry point that:
   - Holds repo context (`repo_path`, `GitCli`)
   - Provides `provider_for_remote(remote_name)` to get a provider for a specific remote
   - Provides `provider_from_url(url)` for URL-based detection (e.g., PR URLs)
   - Provides `provider_for_kind(kind)` for direct provider construction

**Benefits:**
- Provider detection is now contextual - callers specify which remote they want
- The service struct encapsulates provider detection logic
- Cleaner separation: `GitHostService` is the facade, `GitHostProvider` trait is the contract
- Ready for multi-remote support (different providers for different remotes)

All checks pass (`pnpm run check`, `pnpm run lint`, `cargo test --workspace`).

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

All the call sites have been updated to use the new cleaner `GitHostService` facade API. Here's a summary of the changes:

**Changes made:**

1. **`pr.rs:414-418` (`attach_existing_pr`)**: Simplified from:
   ```rust
   let git_host = git_host::GitHostService::new(&repo.path);
   let git_host_provider = git_host.provider_for_remote("origin")?;
   let repo_info = git_host_provider.get_repo_info(&repo.path).await?;
   let prs = git_host_provider.list_prs_for_branch(&repo_info, &workspace.branch).await?;
   ```
   To:
   ```rust
   let git_host = git_host::GitHostService::new(&repo.path);
   let prs = git_host.list_prs_for_branch(&workspace.branch).await?;
   ```

2. **`pr.rs:511-525` (`get_pr_comments`)**: Simplified from provider-based pattern to:
   ```rust
   let git_host = git_host::GitHostService::new(&repo.path);
   let provider = git_host.provider_kind()?;
   match git_host.get_pr_comments(pr_info.number).await { ... }
   ```

3. **`task_attempts.rs:451-453` (`push_task_attempt_branch`)**: Removed explicit `check_auth()` call since auth is now checked during the actual operation. Just verify provider is supported:
   ```rust
   let git_host = git_host::GitHostService::new(&worktree_path);
   git_host.provider_kind()?;
   ```

4. **`task_attempts.rs:490-492` (`force_push_task_attempt_branch`)**: Same simplification.

The new API is much cleaner - call sites just create a `GitHostService::new(path)` and call methods directly without dealing with providers, repo info, or explicit auth checks.

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

The refactoring is complete. Here's a summary of what was done:

**Changes made:**

1. **`crates/services/Cargo.toml`** - Added `enum_dispatch` dependency

2. **`crates/services/src/services/git_host/mod.rs`** - Completely rewritten:
   - `GitHostProvider` is now a public trait with `#[enum_dispatch(GitHostService)]`
   - `GitHostService` is now an enum with `GitHub` and `AzureDevOps` variants
   - Constructors: `from_pr_url(url)` and `from_remote_url(url)` - no `new()` method
   - Methods now take `repo_path` as a parameter where needed

3. **`crates/services/src/services/git_host/github/mod.rs`** - Updated to match new trait signature (methods take `repo_path`, `check_auth` called inside `create_pr`)

4. **`crates/services/src/services/git_host/azure/mod.rs`** - Updated similarly

5. **`crates/services/src/services/git.rs`** - Added `get_remote_url()` method to `GitService`

6. **Call site updates:**
   - `pr_monitor.rs` - Uses `from_pr_url`
   - `pr.rs` - Uses `get_remote_name_from_branch_name` + `get_remote_url` + `from_remote_url`
   - `task_attempts.rs` - Same pattern for push functions

**New API usage:**
```rust
// From a PR URL (e.g., for checking PR status)
let git_host = GitHostService::from_pr_url(&pr_url)?;
let status = git_host.get_pr_status(&pr_url).await?;

// From a remote URL (e.g., for creating PRs)
let remote_name = git_service.get_remote_name_from_branch_name(&repo_path, &branch)?;
let remote_url = git_service.get_remote_url(&repo_path, &remote_name)?;
let git_host = GitHostService::from_remote_url(&remote_url)?;
let pr_info = git_host.create_pr(&repo_path, &pr_request).await?;

// Get provider kind (infallible since already constructed)
let provider = git_host.provider_kind();
```

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

All cleaned up. Here's the final architecture:

**`git_host/mod.rs`:**
```rust
pub trait GitHostProvider: Send + Sync {
    async fn create_pr(&self, repo_path: &Path, request: &CreatePrRequest) -> Result<PullRequestInfo, GitHostError>;
    async fn get_pr_status(&self, pr_url: &str) -> Result<PullRequestInfo, GitHostError>;
    async fn list_prs_for_branch(&self, repo_path: &Path, branch_name: &str) -> Result<Vec<PullRequestInfo>, GitHostError>;
    async fn get_pr_comments(&self, repo_path: &Path, pr_number: i64) -> Result<Vec<UnifiedPrComment>, GitHostError>;
    fn provider_kind(&self) -> ProviderKind;
}

pub enum GitHostService {
    GitHub(GitHubProvider),
    AzureDevOps(AzureDevOpsProvider),
}

impl GitHostService {
    pub fn from_url(url: &str) -> Result<Self, GitHostError>
}
```

**Changes made:**
1. Removed `check_auth` and `get_repo_info` from the public trait - they're now private methods on each provider
2. Consolidated `from_pr_url` and `from_remote_url` into a single `from_url` constructor
3. The trait now has exactly 5 methods - the minimal public API needed by call sites

**Call site usage is clean:**
```rust
// From any URL (PR URL or remote URL)
let git_host = GitHostService::from_url(&url)?;

// Use the trait methods
let pr_info = git_host.create_pr(&repo_path, &request).await?;
let status = git_host.get_pr_status(&pr_url).await?;
let prs = git_host.list_prs_for_branch(&repo_path, &branch).await?;
let comments = git_host.get_pr_comments(&repo_path, pr_number).await?;
let kind = git_host.provider_kind();
```

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

Done. The refactoring is complete:

1. **Created `GitHubRepoInfo`** in `git_host/github/cli.rs` - a simple struct with `owner` and `repo_name`
2. **Created `AzureRepoInfo`** in `git_host/azure/cli.rs` - a struct with `organization_url`, `project`, `project_id`, `repo_name`, `repo_id`
3. **Updated both providers** to use their respective provider-specific structs directly, removing all the match arms and error cases for "wrong variant" that could never happen
4. **Removed the shared `RepoInfo` enum** from `types.rs` and the public exports

The code is cleaner now - each provider has its own internal representation of repo info, and there's no shared enum that requires impossible error handling paths.

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

The fix compiles. The issue was that `get_remote_name_from_branch_name` was calling `get_remote_from_branch_ref` which uses `repo.branch_remote_name()` - this git2 function requires the branch to have upstream tracking configured. For local branches that haven't been pushed yet (or don't have tracking set), this fails with the error you saw.

The fix changes the behavior to fall back to the default remote (typically "origin") when the branch doesn't have upstream tracking configured. This makes sense because:

1. Most repos only have one remote anyway
2. When creating a PR for a local branch, we need to push to *some* remote - the default is the sensible choice
3. The original code computed `default_remote` but never actually used it as a fallback

Done. Added `get_remote_url_from_branch_or_default` to `GitService` and updated all 4 call sites. The pattern is now:

```rust
let remote_url = deployment
    .git()
    .get_remote_url_from_branch_or_default(&repo_path, &branch)?;
let git_host = git_host::GitHostService::from_url(&remote_url)?;
```

Two lines instead of four, and the function name makes the fallback behavior explicit.

Done. Removed the unnecessary provider detection checks from both `push_task_attempt_branch` and `force_push_task_attempt_branch`. The push operations now just push directly - git push works with any remote regardless of whether we support it as a PR provider. Auth errors from git push itself (SSH keys, HTTPS credentials) still come through `GitServiceError::GitCLI(...)` and propagate to the frontend the same way.

* All done. Removed the low-value comments:
- "Create git host from the PR URL"
- "Fetch comments"
- "Get the URL for a remote (e.g., "origin")."
- "Azure DevOps-specific repository information"
- "GitHub-specific repository information"
- "Get the remote URL for the branch to detect the provider" (2 places)
- "Get repository info from the GitHub CLI"
- "Get repository info from the Azure CLI"
- "Check authentication status" (2 places)

Kept comments that provide actual value like the fallback behavior explanation on `get_remote_url_from_branch_or_default`.

All done. Removed the low-value comments:
- "Create git host from the PR URL"
- "Fetch comments"
- "Get the URL for a remote (e.g., "origin")."
- "Azure DevOps-specific repository information"
- "GitHub-specific repository information"
- "Get the remote URL for the branch to detect the provider" (2 places)
- "Get repository info from the GitHub CLI"
- "Get repository info from the Azure CLI"
- "Check authentication status" (2 places)
- "Get PR status from URL (auto-detects provider)"
- "High-level errors originating from the Azure CLI."
- "High-level errors originating from the GitHub CLI."
- "Azure DevOps hosting provider implementation"
- "GitHub hosting provider implementation"
- "Newtype wrapper for invoking the `gh` command."
- "Newtype wrapper for invoking the `az` command."
- "Trait for git hosting provider operations (GitHub, Azure DevOps, etc.)"
- All the trait method doc comments (Create a pull request, Get PR status, etc.)
- "Git hosting service - dispatches to the appropriate provider."
- "Create a GitHostService by detecting the provider from a URL."
- Simplified the Azure DevOps pattern comments in detection.rs

* Done. Here's a summary of the fix:

**Problem**: `get_repo_info` used `az repos list --detect true` which returns ALL repos in the Azure DevOps project, then just took the first one. This was wrong for multi-repo projects.

**Solution**:
1. `AzureDevOpsProvider` now stores the remote URL passed to `from_url()`
2. `get_repo_info` now takes the remote URL and filters the repo list to find the matching repo using `remote_urls_match()`
3. Added `remote_urls_match()` helper that normalizes URLs (lowercase, strips trailing `/` and `.git`) for comparison
4. Added `extract_organization_url()` to get the Azure organization URL from a remote URL (supports both `dev.azure.com` and legacy `visualstudio.com` formats)
5. Removed the now-unused `extract_org_from_remote_url()` function

The flow is now:
- Call site gets remote URL via `get_remote_url_from_branch_or_default()`
- Creates `GitHostService::from_url(&remote_url)` which stores the URL on `AzureDevOpsProvider`
- When `get_repo_info` is called, it lists all repos in the project and finds the one matching the stored remote URL

Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

* Done. Summary of changes:

1. **`pr.rs:get_pr_comments`** - Now gets the remote URL from `workspace_repo.target_branch` instead of using the PR URL to create the `GitHostService`

2. **`azure/cli.rs`**:
   - Added `ssh_url` field to `AzRepoListItem`
   - Updated `get_repo_info` to detect if the input URL is SSH (`starts_with("git@")`) and compare against the appropriate field (`ssh_url` vs `remote_url`)
   - Renamed `remote_urls_match` to `urls_match` since it now handles both HTTPS and SSH URLs
   - Added SSH URL test case

* Build passes. The simple fix handles both SSH formats without adding a dependency.

* Build passes. Now `ssh_url` is optional - if it's not in the response and the user has an SSH remote configured, they'll get a clear error message ("No repo found matching remote URL: ...").

* Done. The `urls_match` function now normalizes `ssh://` prefix to scp-style before comparing.

* Done. Summary of changes:

1. **Removed `remote_url` field from `AzureDevOpsProvider`** - no longer stored on the struct

2. **Updated `GitHostProvider` trait** - added `remote_url: &str` parameter to:
   - `create_pr`
   - `list_prs_for_branch`
   - `get_pr_comments`

3. **Updated `AzureDevOpsProvider`** - methods now accept `remote_url` and pass it to `get_repo_info`

4. **Updated `GitHubProvider`** - methods accept `_remote_url` (unused, since gh CLI auto-detects)

5. **Updated call sites in `pr.rs`** - all three methods now pass `remote_url`:
   - `create_pr` passes `&remote_url`
   - `list_prs_for_branch` passes `&remote_url`
   - `get_pr_comments` passes `&remote_url`

6. **Fixed `attach_existing_pr`** - now uses `workspace_repo.target_branch` instead of `workspace.branch` when getting the remote URL (consistent with other call sites)

* Cleanup script changes for workspace 28eb9564-f95a-42e0-8cf2-5228c2ffc0bf

* Update frontend remote copy (vibe-kanban a7bf13b6)

We added azure support but in the frontend many things have github specific wording. Please fix!

* Done. I've addressed the PR comment by:

1. **Renamed `CreatePrError` to `PrError`** - A more generic name that works for both `create_pr` and `attach_existing_pr`

2. **Updated `attach_existing_pr`** to mirror the error handling from `create_pr`:
   - Changed return type from `ApiResponse<AttachPrResponse>` to `ApiResponse<AttachPrResponse, PrError>`
   - Added error handling for `GitHostService::from_url()` - handles `UnsupportedProvider` and `CliNotInstalled`
   - Added error handling for `list_prs_for_branch()` - handles `CliNotInstalled` and `AuthFailed`

3. **Updated `generate_types.rs`** to use the renamed `PrError`

4. **Updated `frontend/src/lib/api.ts`** to use `PrError` instead of `CreatePrError`

5. **Regenerated TypeScript types** and verified all checks pass
2026-01-09 15:50:34 +00:00
GitHub Action
3ad03a0a99 chore: bump version to 0.0.147 2026-01-09 14:46:16 +00:00
Alex Netsch
e73c1b4bff All done. Here's a summary of the fix: (#1875)
## Summary

Fixed PR comment labels showing raw translation keys instead of translated text.

**Problem:** The `CommentWidgetLine.tsx` and `ReviewCommentRenderer.tsx` components were using translation keys that didn't exist in the translation files:
- `comments.addReviewComment`
- `comments.addPlaceholder`
- `comments.editPlaceholder`
- `actions.cancel`
- `actions.saveChanges`
- `actions.copied`

**Solution:** Added the missing translation keys to `common.json` in all 6 locales:
- English (en)
- Spanish (es)
- Japanese (ja)
- Korean (ko)
- Simplified Chinese (zh-Hans)
- Traditional Chinese (zh-Hant)

**Verification:**
-  `pnpm run check` passes (TypeScript and Rust checks)
-  i18n check script confirms translation keys are consistent across all locales
-  No duplicate JSON keys
2026-01-09 12:32:50 +00:00
Louis Knight-Webb
06862ab010 Fix GitHub PR button display and refactor RepoCard styling (Vibe Kanban) (#1872)
* Both issues have been fixed:

**1. Fixed translation parameter mismatch** (`RepoCard.tsx:170, 176`)
- Changed `{ prNumber }` to `{ number: prNumber }` to match the translation key `Open PR #{{number}}`

**2. Refactored PR badge styling** (`RepoCard.tsx:156-180`)
- Replaced hardcoded Tailwind colors with design system tokens:
  - Merged badge: `bg-panel text-success` (uses semantic success color)
  - Open PR button/badge: `bg-panel text-normal hover:bg-tertiary transition-colors`
- Updated spacing to use consistent tokens: `gap-half`, `px-base`, `py-half`
- Changed border radius from `rounded-full` to `rounded-sm` to match other UI elements in the panel

* Both fixes are complete:

1. **Added spacing** - Added `mt-half` to the PR status row container (line 158) to create visual separation from the Actions row below

2. **Made merged PRs clickable** - When `prStatus === 'merged'` and `prUrl` is available, it now renders a clickable `<button>` with:
   - The external link icon (`ArrowSquareOutIcon`)
   - Hover state (`hover:bg-tertiary`)
   - Same transition effect as the open PR button

* improve styles
2026-01-09 09:59:54 +00:00
Louis Knight-Webb
af70dd9239 The implementation is complete. Here's a summary of the changes made: (#1871)
## Summary

I've implemented the GitHub PR status display on `WorkspaceSummary.tsx`. The changes include:

### Backend Changes

1. **`crates/db/src/models/merge.rs`** - Added a new method `get_latest_pr_status_for_workspaces()` that efficiently queries the latest PR status for all workspaces grouped by archived status.

2. **`crates/server/src/routes/task_attempts/workspace_summary.rs`** - Added `pr_status: Option<MergeStatus>` field to the `WorkspaceSummary` struct and included the PR status query in the summary endpoint.

### Frontend Changes

3. **`frontend/src/components/ui-new/hooks/useWorkspaces.ts`** - Added `prStatus` to the `SidebarWorkspace` interface and mapped it in `toSidebarWorkspace()`.

4. **`frontend/src/components/ui-new/primitives/WorkspaceSummary.tsx`** - Added:
   - Import for `GitPullRequestIcon`
   - `prStatus` prop to the component
   - Display logic showing:
     - **PR open**: `GitPullRequestIcon` with `text-brand` (orange) color
     - **PR merged**: `GitPullRequestIcon` with `text-success` (green) color
     - **No PR/closed/unknown**: No icon displayed

5. **`frontend/src/components/ui-new/views/WorkspacesSidebar.tsx`** - Passed the `prStatus` prop to both active and archived workspace summaries.

### Generated Types

6. **`shared/types.ts`** - Auto-generated to include the new `pr_status` field in `WorkspaceSummary`.
2026-01-09 09:09:11 +00:00
Anastasiia Solop
b743f849f7 Add rename workspace functionality (Vibe Kanban) (#1868)
* I've added the rename workspace functionality. Here's a summary of the changes:

## Summary

The backend already had rename workspace support via the `PUT /api/task-attempts/{attemptId}` endpoint with the `name` field. I added the frontend UI to expose this functionality.

### Files Created

1. **`frontend/src/components/ui-new/dialogs/RenameWorkspaceDialog.tsx`**
   - New dialog component for renaming workspaces
   - Shows the current name (or branch name as fallback)
   - Allows user to input a new name
   - Handles mutation with proper error handling and cache invalidation

### Files Modified

1. **`frontend/src/components/ui-new/actions/index.ts`**
   - Added `PencilSimpleIcon` import
   - Added `RenameWorkspaceDialog` import
   - Added new `RenameWorkspace` action that shows the rename dialog

2. **`frontend/src/components/ui-new/actions/pages.ts`**
   - Added `Actions.RenameWorkspace` to the `workspaceActions` page (at the top of the list)

3. **`frontend/src/i18n/locales/en/common.json`**
   - Added translations for the rename workspace dialog under `workspaces.rename`

### How to Use

Users can now rename a workspace by:
1. Clicking the three-dot menu (⋯) on any workspace in the sidebar
2. Selecting "Rename" from the command bar
3. Entering a new name in the dialog
4. Clicking "Rename" to save

* Cleanup script changes for workspace 4eb64331-cc43-43af-849e-3731664e53b9

* Added the missing translations for the rename workspace dialog to all locale files:
- **es** (Spanish)
- **ja** (Japanese)
- **ko** (Korean)
- **zh-Hans** (Simplified Chinese)
- **zh-Hant** (Traditional Chinese)
2026-01-09 10:06:29 +01:00
Louis Knight-Webb
078e7fc372 Done! I've changed block: 'nearest' to block: 'start' in ChangesPanelContainer.tsx:168. (#1869)
**What this fixes:**
- `block: 'nearest'` only scrolled the minimum distance to make the element visible, which often left users "halfway" through a file
- `block: 'start'` aligns the top of the selected diff with the top of the scroll container, ensuring the file header is always visible at the top
2026-01-09 08:44:08 +00:00
Louis Knight-Webb
6a07e5cc16 Fix new sessions to inherit last used variant from previous session (Vibe Kanban) (#1870)
* The implementation is complete. Here's a summary of the changes:

## Summary

Fixed the issue where new sessions were inheriting the last used executor but not the last used variant.

### Changes Made to `vibe-kanban/frontend/src/components/ui-new/containers/SessionChatBoxContainer.tsx`:

1. **Added import** for `useExecutionProcesses` hook

2. **Added `lastSessionId`** - gets the most recent session's ID only when in new session mode:
   ```tsx
   const lastSessionId = isNewSessionMode ? sessions?.[0]?.id : undefined;
   ```

3. **Added `useExecutionProcesses` call** - fetches processes from the last session to get the full executor profile:
   ```tsx
   const { executionProcesses: lastSessionProcesses } =
     useExecutionProcesses(lastSessionId);
   ```

4. **Added `lastSessionProfile` memo** - extracts the full profile (executor + variant) from the last session's processes:
   ```tsx
   const lastSessionProfile = useMemo(() => {
     if (!lastSessionProcesses?.length) return null;
     return getLatestProfileFromProcesses(lastSessionProcesses);
   }, [lastSessionProcesses]);
   ```

5. **Updated `latestProfileId` computation** - now uses `lastSessionProfile` (which includes the variant) before falling back to just the executor with `variant: null`

The type check passes successfully. When a user creates a new session, it will now correctly inherit both the executor AND variant from the most recently used session in that workspace.

* Done! The refactoring is complete. Here's a summary of the changes:

## Summary

Refactored the `latestProfileId` logic in `SessionChatBoxContainer.tsx` to be cleaner:

**Before:** 4 separate declarations
- `lastSessionExecutor` memo
- `lastSessionId`
- `lastSessionProcesses` hook
- `lastSessionProfile` memo
- `latestProfileId` memo (referencing all the above)

**After:** 3 declarations, consolidated
- `lastSessionId`
- `lastSessionProcesses` hook
- `latestProfileId` memo (all logic inlined)

**Changes:**
- Removed 2 intermediate `useMemo` hooks
- Inlined `lastSessionExecutor` and `lastSessionProfile` directly into `latestProfileId`
- Same 3-tier fallback behavior preserved: current processes → last session processes → session metadata
- Type check passes
2026-01-09 08:43:57 +00:00