Skip to content

Add 'Has Workspace' mode to show Linear issues linked to local worktrees - #12632

Merged
AmethystLiang merged 3 commits into
mainfrom
show-linked-linear-ticket
Aug 5, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
show-linked-linear-ticket

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Introduces a new Linear task view mode—'Has Workspace'—that displays only Linear issues already linked to local Orca worktrees or folder workspaces. Users can quickly open an attached workspace from the issue drawer or task list, or start a new one with a fallback option.

Changes

Core Feature

  • New linearMode: 'in-orca' view that collects linked Linear identifiers from all worktrees and fetches their current issue state
  • Issue attachment index for efficient per-row workspace lookups (one pass per list render, not per row)
  • Deduplication logic that normalizes identifiers (case-insensitive, URL-parsed) and handles multi-workspace scenarios
  • Workspace-scoped matching: respects both explicit linkedLinearIssueWorkspaceId and inferred workspace scope from provider context

UI & UX

  • Issue drawer: Shows attached workspace with 'Open workspace' primary button; dropdown offers 'Start new workspace' fallback
  • Task list rows: Icon changes from → (start) to 📁 (open) when workspace is attached; shows workspace name inline
  • Search & filter: In 'Has Workspace' mode, search queries filter by identifier, title, team, and assignee (not a Linear API query)
  • Error states: Partial load failures show recoverable message; empty state guides users to start from a Linear issue

Localization

Added ~12 translation keys per language (en, es, ja, ko, zh) for the new mode, button labels, empty states, and error messages.

Implementation Details

  • task-page-linear-in-orca-issues.ts: Collects refs from worktrees with dedup, filters, and concurrent read pooling (6 concurrent fetches by default)
  • linear-issue-workspace-attachment.ts: Finds and indexes workspace attachments; handles scope matching (workspace ID, org URL key, provider context)
  • linear-issue-workspace-open.ts: Opens attached workspace via activateAndRevealWorktree/activateAndRevealFolderWorkspace, or calls fallback to start a new one
  • worktree-attachment-label.ts: Shared label generation (display name → branch name → path tail) for consistent labeling across GitHub, Linear, and future work-item surfaces

Testing

  • Unit tests cover deduplication, normalization, filtering, workspace scope matching, and index lookups
  • Tests verify both exact and legacy (unscoped) identifier links, archived worktree exclusion, and concurrent read limiting
  • Edge cases: cross-workspace collisions, organization key mismatches, URL parsing, multi-locale labels

Verification

  • No visual change—follows STYLEGUIDE.md tokens and button sizing
  • Uses existing store selectors (useAllWorktrees) and activation utilities
  • Respects folder workspace and git worktree use cases; compatible with SSH execution hosts
  • Cross-platform: no platform-specific paths or shortcuts in new code

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f55fa2a8-77c9-488e-8401-f02b4e1290c2

📥 Commits

Reviewing files that changed from the base of the PR and between bac99c9 and 75dee36.

📒 Files selected for processing (20)
  • src/main/runtime/rpc/methods/task-resume-state-schema.ts
  • src/renderer/src/components/LinearIssueWorkspace.tsx
  • src/renderer/src/components/LinearItemDrawer.tsx
  • src/renderer/src/components/TaskPage.tsx
  • src/renderer/src/components/task-page-linear-in-orca-issues.test.ts
  • src/renderer/src/components/task-page-linear-in-orca-issues.ts
  • src/renderer/src/components/task-page-localized-options.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/github-work-item-workspace-attachment.ts
  • src/renderer/src/lib/linear-issue-workspace-attachment.test.ts
  • src/renderer/src/lib/linear-issue-workspace-attachment.ts
  • src/renderer/src/lib/linear-issue-workspace-open.test.ts
  • src/renderer/src/lib/linear-issue-workspace-open.ts
  • src/renderer/src/lib/worktree-attachment-label.ts
  • src/renderer/src/store/slices/ui.ts
  • src/shared/types.ts

📝 Walkthrough

Walkthrough

