Skip to content

fix(desktop): return direct-lookup PR/issue regardless of state#4190

Merged
saddlepaddle merged 1 commit into
mainfrom
fix-pr-search-modal
May 7, 2026
Merged

fix(desktop): return direct-lookup PR/issue regardless of state#4190
saddlepaddle merged 1 commit into
mainfrom
fix-pr-search-modal

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 7, 2026

Summary

  • Pasting a same-repo PR URL (or #N) into the v2 new-workspace modal returned an empty list when the PR was closed or merged. The direct-lookup branch was applying the same !includeClosed && state !== open filter as the text-search branch, so the dropdown rendered "No open pull requests found." with no hint that the PR actually existed.
  • Direct lookups are unambiguous: the user named a specific PR/issue and wants that one back. State filtering only makes sense for the browse/text-search branch where it bounds an open-ended result set.
  • Drop the state guard from both gh and Octokit direct-lookup branches in searchPullRequests and searchGitHubIssues. Kept the entity-type guards (/pull/ URL check, issue.pull_request) that prevent issues from leaking into PR results and vice versa.

Test plan

  • Open v2 new-workspace modal, click PR icon, paste a URL of an open PR for the project's repo → resolves to that PR
  • Same dropdown, paste URL of a merged PR with "Show closed" unchecked → resolves to that PR (was returning empty)
  • Same dropdown, paste URL of a closed PR with "Show closed" unchecked → resolves to that PR
  • Paste #N shorthand for a closed PR → resolves
  • Paste cross-repo URL → still shows "PR URL must match owner/name"
  • Type free text → text-search branch still respects "Show closed"
  • Repeat the above for the GitHub issue dropdown

Summary by cubic

Return the exact PR/issue when a same-repo URL or #N is pasted in the v2 new-workspace modal, even if it’s closed or merged. Text search still respects “Show closed”.

  • Bug Fixes
    • Removed state filtering from direct-lookup paths in searchPullRequests and searchGitHubIssues (GH and Octokit).
    • Kept entity-type guards to prevent PRs from appearing in issues (and vice versa).

Written for commit c4a8a8f. Summary will update on new commits.

Summary by CodeRabbit

Bug Fixes

  • Direct pull request lookups now consistently return results regardless of the open/closed state filter.
  • Improved pull request detection in GitHub issue searches to prevent incorrect filtering.
  • Enhanced consistency between direct lookups and general search queries for pull requests.

… state

Pasting a same-repo PR URL (or `#N`) into the v2 new-workspace modal
returned an empty list when the PR was closed or merged, because the
direct-lookup branch ran the same `!includeClosed && state !== open`
filter as the text-search branch. The dropdown rendered "No open pull
requests found." with no hint that the PR existed.

Direct lookups are unambiguous — the user named a specific PR/issue and
wants that one back. State filtering only makes sense for the
browse/text-search branch where it bounds an open-ended result set.

Drop the state guard from both gh and Octokit direct-lookup branches in
searchPullRequests and searchGitHubIssues. Keep the entity-type guards
(`/pull/` URL check, `issue.pull_request` field) that prevent issues
from leaking into PR results and vice versa — those aren't about state.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d81fec0-c0bd-43ba-bafe-aeefab2cd5ae

📥 Commits

Reviewing files that changed from the base of the PR and between cac1fef and c4a8a8f.

📒 Files selected for processing (2)
  • packages/host-service/src/trpc/router/workspace-creation/procedures/search-github-issues.ts
  • packages/host-service/src/trpc/router/workspace-creation/procedures/search-pull-requests.ts
💤 Files with no reviewable changes (2)
  • packages/host-service/src/trpc/router/workspace-creation/procedures/search-github-issues.ts
  • packages/host-service/src/trpc/router/workspace-creation/procedures/search-pull-requests.ts

📝 Walkthrough

Walkthrough

Two GitHub issue and pull-request lookup procedures are refactored. The issue lookup now explicitly detects and rejects PR results by checking URL paths or PR fields in direct lookups. The PR lookup removes state-based filtering in direct lookups, returning resolved PRs regardless of open/closed status, while search queries continue to respect the includeClosed filter.

Changes

Direct Lookup Filtering

Layer / File(s) Summary
Issue Direct Lookup — PR Detection
packages/host-service/src/trpc/router/workspace-creation/procedures/search-github-issues.ts
gh CLI and Octokit fallback paths now detect when a numeric input resolves to a PR using URL path (/pull/) or pull_request field presence, returning empty issues in both cases.
PR Direct Lookup — State Filter Removal
packages/host-service/src/trpc/router/workspace-creation/procedures/search-pull-requests.ts
gh CLI and Octokit fallback paths no longer skip closed PRs in direct lookups; both always return the resolved PR regardless of includeClosed value. Search queries retain state filtering.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through GitHub's data store,
Fixing lookups to distinguish more—
When PRs hide as issues in the view,
Direct detects and filters through.
State filtering removed for direct PR requests,
Now lookups return regardless—much the best!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing state filtering from direct-lookup PR/issue resolution in the v2 new-workspace modal.
Description check ✅ Passed The PR description includes all required template sections: a clear summary of the bug and fix, related issue links via checklist, bug fix type selection, comprehensive test plan, and detailed notes on the implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-pr-search-modal

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 and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 7, 2026

Greptile Summary

Direct-lookup paths for PRs and issues now bypass the includeClosed state filter, so pasting a specific PR/issue URL or #N shorthand into the new-workspace modal correctly returns the item regardless of whether it is open, closed, or merged. Text-search branches that operate on open-ended result sets are untouched.

  • search-pull-requests.ts: Drops the state !== \"open\" guard from both the gh pr view and octokit.pulls.get direct-lookup branches; ghSearch/octokit.search branches still pass includeClosed to bound unbounded result sets.
  • search-github-issues.ts: Identical treatment — the /pull/ URL check and issue.pull_request entity-type guards that prevent PR numbers from leaking into issue results are kept intact.

Confidence Score: 5/5

Safe to merge — the change is a small, targeted removal of a filter that was incorrectly applied to unambiguous direct lookups.

Both files make the same minimal, symmetrical change: dropping the state guard from the direct-lookup branch while leaving the text-search branch untouched. The entity-type guards that prevent PRs from surfacing in issue results (and vice versa) are fully preserved. The gh-CLI and Octokit fallback paths both receive the same treatment, so neither code path regresses. No new logic is introduced that could produce wrong data or unexpected side effects.

No files require special attention.

Important Files Changed

Filename Overview
packages/host-service/src/trpc/router/workspace-creation/procedures/search-pull-requests.ts Removes the includeClosed state guard from both the gh-CLI and Octokit direct-lookup branches so pasting a specific PR URL/number always returns that PR regardless of state; text-search branch is unchanged.
packages/host-service/src/trpc/router/workspace-creation/procedures/search-github-issues.ts Same targeted removal of the includeClosed state guard from the direct-lookup branches; the /pull/ URL check and issue.pull_request entity-type guards are correctly retained.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User pastes query] --> B{normalizeGitHubQuery}
    B -- repoMismatch --> C[Return repoMismatch error]
    B -- isDirectLookup=true --> D[Direct Lookup Branch]
    B -- isDirectLookup=false --> E[Text-Search Branch]

    D --> F{Try gh CLI}
    F -- success --> G["Return item (any state) ✅"]
    F -- error --> H{Try Octokit}
    H -- success --> I["Return item (any state) ✅"]
    H -- error --> J[Rethrow → error toast]

    E --> K{includeClosed?}
    K -- false --> L[Filter: open only]
    K -- true --> M[Filter: all states]
    L --> N[Return filtered results]
    M --> N

    style G fill:#d4edda
    style I fill:#d4edda
Loading

Reviews (1): Last reviewed commit: "fix(host-service): always return direct-..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@saddlepaddle saddlepaddle merged commit 5564161 into main May 7, 2026
17 checks passed
@saddlepaddle saddlepaddle mentioned this pull request May 7, 2026
4 tasks
saddlepaddle added a commit that referenced this pull request May 7, 2026
Changes since v0.2.11:

- workspaces: add `superset workspaces update <id> --name "..."` for
  renaming. Branch/host moves stay desktop-only — they require host-side
  git orchestration that isn't safe to drive from the cloud directly.
  (#4189)
- organization: new `superset organization members list` command (also
  exposed via SDK + mcp-v2). Read-only — add/remove keep their
  existing UI flows. (#4197)
- tasks: new `superset tasks statuses list` command surfacing the
  organization's configured task statuses. (#4197)
- host-service: paste a closed/merged PR URL or `#N` into the v2
  new-workspace modal and the dropdown actually returns the PR instead
  of "No open pull requests found." Direct lookups now ignore the
  open-only state filter that bounds text-search results. (#4190)

Push cli-v0.2.12 after this lands to fire the release pipeline.
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