π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π Fix Working Sidebar PR items opening externally (#19782)
Innei23fd4917d014
diff --git a/src/features/Conversation/WorkingSidebar/Overview/index.tsx b/src/features/Conversation/WorkingSidebar/Overview/index.tsxindex 258422a27ea..6133316a354 100644--- a/src/features/Conversation/WorkingSidebar/Overview/index.tsx+++ b/src/features/Conversation/WorkingSidebar/Overview/index.tsx@@ -1,5 +1,6 @@'use client';+import type { DeviceGitLinkedPullRequest } from '@lobechat/types';import { Empty, Flexbox, Icon, Tooltip } from '@lobehub/ui';import { Button, Skeleton, toast } from '@lobehub/ui/base-ui';import { SkillsIcon } from '@lobehub/ui/icons';@@ -38,11 +39,9 @@ import { dbMessageSelectors } from '@/store/chat/selectors';import {useFetchGitAheadBehind,useFetchGitBranch,- useFetchGitLinkedPR,useFetchGitWorktrees,useReviewPatches,} from '@/store/device';-import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';import ProgressSection from '../ProgressSection';import { collectChangeStats, isLinkedWorktreeCheckout, shouldShowCiLabel } from './overviewData';@@ -66,7 +65,9 @@ interface OverviewProps {deviceId?: string;environmentAvailable: boolean;onOpenTab: (tab: string) => void;- prAvailable?: boolean;+ onRefreshPullRequest: () => Promise<unknown>;+ /** Parent-owned so the Overview row and the on-demand PR tab cannot disagree. */+ pullRequest?: DeviceGitLinkedPullRequest | null;repoType?: string;sourcePath?: string;workingDirectory?: string;@@ -81,7 +82,8 @@ const Overview = memo<OverviewProps>(deviceId,environmentAvailable,onOpenTab,- prAvailable,+ onRefreshPullRequest,+ pullRequest,repoType,sourcePath,workingDirectory,@@ -121,13 +123,6 @@ const Overview = memo<OverviewProps>(deviceId,gitPath,);- const { data: prData, mutate: mutatePR } = useFetchGitLinkedPR(- deviceId,- gitPath,- branch,- isGithub,- );-const [switcherOpen, setSwitcherOpen] = useState(false);const [pulling, setPulling] = useState(false);const [pushing, setPushing] = useState(false);@@ -148,9 +143,9 @@ const Overview = memo<OverviewProps>(mutateAheadBehind(),mutateReview(),mutateWorktrees(),- mutatePR(),+ onRefreshPullRequest(),]);- }, [mutateBranch, mutateAheadBehind, mutateReview, mutateWorktrees, mutatePR]);+ }, [mutateBranch, mutateAheadBehind, mutateReview, mutateWorktrees, onRefreshPullRequest]);// Flip the displayed branch instantly on checkout; the switcher's// onAfterCheckout reconciles once the checkout lands (same as GitStatus).@@ -203,7 +198,6 @@ const Overview = memo<OverviewProps>(}}, [deviceId, refreshGit, syncBusy, tDevice, workingDirectory]);- const pullRequest = prData?.pullRequest;const ciStatus = pullRequest?.ciStatus;const ci = pullRequest ? getCiVisual(ciStatus) : undefined;const prVisual = pullRequest ? PR_STATE_VISUAL[getPullRequestState(pullRequest)] : undefined;@@ -358,13 +352,7 @@ const Overview = memo<OverviewProps>({pullRequest.title}</>}- onClick={- prAvailable- ? () => onOpenTab('pr')- : pullRequest.url- ? () => openTrustedExternalUrl(pullRequest.url)- : undefined- }+ onClick={() => onOpenTab('pr')}/></div></Tooltip>diff --git a/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx b/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsxindex 7df7ebbfdf6..35cebe728a2 100644--- a/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx+++ b/src/features/Conversation/WorkingSidebar/__tests__/index.test.tsx@@ -205,16 +205,23 @@ vi.mock('../Overview', () => ({default: ({environmentAvailable,onOpenTab,+ pullRequest,workingDirectory,}: {environmentAvailable: boolean;onOpenTab: (tab: string) => void;+ pullRequest?: { number: number };workingDirectory?: string;}) => (<><button type="button" onClick={() => onOpenTab('review')}>Open Review from Overview</button>+ {pullRequest && (+ <button type="button" onClick={() => onOpenTab('pr')}>+ Open Pull Request from Overview+ </button>+ )}{environmentAvailable && <span>Workspace environment</span>}{workingDirectory && <span>{workingDirectory}</span>}</>@@ -535,6 +542,21 @@ describe('AgentWorkingSidebar β controlled panel width', () => {rerender(<AgentWorkingSidebar availableWidth={1601} />);expect(screen.getByLabelText('PR draft')).toHaveValue('');});++ it('opens a linked pull request from Overview in the Working Sidebar tab', () => {+ reviewState.repoType = 'github';+ reviewState.workingDirectory = '/repo';+ linkedPR.number = 42;+ linkedPR.status = 'ok';++ render(<AgentWorkingSidebar />);++ fireEvent.click(screen.getByRole('button', { name: 'Open Pull Request from Overview' }));++ expect(globalStore.openWorkingSidebar).toHaveBeenCalledWith('pr');+ expect(screen.getByRole('button', { name: '#42' })).toHaveAttribute('aria-pressed', 'true');+ });+it('seeds the RightPanel with the default width', () => {render(<AgentWorkingSidebar />);diff --git a/src/features/Conversation/WorkingSidebar/index.tsx b/src/features/Conversation/WorkingSidebar/index.tsxindex b8e3b48f1bf..4790e97df41 100644--- a/src/features/Conversation/WorkingSidebar/index.tsx+++ b/src/features/Conversation/WorkingSidebar/index.tsx@@ -389,7 +389,7 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })repoType === 'github' || (!repoType && !!snapshotConfig?.git?.github?.pullRequest);const gitPath = filesystemEnvironmentAvailable && isGithub ? workingDirectory : undefined;const { data: branchData } = useFetchGitBranch(remoteDeviceId, gitPath);- const { data: linkedPR } = useFetchGitLinkedPR(+ const { data: linkedPR, mutate: refreshPullRequest } = useFetchGitLinkedPR(remoteDeviceId,gitPath,branchData?.branch,@@ -406,7 +406,6 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })? linkedPR.pullRequest: (linkedPR?.pullRequest ?? snapshotPR): undefined;- const prAvailable = !!pullRequest;const paramsAvailable = !isHetero;// The in-app browser pages are renderer-retained Electron webviews β desktop only.const browserAvailable = isDesktop;@@ -992,11 +991,12 @@ const AgentWorkingSidebar = memo<AgentWorkingSidebarProps>(({ availableWidth })agentId={activeAgentId}deviceId={remoteDeviceId}environmentAvailable={filesystemEnvironmentAvailable}- prAvailable={prAvailable}+ pullRequest={pullRequest}repoType={environmentRepoType}sourcePath={sourceWorkingDirectory}workingDirectory={environmentWorkingDirectory}onOpenTab={openTab}+ onRefreshPullRequest={refreshPullRequest}/></Flexbox></m.div>