The change adds the in-orca Linear mode and persists it across task resume state. It resolves Linear issue attachments across worktrees and folder workspaces, opens existing workspaces, and starts new ones when needed. It adds linked-issue loading, filtering, search, refresh, empty states, and workspace columns to Linear views. Issue pages and drawers expose workspace actions and labels. Tests cover matching, filtering, concurrency, activation, and localization strings.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the feature and tests, but it omits required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, complete the testing checklist, and document the AI review, cross-platform checks, and security audit.
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a Has Workspace mode for Linear issues linked to local workspaces.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (3)
src/renderer/src/lib/linear-issue-workspace-open.test.ts (1)

76-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add cases for the started and failed branches.

The suite covers only the opened outcome. Two branches stay untested: the no-attachment path that must call startWorkspace and return 'started', and the activation-failure path that must emit the toast and return 'failed'. Both are cheap to add with the existing mocks.

💚 Proposed additional tests
+  it('starts a new workspace when no linked workspace exists', () => {
+    const startWorkspace = vi.fn()
+
+    expect(openLinearIssueWorkspaceOrStart({ identifier: 'ENG-1' }, startWorkspace)).toBe('started')
+    expect(startWorkspace).toHaveBeenCalledTimes(1)
+  })
+
+  it('reports failure when activation is refused', () => {
+    mocks.worktrees = [worktree()]
+    mocks.activateAndRevealWorktree.mockReturnValue(false)
+
+    expect(openLinearIssueWorkspaceOrStart({ identifier: 'ENG-1' }, vi.fn())).toBe('failed')
+  })
src/renderer/src/components/task-page-linear-in-orca-issues.ts (1)

77-117: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the scope key so it is computed once per candidate.

This block builds the same workspaceId::orgKey::sourceScope string in three places and calls getTaskSourceCacheScope inside two separate scans of existing. A small helper makes the dedupe rule readable and removes the repeated scope computation.

♻️ Proposed helper extraction
+function refScopeKey(ref: LinkedLinearIssueRef): string {
+  const sourceScope = ref.sourceContext ? getTaskSourceCacheScope(ref.sourceContext) : ''
+  return `${ref.workspaceId ?? ''}::${ref.organizationUrlKey?.toLowerCase() ?? ''}::${sourceScope}`
+}
src/renderer/src/components/LinearIssueWorkspace.tsx (1)

530-535: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated attachment derivation into one hook. Both components subscribe to allWorktrees and folderWorkspaces, build the same merged list with folderWorkspaceToWorktree, then derive attachedWorkspace and attachedWorkspaceLabel with identical code. A shared hook next to linear-issue-workspace-attachment.ts keeps the two surfaces from drifting.

  • src/renderer/src/components/LinearIssueWorkspace.tsx#L530-L535: replace the memo and the derivation at Lines 671-677 with the shared hook.
  • src/renderer/src/components/LinearItemDrawer.tsx#L1253-L1258: replace the memo and the derivation at Lines 1382-1388 with the same hook.
♻️ Proposed shared hook
// src/renderer/src/lib/use-linear-issue-workspace-attachment.ts
export function useLinearIssueWorkspaceAttachment(issue: LinearIssueAttachmentRef | null): {
  attachedWorkspace: Worktree | null
  attachedWorkspaceLabel: string | null
} {
  const allWorktrees = useAllWorktrees()
  const folderWorkspaces = useAppStore((s) => s.folderWorkspaces)
  const workspaces = useMemo(
    () => [...allWorktrees, ...folderWorkspaces.map(folderWorkspaceToWorktree)],
    [allWorktrees, folderWorkspaces]
  )
  const attachedWorkspace = useMemo(
    () => (issue ? findLinearIssueWorkspaceAttachment(workspaces, issue) : null),
    [workspaces, issue]
  )
  return {
    attachedWorkspace,
    attachedWorkspaceLabel: attachedWorkspace
      ? getLinearIssueWorkspaceAttachmentLabel(attachedWorkspace)
      : null
  }
}

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 303a036a-e1f1-400d-a96c-b61063019bf4

📥 Commits

Reviewing files that changed from the base of the PR and between 9507cbc and 3e2337e4a516a9f8f2b1e4f83f86a6a4669412d0.

