Repository navigation
fix(gitlab): find issues and #N in the new-workspace gitlab source - #32005
Conversation
…y origin/upstream
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0cb74413-c73c-4599-aeaf-8a406c849340
📒 Files selected for processing: 9
src/main/gitlab/client-work-items.test.tssrc/main/gitlab/gitlab-issue-source-resolution.tssrc/main/gitlab/gitlab-project-ref-resolution.tssrc/main/gitlab/gl-utils.test.tssrc/main/gitlab/gl-utils.tssrc/main/gitlab/work-item-queries.tssrc/renderer/src/components/new-workspace/use-smart-workspace-gitlab-search.tssrc/renderer/src/lib/gitlab-work-item-source-lookup.test.tssrc/renderer/src/lib/gitlab-work-item-source-lookup.ts
💤 Files with no reviewable changes: 1
- src/main/gitlab/gitlab-project-ref-resolution.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
… sign-in probe and onboarding trust prompt - setup-script-import: imported setups are saved from the Review setup script dialog since #37937. - github-url-smart-input-transition: the GitLab source lists through gitlab:listWorkItems since #32005, so stub that channel. - structured-chat-tabs-open-close: the Claude catalog probe also sends an initialize request for sign-in discovery since #37191. - golden-core-flows: onboarding launches the chosen agent in the fresh ~ workspace (#37898), whose first launch asks the per-repo agent folder trust question (#38946); answer it before adding a project.
… sign-in probe and onboarding trust prompt (#39983) - setup-script-import: imported setups are saved from the Review setup script dialog since #37937. - github-url-smart-input-transition: the GitLab source lists through gitlab:listWorkItems since #32005, so stub that channel. - structured-chat-tabs-open-close: the Claude catalog probe also sends an initialize request for sign-in discovery since #37191. - golden-core-flows: onboarding launches the chosen agent in the fresh ~ workspace (#37898), whose first launch asks the per-repo agent folder trust question (#38946); answer it before adding a project. Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
ELI5
In the new-workspace dialog, the GitLab source only ever found merge requests. Typing a word or
#23never found issues. It now finds both, like the GitHub source next to it.What Changed
listMRs, so a project with issues and no matching MRs showed an empty list. Only a pasted issue URL found an issue.listWorkItems(MRs + issues, merged and sorted by update time). It goes through the samegitLabApiForrouting, so local, SSH and paired-runtime repos all work. Cmd-J and mobile already use this query. The MR-only renderer helper is gone;listMRsitself stays for the Tasks page.#23now finds issue 23. GitLab's RESTsearchparam matches title and description text only (on gitlab-org/cli,search=#1000returns 13 issues and none of them is [Feature]: Support idempotent distros #1000;iids[]=1000returns it). SofetchIssuesAsWorkItemssends a#Nquery asiids[]=N. That's GitLab's own issue reference syntax. MRs keep the text search, which still surfaces MRs that mention#23.listWorkItemsdrops the issue fetch formerged), and the hook still cuts the merged list toRESULT_LIMIT.Why
Root cause:
use-smart-workspace-gitlab-search.tscalled the MR-only list, and GitLab's text search can't match an issue number. Swapping the call fixes words. The#Nrule lives in main's issue fetch, the one place the dialog, Cmd-J and mobile all reach, so they all get it.Compatibility: no new IPC/RPC method or field.
gitlab.listWorkItemshas existed since #2452, so a new desktop works with older paired servers. An older server just text-searches#N.Remote names:
listMRshad a cwdglab mr listfallback for local repos where noorigin/upstreamGitLab project resolves, for example a GitLab remote namedgitlab.listWorkItemshad no such fallback, so on its own the swap would have lost those MRs. I didn't move the cwd fallback: the dialog shows the GitLab source for every repo when glab is installed, so it spawnedglab mr liston every debounced query for every GitHub repo, and moving it would bring that to Cmd-J and mobile. The fix is in project detection instead. Whenoriginandupstreamdon't resolve,getIssueProjectReftries the repo's other remotes through the same cachedgetProjectRefForRemoteprobe. A remote namedgitlabgoes first, matching glab's ownremoteNameSortScore. Every caller of the default issue source gets this: the dialog, Cmd-J, mobile, issue details and updates. It adds no glab spawn for GitHub repos. The remote list is cached, the extra remotes reuse the per-host auth memo thatoriginalready filled, and SSH repos list no remotes here, which is what the old fallback did too. I moved the preference resolver out ofgitlab-project-ref-resolution.tsintogitlab-issue-source-resolution.tsto keep that file under the 300-line limit.Linked Issue
Fixes #31218
Linear: STA-11422
Visual Proof
Real dev build against the public gitlab-org/cli project (local clone, glab 1.124.0), GitLab source, Open chip.
release#8644releasebefore: 12 rows, all MRs (the shot is scrolled to the end of the list). After: 6 MRs, then issues#8651,#8649,#1165,#7675,#8644,#7859.#8644before: empty. After: the issue.Testing
glabagainst gitlab.com. Word search returns MRs and issues;#8644returns the issue; the Merged chip returns 12 rows, all MRs.client-work-items.test.tscase pins#Ntoiids[](fails without the fix). The source-lookup routing tests now pinlistWorkItemsover runtime RPC and local IPC. Newgl-utils.test.tscases: a GitHuboriginwith GitLab remotesa-forkandgitlabresolvesgitlab(fails without the fix, and fails without thegitlab-first order), and a GitHub-only repo with an extra remote adds no glab probe.SSH and Windows were not run by hand. The issue fetch already runs on the owning host (
glabRepoExecOptions/glabHostnameArgs), and the request path already carries?and&, soiids[]adds no new quoting.Review
Agent skill upstream boundary
Notes
Follow-ups, not in this PR:
!N(GitLab's MR reference) still text-searches MRs. Project detection doesn't expand SSH host aliases (git@gitlab-work:group/repo.gitwith an~/.ssh/configalias). The old cwd fallback let glab expand them, so the dialog loses MR results for those checkouts, the same as Cmd-J and mobile today.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)