fix(ui): provider-aware context rail branding for GitLab

This commit is contained in:
2026-08-16 16:24:40 +00:00
parent 06a5dd63bb
commit 7bf07f0dd9
17 changed files with 87 additions and 16 deletions
@@ -23,10 +23,11 @@ edge (`components/layout/ContextPanelRail.tsx`) and rendered by
- `getVisibleContextRailSurfaces` is the single visibility filter shared by the
rail and the global surface-switch shortcut (`switch_context_surface` in
`lib/shortcuts.ts`): it drops the plan surface unless plan mode is enabled,
drops the walkthrough on VS Code and below `WALKTHROUGH_MIN_WIDTH`, and hides
`has-content` surfaces until a tab of their mode exists. Both consumers use
it so the digit shown on a rail badge always maps to the same surface the
shortcut opens.
drops the walkthrough on VS Code and below `WALKTHROUGH_MIN_WIDTH`, hides
`has-content` surfaces until a tab of their mode exists, and drops the `pr`
surface when the repository is on a git provider other than GitHub or GitLab
(`gitProvider: 'other'`). Both consumers use it so the digit shown on a rail
badge always maps to the same surface the shortcut opens.
## Adding a surface
@@ -59,6 +59,17 @@ describe('getVisibleContextRailSurfaces', () => {
expect(getVisibleContextRailSurfaces(baseOptions).some((s) => s.id === 'browser')).toBe(true);
});
test('hides the pr surface for other git providers but keeps it for github/gitlab', () => {
expect(getVisibleContextRailSurfaces({ ...baseOptions, gitProvider: 'other' }).some((s) => s.id === 'pr')).toBe(false);
expect(getVisibleContextRailSurfaces({ ...baseOptions, gitProvider: 'gitlab' }).some((s) => s.id === 'pr')).toBe(true);
expect(getVisibleContextRailSurfaces({ ...baseOptions, gitProvider: 'github' }).some((s) => s.id === 'pr')).toBe(true);
});
test('keeps the pr surface while the git provider is unknown', () => {
expect(getVisibleContextRailSurfaces({ ...baseOptions, gitProvider: null }).some((s) => s.id === 'pr')).toBe(true);
expect(getVisibleContextRailSurfaces(baseOptions).some((s) => s.id === 'pr')).toBe(true);
});
test('respects the persisted user rail order', () => {
const surfaces = getVisibleContextRailSurfaces({ ...baseOptions, railOrder: ['git', 'context'] });
expect(surfaces.slice(0, 2).map((surface) => surface.id)).toEqual(['git', 'context']);
+13
View File
@@ -188,6 +188,12 @@ type VisibleRailSurfacesOptions = {
isVSCode: boolean;
screenWidth: number;
tabs: readonly { mode: ContextPanelMode }[];
/**
* The repository's git provider. The 'pr' surface renders the GitHub pull
* request / GitLab merge request view; it is hidden for repositories on
* any other provider. null (unknown, still resolving) keeps it visible.
*/
gitProvider?: 'github' | 'gitlab' | 'other' | null;
};
/**
@@ -203,6 +209,13 @@ export const getVisibleContextRailSurfaces = (options: VisibleRailSurfacesOption
if (surface.id === 'plan' && !options.planModeEnabled) {
return false;
}
// The 'pr' surface hosts the GitHub PR / GitLab MR view. Neither applies
// to repositories on other providers, so the rail button (and its shortcut
// digit) must not appear. Unknown (null) keeps it while the provider is
// still resolving — it is not a reason to hide the surface.
if (surface.id === 'pr' && options.gitProvider === 'other') {
return false;
}
// The walkthrough needs room for a stop list beside real code, and its
// diffs come from OpenChamber's Git routes, which VS Code does not serve.
if (surface.id === 'walkthrough' && (options.isVSCode || options.screenWidth < WALKTHROUGH_MIN_WIDTH)) {