📒 Files selected for processing (20)
  • src/main/runtime/rpc/methods/task-resume-state-schema.ts
  • src/renderer/src/components/LinearIssueWorkspace.tsx
  • src/renderer/src/components/LinearItemDrawer.tsx
  • src/renderer/src/components/TaskPage.tsx
  • src/renderer/src/components/task-page-linear-in-orca-issues.test.ts
  • src/renderer/src/components/task-page-linear-in-orca-issues.ts
  • src/renderer/src/components/task-page-localized-options.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/github-work-item-workspace-attachment.ts
  • src/renderer/src/lib/linear-issue-workspace-attachment.test.ts
  • src/renderer/src/lib/linear-issue-workspace-attachment.ts
  • src/renderer/src/lib/linear-issue-workspace-open.test.ts
  • src/renderer/src/lib/linear-issue-workspace-open.ts
  • src/renderer/src/lib/worktree-attachment-label.ts
  • src/renderer/src/store/slices/ui.ts
  • src/shared/types.ts

Comment thread src/renderer/src/i18n/locales/es.json Resolved
Comment thread src/renderer/src/i18n/locales/ja.json Resolved
Comment thread src/renderer/src/i18n/locales/zh.json Resolved
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai Fixing. Will be in the next commit

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@AmethystLiang Understood. I will review the fix after the next commit is available.

You are interacting with an AI system.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/lib/linear-issue-workspace-open.test.ts (1)

112-119: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert that activation was attempted.

This test configures activateAndRevealWorktree to return false but never verifies that the function called it. Add a call assertion so the test fails if the implementation returns failed without attempting activation.

Suggested assertion
     expect(openLinearIssueWorkspaceOrStart({ identifier: 'ENG-1' }, startWorkspace)).toBe('failed')
+    expect(mocks.activateAndRevealWorktree).toHaveBeenCalledTimes(1)
     expect(startWorkspace).not.toHaveBeenCalled()

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fd0afda6-72be-4208-96c8-8838fc0323ac

📥 Commits

Reviewing files that changed from the base of the PR and between 3e2337e4a516a9f8f2b1e4f83f86a6a4669412d0 and 459c33095fe3527ae99db1e9dd4c543b923a8504.

📒 Files selected for processing (7)
  • src/renderer/src/components/LinearIssueWorkspace.tsx
  • src/renderer/src/components/TaskPage.tsx
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/linear-issue-workspace-open.test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/components/LinearIssueWorkspace.tsx
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/components/TaskPage.tsx

Enable users to view and open existing workspaces attached to Linear issues
instead of accidentally starting duplicates. Includes shared worktree attachment
labeling for consistent UX across GitHub and Linear surfaces.
- Apply search filter in 'in-orca' mode even without active context label to prevent
  team filters from silently hiding linked tickets (no "Fetch more" recovery path)
- Add aria-label to workspace-open button for accessibility
- Update tooltip from "local worktree" to "Orca workspace"
- Reorganize i18n: move workspace.open from lib.linear to components.issue
- Expand test coverage for workspace start and activation scenarios
@AmethystLiang
AmethystLiang force-pushed the show-linked-linear-ticket branch from 459c330 to c5083eb Compare August 5, 2026 05:09
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

React Doctor fails static analysis when refs are written during render.
Keep the latest linked refs in an effect so the in-orca loader can still
read them without re-running on identity-only worktree churn.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@AmethystLiang
AmethystLiang merged commit eebaf47 into main Aug 5, 2026
40 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ees (stablyai#12632)

* feat(linear): add 'Has Workspace' mode to show issues linked to local wo

Enable users to view and open existing workspaces attached to Linear issues
instead of accidentally starting duplicates. Includes shared worktree attachment
labeling for consistent UX across GitHub and Linear surfaces.

* fix(linear): apply search filter in 'in-orca' mode to prevent drops

- Apply search filter in 'in-orca' mode even without active context label to prevent
  team filters from silently hiding linked tickets (no "Fetch more" recovery path)
- Add aria-label to workspace-open button for accessibility
- Update tooltip from "local worktree" to "Orca workspace"
- Reorganize i18n: move workspace.open from lib.linear to components.issue
- Expand test coverage for workspace start and activation scenarios

* fix(linear): avoid mutating in-orca linked refs during render

React Doctor fails static analysis when refs are written during render.
Keep the latest linked refs in an effect so the in-orca loader can still
read them without re-running on identity-only worktree churn.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant