feat(ui): context panel 2.0 - surface rail, changes-first git view, live PR surface (#2418)
* feat(ui): add context surface registry and rail switcher * feat(ui): move git and project notes into context surfaces, embed editor file tree * feat(ui): replace right sidebar with context surfaces, per-surface panel widths * refactor(ui): retire legacy main-tab overlays and right-sidebar state * feat(ui): rail polish, right-docked file tree, terminal surface * feat(ui): move terminal into context surface, per-surface tab closing, editor empty state * feat(ui): tune default rail order and activity dot * fix(ui): keep context panel controls anchored during width animations * feat(ui): lazy-follow context panel resize with window-level drag tracking * feat(ui): panel dividers, right-dock tree icon, muted outline folder icons * feat(ui): restructure git view into changes-first surface with standalone PR surface - Remove commit/update/pr tabs; git view is always changes + commit - Promote pull request to its own rail surface with shared repo context - Move update-branch and re-integrate flows into separate dialogs - Add PR status chip and repo actions menu to the git header row - Seed new PR-status entries from resolved sibling remotes to avoid a false "checking status" state when the PR is already known - History/graph dialog refresh button, fingerprint global identity icon, muted outline folder icons follow-ups * feat(ui): progressive-disclosure PR surface with live checks and pinned chat context - Segment the PR surface into Overview / Checks / Comments pill tabs with live badges; merge controls move to the status row - Live checks segment: progress bar, per-run rows with workflow names, elapsed timers, expandable failures, auto-refresh while pending - PR comments and failed checks pin as chat-context drafts (like terminal selections) instead of sending an immediate message; works on new-session drafts too - Shared prContext cache client+server, ETag conditional requests in the octokit wrapper (304s bypass rate limits), extended checks aggregate (inProgress/queued/startedAt) - Resolve gh-CLI auth login for merge-permission checks - Full-width description editor with matched control heights * fix(ui): single source of truth for PR checks and status readers - Derive the checks aggregate from the visible run list and sync it into the PR-status store so bar, badges, header, and git-view chip agree - Route PR body hydration through the shared context cache - Git-view PR chip reads the freshest entry across remote keys * fix(github): freshness stamps prevent stale cache responses from regressing PR state - pr/status and pulls/context responses carry a server-side fetchedAt that survives cache serves - The status store rejects responses older than the held snapshot (only clearing the loading flag), and the checks sync adopts the context's stamp so stale status polls cannot flip fresher derived checks - Regression test for the stale-response guard * perf(github): repo-level pull-list cache collapses per-branch PR resolution - One pulls.list per repo per state per 45s answers every branch (10 worktrees = 1 call, not 10 query fans); in-flight fetches coalesce - A complete repo list makes a no-PR miss authoritative, skipping the per-owner head queries AND the Search API fallback (the 30/min killer) - force refresh bypasses the repo list cache; PR create/merge/ready invalidate it * perf(github): back off Search API misses per repo+branch A branch without a PR re-searched on every poll; with >100 closed PRs the list miss is never authoritative, so the search fallback still ran and burned the 30/min search quota. Remember misses for 10 minutes; PR creation clears remembered misses for the repo. * fix(github): dedupe re-run check runs to the latest per (app, name) listForRef returns the superseded completed run alongside its re-run; GitHub's UI shows only the latest per name. Mirror that in both pr/status and pulls/context so counts and run lists match github.com. * fix(ui): address review findings on registry test, surface docs, and PR-context keys - Rail-order test asserts against the registry itself (was stale after the 'pr' surface landed and failed) - surfaces DOCUMENTATION.md describes actual behavior: has-content surfaces hide until content exists; only multi-instance/terminal panes are keep-alive, singleton surfaces remount and restore from stores - PR-context cache keys are runtime-scoped JSON tuples; invalidation compares the directory exactly instead of by string prefix (+ test) * fix(ui): wrap long unbreakable tokens in check-run details Annotation messages with long SHAs/URLs overflowed the panel; break-words on annotation title/message/rawDetails and output summary/text, and the expanded run body clips instead of widening the panel. * fix(ui): busy state for context-attach buttons and honest attach labels - 'Attach failed checks' / 'Attach all to chat' show a spinner and disable while the context request runs (previously nothing happened for seconds) - Action labels/tooltips reworded from send-to-agent to attach-to-chat semantics across all locales * fix(i18n): Ukrainian attach wording uses 'прикріпити' with proper cases * fix(ui): runtime-scope PR-view remote caches, correct surfaces doc on preview - Remote/remote-url caches in PullRequestView are keyed by runtime + directory so a backend switch never serves another runtime's remotes - surfaces DOCUMENTATION.md: preview is not keep-alive; preview tabs remount on switch like singleton surfaces * fix(ui): rail active color, clearer collapse icon, remove dead bottom-terminal dock Design-review feedback on the context panel: - Context rail: icons enlarged 16px -> 18px; the active surface is now highlighted with the primary color only (no background, no scale animation), replacing the previous scale-up effect that read as a resize rather than a selected state. - Files tree: the icon-only 'collapse all folders' toolbar button now uses collapse-vertical instead of contract-up-down, which was easily mistaken for a close button. The labelled 'Collapse all' dropdown item in the session sidebar keeps its icon since text removes the ambiguity. - Terminal: removed the leftover bottom-dock expand/close buttons that rendered in the context-panel terminal but controlled a dock that no longer exists (nothing toggles it anymore), so the expand button appeared to do nothing and duplicated the panel-header fullscreen control. Cleaned up the entire inert layer with it: four useUIStore fields (isBottomTerminalOpen/Expanded, bottomTerminalHeight, hasManuallyResizedBottomTerminal), five actions, their persistence, the MainLayout resize listener that only served the dock height, the dock-driven refit effect in TerminalView, and the terminalView.bottomDock.* keys across all 10 locale dictionaries. Validated: ui type-check and lint clean; messages parity test (2 pass) and useUIStore contextPanel test (13 pass) green; icon sprite regenerated via icons:generate. * refactor: use PR visual state for git header icon Derives the pull request icon color from a single visual state Covers merged, closed, draft, blocked, and open PR states Removes conditional class handling from the git header icon
This commit is contained in:
committed by
GitHub
parent
005b2e61b0
commit
e2fa7dbad2
@@ -46,7 +46,12 @@ interface BranchIntegrationSectionProps {
|
||||
isOperating?: boolean;
|
||||
operationLogs?: OperationLogEntry[];
|
||||
onOperationComplete?: () => void;
|
||||
mode?: 'dialog' | 'inline';
|
||||
/**
|
||||
* 'dialog' renders its own trigger button + dialog, 'inline' renders a
|
||||
* titled section, 'bare' renders just the form body for embedding in an
|
||||
* externally-owned dialog.
|
||||
*/
|
||||
mode?: 'dialog' | 'inline' | 'bare';
|
||||
defaultTargetBranch?: string;
|
||||
}
|
||||
|
||||
@@ -167,7 +172,7 @@ export const BranchIntegrationSection: React.FC<BranchIntegrationSectionProps> =
|
||||
}, [branchDropdownOpen]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (mode !== 'inline' || selectedBranch) return;
|
||||
if (mode === 'dialog' || selectedBranch) return;
|
||||
setSelectedBranch(resolveDefaultBranch());
|
||||
}, [mode, resolveDefaultBranch, selectedBranch]);
|
||||
|
||||
@@ -412,6 +417,10 @@ export const BranchIntegrationSection: React.FC<BranchIntegrationSectionProps> =
|
||||
|
||||
const body = isOperating ? renderOperating() : renderForm();
|
||||
|
||||
if (mode === 'bare') {
|
||||
return body;
|
||||
}
|
||||
|
||||
if (mode === 'inline') {
|
||||
return (
|
||||
<section className="border-0 bg-transparent rounded-none">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SortableTabsStrip, type SortableTabsStripItem } from '@/components/ui/sortable-tabs-strip';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
@@ -18,6 +17,8 @@ import type {
|
||||
GitIdentityProfile,
|
||||
GitRemote,
|
||||
GitRemoteComparison,
|
||||
GitHubPullRequest,
|
||||
GitHubChecksSummary,
|
||||
} from '@/lib/api/types';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
|
||||
@@ -45,9 +46,11 @@ interface GitHeaderProps {
|
||||
onOpenHistory?: () => void;
|
||||
onOpenGraph?: () => void;
|
||||
onOpenStashes?: () => void;
|
||||
actionTabItems?: SortableTabsStripItem[];
|
||||
activeActionTab?: string;
|
||||
onSelectActionTab?: (tabID: string) => void;
|
||||
onOpenUpdateBranch?: () => void;
|
||||
onOpenReintegrateCommits?: () => void;
|
||||
pullRequest?: GitHubPullRequest | null;
|
||||
prChecks?: GitHubChecksSummary | null;
|
||||
onOpenPullRequest?: () => void;
|
||||
}
|
||||
|
||||
const IDENTITY_ICON_MAP: Record<string, IconName> = {
|
||||
@@ -58,6 +61,7 @@ const IDENTITY_ICON_MAP: Record<string, IconName> = {
|
||||
code: 'code',
|
||||
heart: 'heart',
|
||||
user: 'user-3',
|
||||
fingerprint: 'fingerprint',
|
||||
};
|
||||
|
||||
const IDENTITY_COLOR_MAP: Record<string, string> = {
|
||||
@@ -249,9 +253,11 @@ export const GitHeader: React.FC<GitHeaderProps> = ({
|
||||
onOpenHistory,
|
||||
onOpenGraph,
|
||||
onOpenStashes,
|
||||
actionTabItems,
|
||||
activeActionTab,
|
||||
onSelectActionTab,
|
||||
onOpenUpdateBranch,
|
||||
onOpenReintegrateCommits,
|
||||
pullRequest,
|
||||
prChecks,
|
||||
onOpenPullRequest,
|
||||
}) => {
|
||||
const { t } = useI18n();
|
||||
if (!status) {
|
||||
@@ -260,7 +266,7 @@ export const GitHeader: React.FC<GitHeaderProps> = ({
|
||||
|
||||
const managementButtons = (
|
||||
<div className="flex items-center gap-1 shrink-0">
|
||||
{onOpenHistory || onOpenGraph || onOpenStashes ? (
|
||||
{onOpenHistory || onOpenGraph || onOpenStashes || onOpenUpdateBranch ? (
|
||||
<DropdownMenu>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
@@ -271,7 +277,7 @@ export const GitHeader: React.FC<GitHeaderProps> = ({
|
||||
className="h-8 w-8 px-0"
|
||||
aria-label={t('gitView.header.repositoryViews')}
|
||||
>
|
||||
<Icon name="git-repository" className="size-4" />
|
||||
<Icon name="more-fill" className="size-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
</TooltipTrigger>
|
||||
@@ -286,7 +292,7 @@ export const GitHeader: React.FC<GitHeaderProps> = ({
|
||||
) : null}
|
||||
{onOpenGraph ? (
|
||||
<DropdownMenuItem onSelect={onOpenGraph}>
|
||||
<Icon name="git-merge" className="size-4" />
|
||||
<Icon name="git-branch" className="size-4" />
|
||||
{t('gitView.graph.title')}
|
||||
</DropdownMenuItem>
|
||||
) : null}
|
||||
@@ -296,12 +302,75 @@ export const GitHeader: React.FC<GitHeaderProps> = ({
|
||||
{t('gitView.stashes.title')}
|
||||
</DropdownMenuItem>
|
||||
) : null}
|
||||
{onOpenUpdateBranch ? (
|
||||
<DropdownMenuItem onSelect={onOpenUpdateBranch}>
|
||||
<Icon name="git-merge" className="size-4" />
|
||||
{t('gitView.header.updateBranch')}
|
||||
</DropdownMenuItem>
|
||||
) : null}
|
||||
{onOpenReintegrateCommits ? (
|
||||
<DropdownMenuItem onSelect={onOpenReintegrateCommits}>
|
||||
<Icon name="split-cells-horizontal" className="size-4" />
|
||||
{t('gitView.integrate.title')}
|
||||
</DropdownMenuItem>
|
||||
) : null}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
|
||||
const prChecksColor = prChecks
|
||||
? prChecks.state === 'success'
|
||||
? 'var(--status-success)'
|
||||
: prChecks.state === 'failure'
|
||||
? 'var(--status-error)'
|
||||
: 'var(--status-warning)'
|
||||
: null;
|
||||
|
||||
const prVisualState = pullRequest
|
||||
? pullRequest.state === 'merged'
|
||||
? 'merged'
|
||||
: pullRequest.state === 'closed'
|
||||
? 'closed'
|
||||
: pullRequest.draft
|
||||
? 'draft'
|
||||
: prChecks?.state === 'failure'
|
||||
|| pullRequest.mergeable === false
|
||||
|| pullRequest.mergeableState === 'blocked'
|
||||
|| pullRequest.mergeableState === 'dirty'
|
||||
? 'blocked'
|
||||
: 'open'
|
||||
: null;
|
||||
|
||||
const prChip = pullRequest && onOpenPullRequest ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={onOpenPullRequest}
|
||||
className="h-8 gap-1.5 px-2 typography-micro"
|
||||
>
|
||||
<Icon
|
||||
name="git-pull-request"
|
||||
className="size-3.5"
|
||||
style={{ color: `var(--pr-${prVisualState})` }}
|
||||
/>
|
||||
<span className="tabular-nums text-foreground/80">{t('gitView.pr.numberLabel', { number: pullRequest.number })}</span>
|
||||
{prChecksColor ? (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="h-1.5 w-1.5 rounded-full"
|
||||
style={{ backgroundColor: prChecksColor }}
|
||||
/>
|
||||
) : null}
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent sideOffset={8}>{t('gitView.header.openPullRequest')}</TooltipContent>
|
||||
</Tooltip>
|
||||
) : null;
|
||||
|
||||
const syncButtons = (
|
||||
<SyncActions
|
||||
syncAction={syncAction}
|
||||
@@ -360,30 +429,19 @@ export const GitHeader: React.FC<GitHeaderProps> = ({
|
||||
)}
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-1">
|
||||
{managementButtons}
|
||||
{identityControl}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{actionTabItems && activeActionTab && onSelectActionTab ? (
|
||||
<div className="mt-3 flex h-8 min-w-0 items-center gap-2">
|
||||
<div className="min-w-0 flex-1">
|
||||
<SortableTabsStrip
|
||||
items={actionTabItems}
|
||||
activeId={activeActionTab}
|
||||
onSelect={onSelectActionTab}
|
||||
layoutMode="fit"
|
||||
variant="active-pill"
|
||||
activePillButtonClassName="h-7"
|
||||
className="h-full"
|
||||
/>
|
||||
</div>
|
||||
{upstreamStatusPill ? (
|
||||
<div className="min-w-0 shrink">{upstreamStatusPill}</div>
|
||||
) : null}
|
||||
<div className="shrink-0">{syncButtons}</div>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="mt-3 flex h-8 min-w-0 items-center gap-2">
|
||||
{prChip ? <div className="shrink-0">{prChip}</div> : null}
|
||||
<div className="min-w-0 flex-1" />
|
||||
{upstreamStatusPill ? (
|
||||
<div className="min-w-0 shrink">{upstreamStatusPill}</div>
|
||||
) : null}
|
||||
{managementButtons}
|
||||
<div className="shrink-0">{syncButtons}</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -50,6 +50,8 @@ export const IntegrateCommitsSection: React.FC<{
|
||||
defaultTargetBranch: string;
|
||||
refreshKey?: number;
|
||||
onRefresh?: () => void;
|
||||
/** Hide the built-in section heading when a dialog already provides one. */
|
||||
showHeader?: boolean;
|
||||
}> = ({
|
||||
repoRoot,
|
||||
sourceBranch,
|
||||
@@ -58,6 +60,7 @@ export const IntegrateCommitsSection: React.FC<{
|
||||
defaultTargetBranch,
|
||||
refreshKey,
|
||||
onRefresh,
|
||||
showHeader = true,
|
||||
}) => {
|
||||
const { t } = useI18n();
|
||||
const currentSessionId = useSessionUIStore((s) => s.currentSessionId);
|
||||
@@ -332,22 +335,24 @@ export const IntegrateCommitsSection: React.FC<{
|
||||
|
||||
return (
|
||||
<section className={containerClassName}>
|
||||
<div className={headerClassName}>
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<Icon name="split-cells-horizontal" className="size-4 text-muted-foreground" />
|
||||
<h3 className="typography-ui-header font-semibold text-foreground truncate">{t('gitView.integrate.title')}</h3>
|
||||
{ui.kind === 'ready' && ui.plan.commits.length > 0 ? (
|
||||
<span className="typography-meta text-muted-foreground truncate">
|
||||
{t('gitView.integrate.toMoveCount', { count: ui.plan.commits.length })}
|
||||
</span>
|
||||
) : null}
|
||||
{showHeader ? (
|
||||
<div className={headerClassName}>
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<Icon name="split-cells-horizontal" className="size-4 text-muted-foreground" />
|
||||
<h3 className="typography-ui-header font-semibold text-foreground truncate">{t('gitView.integrate.title')}</h3>
|
||||
{ui.kind === 'ready' && ui.plan.commits.length > 0 ? (
|
||||
<span className="typography-meta text-muted-foreground truncate">
|
||||
{t('gitView.integrate.toMoveCount', { count: ui.plan.commits.length })}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{ui.kind === 'loading' || ui.kind === 'running' ? (
|
||||
<Icon name="loader-4" className="size-4 animate-spin text-muted-foreground" />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{ui.kind === 'loading' || ui.kind === 'running' ? (
|
||||
<Icon name="loader-4" className="size-4 animate-spin text-muted-foreground" />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className={bodyClassName}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Derives the base ("target") branch a feature branch should compare and
|
||||
* merge against. Shared by GitView and the standalone pull-request surface so
|
||||
* both resolve the same base for the same repository state.
|
||||
*/
|
||||
export const deriveBaseBranch = (options: {
|
||||
remoteNames: ReadonlySet<string>;
|
||||
localBranches: readonly string[];
|
||||
worktreeCreatedFromBranch?: string | null;
|
||||
rootBranchHint?: string | null;
|
||||
}): string => {
|
||||
const { remoteNames, localBranches, worktreeCreatedFromBranch, rootBranchHint } = options;
|
||||
|
||||
const normalizeBaseCandidate = (value: string): string => {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let normalized = value.trim();
|
||||
if (!normalized || normalized === 'HEAD') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (localBranches.includes(normalized)) {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
if (normalized.startsWith('refs/heads/')) {
|
||||
normalized = normalized.slice('refs/heads/'.length);
|
||||
}
|
||||
if (normalized.startsWith('heads/')) {
|
||||
normalized = normalized.slice('heads/'.length);
|
||||
}
|
||||
if (normalized.startsWith('remotes/')) {
|
||||
normalized = normalized.slice('remotes/'.length);
|
||||
}
|
||||
|
||||
const slashIndex = normalized.indexOf('/');
|
||||
if (slashIndex > 0) {
|
||||
const maybeRemote = normalized.slice(0, slashIndex);
|
||||
if (remoteNames.has(maybeRemote)) {
|
||||
const withoutRemote = normalized.slice(slashIndex + 1).trim();
|
||||
if (withoutRemote) {
|
||||
normalized = withoutRemote;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return normalized;
|
||||
};
|
||||
|
||||
const fromMeta = normalizeBaseCandidate(
|
||||
typeof worktreeCreatedFromBranch === 'string' ? worktreeCreatedFromBranch : ''
|
||||
);
|
||||
if (fromMeta) return fromMeta;
|
||||
|
||||
const fromHint = normalizeBaseCandidate(typeof rootBranchHint === 'string' ? rootBranchHint : '');
|
||||
if (fromHint) return fromHint;
|
||||
|
||||
if (localBranches.includes('main')) return 'main';
|
||||
if (localBranches.includes('master')) return 'master';
|
||||
if (localBranches.includes('develop')) return 'develop';
|
||||
return 'main';
|
||||
};
|
||||
Reference in New Issue
Block a user