fix(gitlab): thread MR search query and surface MR base failures (#6263) (#6591)

Defect 1: the typed GitLab MR search query was dropped before reaching
the API. Thread query?: string end-to-end through the renderer effect,
the source-lookup, the preload/RPC args, and the desktop IPC handlers
(which previously passed a hardcoded undefined), and honor it on both the
glab REST path (&search=) and the cwd-inferred 'glab mr list' fallback.

Defect 2: when MR base resolution failed the renderer silently returned,
leaving baseBranch undefined so the worktree was created off the repo
default branch (origin/master) with no feedback. Surface the failure via
toast and clear stale base state, mirroring the GitHub PR path. Also make
resolveManagedMrBase resilient to an optional compare-base (target branch)
fetch failure: degrade gracefully by dropping compareBaseRef instead of
aborting, so a merged MR with a deleted target ref still resolves to its
valid source-branch base.

Fixes #6263

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-06-28 18:05:29 -07:00
committed by GitHub
co-authored by Orca
parent f49808c540
commit 31bfeff01d
19 changed files with 313 additions and 35 deletions
+17
View File
@@ -21,6 +21,23 @@ export function normalizeGitLabIssueListState(value: unknown): GitLabIssueListSt
return value === 'closed' || value === 'all' ? value : 'opened'
}
// Why: cap the free-text MR search at the same byte budget the renderer
// enforces (SMART_WORKSPACE_SOURCE_QUERY_MAX_BYTES) so the RPC/SSH path —
// which can be driven by callers other than the desktop input — can't push
// an unbounded string into the glab `&search=` query.
const GITLAB_SEARCH_QUERY_MAX_BYTES = 2048
export function normalizeGitLabSearchQuery(value: unknown): string | undefined {
if (typeof value !== 'string') {
return undefined
}
const trimmed = value.trim()
if (!trimmed) {
return undefined
}
return Buffer.byteLength(trimmed, 'utf8') > GITLAB_SEARCH_QUERY_MAX_BYTES ? undefined : trimmed
}
export function normalizeGitLabIssueAssignee(value: unknown): '@me' | undefined {
// Why: the renderer only exposes "Assigned to me"; accepting arbitrary
// values would turn preload/RPC boundaries into a generic glab flag surface.