From caeb786e97a134bc052d358a45c31f77d00d3a11 Mon Sep 17 00:00:00 2001
From: Marco Beretta <81851188+berry-13@users.noreply.github.com>
Date: Wed, 7 Oct 2026 12:36:57 +0200
Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20feat:=20Show=20the=20Conversatio?=
=?UTF-8?q?n=20Pull=20Request=20in=20the=20Sidebar=20List=20(#16815)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat: Show the Conversation Pull Request in the Sidebar List
Add a batch lookup route and a sidebar row mark: the state icon with the CI dot, opening the same card beside the row on hover. The row keeps the conversation's own title.
* fix: Address Review Findings on the Sidebar Pull Request Batch and Row Mark
Cap the whole batch with a configurable deadline, make the row mark a keyboard-reachable button that opens the card on focus, refresh rows when the window regains focus through the shared batch, and show a retryable failure state instead of treating a failed first lookup as no pull request.
* fix: Send Sidebar Pull Request Batches One at a Time
Queue every batch request behind the one before it, so an oversized list or an overlapping flush cannot multiply the server's configured lookup concurrency, and bound how long one request may hold the queue so a request that never answers cannot stop the rest.
* fix: Keep the Batch Request Timeout Above the Server Deadline
Default the client's request timeout to just past the longest batchTimeoutSeconds a deployment may configure, so a queued request never starts while the previous request's server-side lookups are still running.
* fix: Keep Batch Lookups Inside the Concurrency Limit and Per-Entry Failures Per Entry
Share one lookup limiter across every batch request so lookups that outlive a request's deadline keep their slot, answer a missing token only for the conversations that needed it, and point the row at its pull request description only while that text is in the page.
* fix: Bound Batch Reads, Scope Concurrency Per Credential, and Gate the Sidebar on the Batch Version
Start the batch deadline when the request arrives and bound the config and lane reads, count lookup slots per credential, advertise a batch route version and ask only a server that has it, take no row space for an absent mark, show a failed refresh over a cached empty answer, keep a malformed response from stalling the request queue, and repair the lane recording tests that still used a mock removed on dev.
* fix: Move Capability Resolution Into the Package and Harden the Batch Route and Queue
Resolve the pull request startup capabilities in packages/api so the route stays wiring only, bound the config and lane reads by the configured deadline, merge identical lanes before taking limiter slots, fall back to the single route when a replica has no batch route, and dispose the batch queue when the signed-in user changes.
* fix: Abort the Batch Fallback With Its Request So the Queue Never Overlaps It
Give the batch fetcher the request's abort signal and pass it to every single-route call, abort a request that times out or is disposed, and stop the fallback workers from starting more calls once it has.
* fix: Forward the Abort Signal to the Batch POST
Pass the request's abort signal through the batch fetcher, the data-provider call and Axios, so a batch request that times out or is disposed is cancelled instead of continuing beside the next one, and settle a request promptly when it is aborted.
* fix: Close the Pull Request Lookup Follow-Ups and Cancel Abandoned Sidebar Rows
---
.../__test-utils__/convos-route-mocks.js | 2 +
api/server/routes/__tests__/config.spec.js | 18 +
api/server/routes/config.js | 4 +-
api/server/routes/convos.js | 15 +-
api/server/services/ToolService.js | 1 +
.../services/__tests__/ToolService.spec.js | 49 ++
.../src/components/Chat/PullRequest/Chip.tsx | 47 +-
.../src/components/Chat/PullRequest/CiDot.tsx | 25 +
.../src/components/Chat/PullRequest/Panel.tsx | 58 ++
.../components/Chat/PullRequest/RowMark.tsx | 150 ++++
.../PullRequest/__tests__/RowMark.test.tsx | 438 ++++++++++
.../src/components/Chat/PullRequest/index.ts | 1 +
client/src/components/Conversations/Convo.tsx | 36 +-
.../__tests__/Convo.pullRequest.spec.tsx | 176 ++++
.../data-provider/PullRequest/batch.test.ts | 758 ++++++++++++++++++
client/src/data-provider/PullRequest/batch.ts | 300 +++++++
client/src/data-provider/PullRequest/index.ts | 1 +
.../PullRequest/queries.test.tsx | 147 +++-
.../src/data-provider/PullRequest/queries.ts | 89 +-
client/src/hooks/AuthContext.tsx | 2 +
.../src/hooks/__tests__/AuthContext.spec.tsx | 24 +
client/src/locales/en/translation.json | 1 +
librechat.example.yaml | 6 +
packages/api/src/code/decision.ts | 7 +-
packages/api/src/code/lane.spec.ts | 35 +
packages/api/src/code/lane.ts | 10 +-
packages/api/src/pulls/capabilities.spec.ts | 36 +
packages/api/src/pulls/capabilities.ts | 33 +
packages/api/src/pulls/github.spec.ts | 261 +++++-
packages/api/src/pulls/github.ts | 99 ++-
packages/api/src/pulls/handler.spec.ts | 652 ++++++++++++++-
packages/api/src/pulls/handler.ts | 397 ++++++++-
packages/api/src/pulls/index.ts | 3 +
packages/api/src/pulls/lookup.spec.ts | 41 +
packages/api/src/pulls/lookup.ts | 20 +-
packages/api/src/pulls/repository.ts | 8 +
packages/api/src/pulls/transport.spec.ts | 49 ++
packages/api/src/pulls/transport.ts | 21 +
packages/api/src/pulls/types.ts | 6 +
packages/data-provider/src/api-endpoints.ts | 2 +
packages/data-provider/src/config.spec.ts | 14 +
packages/data-provider/src/config.ts | 23 +
packages/data-provider/src/data-service.ts | 10 +-
packages/data-provider/src/request.ts | 3 +-
.../data-provider/src/types/pullRequest.ts | 23 +
.../src/methods/conversation.spec.ts | 174 ++++
.../data-schemas/src/methods/conversation.ts | 113 ++-
47 files changed, 4260 insertions(+), 128 deletions(-)
create mode 100644 client/src/components/Chat/PullRequest/CiDot.tsx
create mode 100644 client/src/components/Chat/PullRequest/Panel.tsx
create mode 100644 client/src/components/Chat/PullRequest/RowMark.tsx
create mode 100644 client/src/components/Chat/PullRequest/__tests__/RowMark.test.tsx
create mode 100644 client/src/components/Conversations/__tests__/Convo.pullRequest.spec.tsx
create mode 100644 client/src/data-provider/PullRequest/batch.test.ts
create mode 100644 client/src/data-provider/PullRequest/batch.ts
create mode 100644 packages/api/src/pulls/capabilities.spec.ts
create mode 100644 packages/api/src/pulls/capabilities.ts
create mode 100644 packages/api/src/pulls/repository.ts
create mode 100644 packages/api/src/pulls/transport.spec.ts
create mode 100644 packages/api/src/pulls/transport.ts
diff --git a/api/server/routes/__test-utils__/convos-route-mocks.js b/api/server/routes/__test-utils__/convos-route-mocks.js
index ce6a630d93..402c0877dd 100644
--- a/api/server/routes/__test-utils__/convos-route-mocks.js
+++ b/api/server/routes/__test-utils__/convos-route-mocks.js
@@ -148,7 +148,9 @@ module.exports = {
),
createBackgroundTaskPolicyMiddleware: jest.fn(() => (_req, _res, next) => next()),
createGitHubPullRequestSource: jest.fn(() => ({ find: jest.fn() })),
+ createProxyAwareFetch: jest.fn(() => jest.fn()),
createPullRequestLookup: jest.fn(() => jest.fn()),
+ createConversationPullRequestsHandler: jest.fn(() => jest.fn()),
createConversationPullRequestHandler: jest.fn(
() => (_req, res) => res.status(200).json({ pullRequest: null }),
),
diff --git a/api/server/routes/__tests__/config.spec.js b/api/server/routes/__tests__/config.spec.js
index 07f4de4234..c6386d6867 100644
--- a/api/server/routes/__tests__/config.spec.js
+++ b/api/server/routes/__tests__/config.spec.js
@@ -181,6 +181,7 @@ describe('GET /api/config', () => {
expect(response.body).not.toHaveProperty('conversationImportMaxFileSize');
expect(response.body).not.toHaveProperty('insightsEnabled');
expect(response.body).not.toHaveProperty('pullRequestsEnabled');
+ expect(response.body).not.toHaveProperty('pullRequestsBatchVersion');
expect(response.body).not.toHaveProperty('mcpApps');
});
@@ -683,9 +684,26 @@ describe('GET /api/config', () => {
});
const response = await request(createApp(mockUser)).get('/api/config');
expect(response.body.pullRequestsEnabled).toBe(expected);
+ /** The batch route's version rides with the flag, so a client never sees one without the other. */
+ if (expected) {
+ expect(response.body.pullRequestsBatchVersion).toBe(1);
+ expect(response.body.pullRequestsMaxConcurrentLookups).toBe(4);
+ } else {
+ expect(response.body).not.toHaveProperty('pullRequestsBatchVersion');
+ expect(response.body).not.toHaveProperty('pullRequestsMaxConcurrentLookups');
+ }
},
);
+ it('advertises the configured lookup limit so a fallback client can keep to it', async () => {
+ mockGetAppConfig.mockResolvedValue({
+ ...baseAppConfig,
+ endpoints: { agents: { pullRequests: { enabled: true, maxConcurrentLookups: 2 } } },
+ });
+ const response = await request(createApp(mockUser)).get('/api/config');
+ expect(response.body.pullRequestsMaxConcurrentLookups).toBe(2);
+ });
+
it('should not advertise pull requests for a config with no endpoints', async () => {
mockGetAppConfig.mockResolvedValue(baseAppConfig);
const response = await request(createApp(mockUser)).get('/api/config');
diff --git a/api/server/routes/config.js b/api/server/routes/config.js
index 3336a94d4c..62b0b7eb19 100644
--- a/api/server/routes/config.js
+++ b/api/server/routes/config.js
@@ -23,6 +23,7 @@ const {
resolveCodeWorkspaceInheritanceCapability,
resolveCodeEnvironmentTransitionVersion,
loadConversationListLimits,
+ resolvePullRequestCapabilities,
} = require('@librechat/api');
const {
DEFAULT_MCP_APP_CSP_LIMITS,
@@ -331,8 +332,7 @@ router.get('/', async function (req, res) {
langfuseConnectionAccess,
insightsEnabled: isEnabled(process.env.ENABLE_INSIGHTS),
/** Lets the client skip the pull request lookup entirely when the feature is off. */
- pullRequestsEnabled:
- appConfig?.endpoints?.[EModelEndpoint.agents]?.pullRequests?.enabled === true,
+ ...resolvePullRequestCapabilities(appConfig),
compactionEnabled: appConfig?.summarization?.enabled !== false,
...(codeEnvironmentDecisionVersion != null ? { codeEnvironmentDecisionVersion } : {}),
mcpApps: resolveMCPAppsPolicy(
diff --git a/api/server/routes/convos.js b/api/server/routes/convos.js
index 4c05abb57f..ef6b220150 100644
--- a/api/server/routes/convos.js
+++ b/api/server/routes/convos.js
@@ -21,7 +21,9 @@ const {
createBackgroundTaskPolicyMiddleware,
createConversationPullRequestHandler,
createGitHubPullRequestSource,
+ createProxyAwareFetch,
createPullRequestLookup,
+ createConversationPullRequestsHandler,
backgroundTaskRegistry,
createSubagentThreadViewHandler,
createGeneratedTitleHandler,
@@ -170,10 +172,20 @@ const backgroundTaskIndexHandler = createBackgroundTaskIndexHandler({
const backgroundTaskCancelHandler = createBackgroundTaskCancelHandler({
registry: backgroundTaskRegistry,
});
+/** One lookup, so the header's single route and the sidebar's batch route share its cache. */
+const pullRequestLookup = createPullRequestLookup({
+ source: createGitHubPullRequestSource({ fetchFn: createProxyAwareFetch() }),
+});
const conversationPullRequestHandler = createConversationPullRequestHandler({
getConvoLaneGit: db.getConvoLaneGit,
getAppConfig,
- lookup: createPullRequestLookup({ source: createGitHubPullRequestSource({ fetchFn: fetch }) }),
+ lookup: pullRequestLookup,
+ env: process.env,
+});
+const conversationPullRequestsHandler = createConversationPullRequestsHandler({
+ getConvosLaneGit: db.getConvosLaneGit,
+ getAppConfig,
+ lookup: pullRequestLookup,
env: process.env,
});
router.use(requireJwtAuth);
@@ -248,6 +260,7 @@ router.post(
subagentControlHandler,
);
router.get('/:parentConversationId/subagents', parentSubagentIndexHandler);
+router.post('/pull-requests', conversationPullRequestsHandler);
router.get('/:conversationId/pull-request', conversationPullRequestHandler);
router.get('/:conversationId/background-tasks', backgroundTaskPolicy, backgroundTaskIndexHandler);
router.post(
diff --git a/api/server/services/ToolService.js b/api/server/services/ToolService.js
index 632d884eca..446fe54004 100644
--- a/api/server/services/ToolService.js
+++ b/api/server/services/ToolService.js
@@ -2376,6 +2376,7 @@ async function loadToolsForExecution({
environmentId: codeExecutionContext.codeWorkspace.environmentId,
workspaceId: codeExecutionContext.codeWorkspace.workspaceId,
},
+ admittedEpoch: req.resolvedConversation?.codeAttachmentEpoch,
getConvoLaneContext,
reserveConvoLaneGitSeq,
setConvoLaneGit,
diff --git a/api/server/services/__tests__/ToolService.spec.js b/api/server/services/__tests__/ToolService.spec.js
index b00271883a..213827e73f 100644
--- a/api/server/services/__tests__/ToolService.spec.js
+++ b/api/server/services/__tests__/ToolService.spec.js
@@ -3274,6 +3274,55 @@ describe('ToolService - Action Capability Gating', () => {
expect(mockSetConvoLaneGit).toHaveBeenCalledWith(input);
});
+ it.each([
+ ['a moved conversation', 3, 3],
+ ['a conversation never moved', 0, 0],
+ ['a conversation whose admitted read carried no epoch', undefined, undefined],
+ ])(
+ 'fences the lane report by the epoch of the admitted decision for %s',
+ async (_label, admitted, expected) => {
+ const capabilities = [
+ AgentCapabilities.tools,
+ AgentCapabilities.execute_code,
+ AgentCapabilities.stateful_code_sessions,
+ ];
+ const req = createMockReq(capabilities);
+ req.config.endpoints[EModelEndpoint.agents].pullRequests = { enabled: true };
+ req.resolvedConversation = {
+ conversationId: 'resolved-convo',
+ codeWorkspaces: [{ environmentId: 'personal-machine', workspaceId: 'project-a' }],
+ ...(admitted === undefined ? {} : { codeAttachmentEpoch: admitted }),
+ };
+ req.body = {
+ conversationId: 'resolved-convo',
+ codeWorkspaces: [{ environmentId: 'personal-machine', workspaceId: 'project-a' }],
+ };
+ mockGetEndpointsConfig.mockResolvedValue(createEndpointsConfig(capabilities));
+ req.config.endpoints[EModelEndpoint.agents].statefulCodeSessions = {
+ environments: [attachedEnvironment()],
+ };
+ mockCreateLaneGitRecorder.mockClear();
+
+ await loadToolsForExecution({
+ req,
+ res: {},
+ agent: {
+ id: 'attached-agent',
+ tools: [Tools.execute_code],
+ stateful_code_sessions: true,
+ stateful_code_environment: 'agent-user',
+ code_environment_id: 'personal-machine',
+ },
+ conversationId: 'resolved-convo',
+ toolNames: [AgentConstants.BASH_TOOL],
+ toolRegistry: new Map([[AgentConstants.BASH_TOOL, { name: AgentConstants.BASH_TOOL }]]),
+ actionsEnabled: false,
+ });
+
+ expect(mockCreateLaneGitRecorder.mock.calls[0][0].admittedEpoch).toBe(expected);
+ },
+ );
+
it.each([
['unset', undefined],
['disabled', { enabled: false }],
diff --git a/client/src/components/Chat/PullRequest/Chip.tsx b/client/src/components/Chat/PullRequest/Chip.tsx
index 18c3bde4c1..fbd5763748 100644
--- a/client/src/components/Chat/PullRequest/Chip.tsx
+++ b/client/src/components/Chat/PullRequest/Chip.tsx
@@ -5,31 +5,10 @@ import { useAgentsMapContext, useChatContext } from '~/Providers';
import { TONE_DOT_CLASS, presentPullRequest } from './status';
import { URLIcon } from '~/components/Endpoints/URLIcon';
import { summarizePullRequest } from './summary';
+import PullRequestPanel from './Panel';
import { useLocalize } from '~/hooks';
import PullRequestIcon from './Icon';
-import PullRequestCard from './Card';
-import { cn } from '~/utils';
-
-/** Slides in from the chip's side, left to right, and fades; reduced motion only fades. */
-const cardClass = cn(
- 'border-border-light bg-surface-secondary text-text-primary z-[200] w-80 max-w-[calc(100vw-2rem)] rounded-xl border shadow-lg focus:outline-none',
- 'origin-left -translate-x-3 opacity-0 transition duration-200 ease-out',
- 'data-[enter]:translate-x-0 data-[enter]:opacity-100',
- 'data-[leave]:-translate-x-3 data-[leave]:opacity-0',
- 'motion-reduce:translate-x-0 motion-reduce:transition-opacity',
-);
-
-function CiDot({ dotClass }: { dotClass: string }) {
- return (
-
- );
-}
+import CiDot from './CiDot';
/** The agent's picture with the CI dot on its corner. */
function AgentAvatar({
@@ -72,7 +51,6 @@ function PullRequestChip({ conversationId }: { conversationId: string }) {
hideTimeout: 150,
});
const open = Ariakit.useStoreState(hovercard, 'open');
- const cardElement = Ariakit.useStoreState(hovercard, 'contentElement');
const { data, isError, refetch } = useConversationPullRequestQuery(conversationId);
const pullRequest = data?.pullRequest;
@@ -108,21 +86,12 @@ function PullRequestChip({ conversationId }: { conversationId: string }) {
}
/>
-
- void refetch()}
- portalElement={cardElement}
- />
-
+ void refetch()}
+ />
);
}
diff --git a/client/src/components/Chat/PullRequest/CiDot.tsx b/client/src/components/Chat/PullRequest/CiDot.tsx
new file mode 100644
index 0000000000..0e1e522c37
--- /dev/null
+++ b/client/src/components/Chat/PullRequest/CiDot.tsx
@@ -0,0 +1,25 @@
+import { cn } from '~/utils';
+
+/**
+ * The CI status dot that sits on the corner of the picture or icon it describes. The ring is
+ * painted in the surface the dot sits on, so the caller names that surface.
+ */
+export default function CiDot({
+ dotClass,
+ ringClassName = 'ring-presentation',
+}: {
+ dotClass: string;
+ ringClassName?: string;
+}) {
+ return (
+
+ );
+}
diff --git a/client/src/components/Chat/PullRequest/Panel.tsx b/client/src/components/Chat/PullRequest/Panel.tsx
new file mode 100644
index 0000000000..b9881e9407
--- /dev/null
+++ b/client/src/components/Chat/PullRequest/Panel.tsx
@@ -0,0 +1,58 @@
+import * as Ariakit from '@ariakit/react';
+import type { TConversationPullRequest } from 'librechat-data-provider';
+import { useLocalize } from '~/hooks';
+import PullRequestCard from './Card';
+import { cn } from '~/utils';
+
+/** Slides in from the anchor's side, left to right, and fades; reduced motion only fades. */
+export const panelClass = cn(
+ 'border-border-light bg-surface-secondary text-text-primary z-[200] w-80 max-w-[calc(100vw-2rem)] rounded-xl border shadow-lg focus:outline-none',
+ 'origin-left -translate-x-3 opacity-0 transition duration-200 ease-out',
+ 'data-[enter]:translate-x-0 data-[enter]:opacity-100',
+ 'data-[leave]:-translate-x-3 data-[leave]:opacity-0',
+ 'motion-reduce:translate-x-0 motion-reduce:transition-opacity',
+);
+
+/**
+ * The card as a hovercard beside its anchor. It is portaled, and a portal's events still bubble
+ * to the React tree that rendered it, so anything that sits inside a clickable row stops them
+ * here: a click on the card must not open the row it hangs from.
+ */
+export default function PullRequestPanel({
+ store,
+ pullRequest,
+ refreshFailed,
+ onRetry,
+}: {
+ store: Ariakit.HovercardStore;
+ pullRequest: TConversationPullRequest;
+ refreshFailed: boolean;
+ onRetry: () => void;
+}) {
+ const localize = useLocalize();
+ const panelElement = Ariakit.useStoreState(store, 'contentElement');
+ const stop = (event: { stopPropagation: () => void }) => event.stopPropagation();
+
+ return (
+
+
+
+ );
+}
diff --git a/client/src/components/Chat/PullRequest/RowMark.tsx b/client/src/components/Chat/PullRequest/RowMark.tsx
new file mode 100644
index 0000000000..918b11746b
--- /dev/null
+++ b/client/src/components/Chat/PullRequest/RowMark.tsx
@@ -0,0 +1,150 @@
+import { memo, useEffect } from 'react';
+import * as Ariakit from '@ariakit/react';
+import { Button } from '@librechat/client';
+import { TriangleAlert } from 'lucide-react';
+import type React from 'react';
+import { useRowPullRequestQuery } from '~/data-provider/PullRequest';
+import { TONE_DOT_CLASS, presentPullRequest } from './status';
+import PullRequestPanel, { panelClass } from './Panel';
+import { summarizePullRequest } from './summary';
+import { useLocalize } from '~/hooks';
+import PullRequestIcon from './Icon';
+import { cn } from '~/utils';
+import CiDot from './CiDot';
+
+/** The row's own surface at each state, so the dot's ring blends into it. */
+const RING_SELECTED = 'ring-surface-nav-selected';
+const RING_IDLE = 'ring-surface-primary-alt group-hover:ring-surface-nav-hover';
+
+/**
+ * The pull request a conversation opened, as a mark in its sidebar row: the state icon with the
+ * CI dot on its corner. It renders nothing until a pull request is known, so a row without one
+ * is exactly what it was. The row's title stays the conversation's own title; this only adds
+ * the icon. The mark is a button beside the row's own, so Tab reaches it: focusing it opens the
+ * card, which holds the GitHub link, and activating it must not also open the row.
+ */
+function PullRequestRowMark({
+ conversationId,
+ labelId,
+ selected,
+ onDescribed,
+}: {
+ conversationId: string;
+ /** The id the row lists in `aria-describedby`, so a screen reader hears what the colors say. */
+ labelId: string;
+ selected: boolean;
+ /** Tells the row whether `labelId` is in the page, so it never points at text that is not. */
+ onDescribed?: (described: boolean) => void;
+}) {
+ const localize = useLocalize();
+ const store = Ariakit.useHovercardStore({
+ placement: 'right-start',
+ showTimeout: 100,
+ hideTimeout: 150,
+ });
+ const open = Ariakit.useStoreState(store, 'open');
+ const { data, isError, refetch } = useRowPullRequestQuery(conversationId);
+ const pullRequest = data?.pullRequest;
+ const described = pullRequest != null || isError;
+
+ useEffect(() => {
+ onDescribed?.(described);
+ return () => onDescribed?.(false);
+ }, [described, onDescribed]);
+
+ /* A first lookup that failed is not the same as a chat with no pull request: say so, and
+ offer a retry, instead of leaving the row looking like there is nothing to find. */
+ if (pullRequest == null && isError) {
+ const failed = localize('com_ui_pr_load_failed');
+ return (
+
+ }
+ aria-label={failed}
+ aria-expanded={open}
+ data-testid="convo-pull-request-failed"
+ onFocus={() => store.show()}
+ onClick={(event: React.MouseEvent) => {
+ event.stopPropagation();
+ store.show();
+ }}
+ onKeyDown={(event: React.KeyboardEvent) => {
+ if (event.key === 'Enter' || event.key === ' ') event.stopPropagation();
+ }}
+ className="focus-visible:ring-text-primary text-status-warning relative mr-1 flex size-4 shrink-0 items-center justify-center rounded-sm outline-hidden focus-visible:ring-2"
+ >
+
+
+
+ {failed}
+
+ event.stopPropagation()}
+ onDoubleClick={(event) => event.stopPropagation()}
+ onContextMenu={(event) => event.stopPropagation()}
+ onKeyDown={(event) => event.stopPropagation()}
+ >
+