mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-20 23:13:35 +00:00
🔀 feat: Show the Conversation Pull Request in the Sidebar List (#16815)
* 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
This commit is contained in:
parent
cdf2e94dcf
commit
caeb786e97
47 changed files with 4260 additions and 128 deletions
|
|
@ -171,6 +171,8 @@ export const backgroundTasksCancel = (conversationId: string) =>
|
|||
export const conversationPullRequest = (conversationId: string) =>
|
||||
`${conversationsRoot}/${encodeURIComponent(conversationId)}/pull-request`;
|
||||
|
||||
export const conversationPullRequests = () => `${conversationsRoot}/pull-requests`;
|
||||
|
||||
export const genTitle = (conversationId: string) =>
|
||||
`${conversationsRoot}/gen_title/${encodeURIComponent(conversationId)}`;
|
||||
|
||||
|
|
|
|||
|
|
@ -1132,9 +1132,12 @@ describe('agent pull request config', () => {
|
|||
lookupTimeoutSeconds: 30,
|
||||
maxCheckRunPages: 10,
|
||||
maxCandidatePullRequests: 10,
|
||||
maxCandidatePages: 1,
|
||||
maxHeadComparisons: 3,
|
||||
cacheMaxEntries: 500,
|
||||
cacheMaxCredentials: 256,
|
||||
maxConcurrentLookups: 4,
|
||||
batchTimeoutSeconds: 20,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1185,6 +1188,8 @@ describe('agent pull request config', () => {
|
|||
['maxCheckRunPages', 1.5],
|
||||
['maxCandidatePullRequests', 0],
|
||||
['maxCandidatePullRequests', 101],
|
||||
['maxCandidatePages', 0],
|
||||
['maxCandidatePages', 11],
|
||||
['maxHeadComparisons', -1],
|
||||
['maxHeadComparisons', 21],
|
||||
['maxHeadComparisons', 1.5],
|
||||
|
|
@ -1194,6 +1199,12 @@ describe('agent pull request config', () => {
|
|||
['cacheMaxCredentials', 0],
|
||||
['cacheMaxCredentials', 10_001],
|
||||
['cacheMaxCredentials', 1.5],
|
||||
['maxConcurrentLookups', 0],
|
||||
['maxConcurrentLookups', 17],
|
||||
['maxConcurrentLookups', 1.5],
|
||||
['batchTimeoutSeconds', 0],
|
||||
['batchTimeoutSeconds', 121],
|
||||
['batchTimeoutSeconds', 1.5],
|
||||
])('rejects %s of %s', (field, value) => {
|
||||
expect(parse({ [field]: value }).success).toBe(false);
|
||||
});
|
||||
|
|
@ -1205,8 +1216,11 @@ describe('agent pull request config', () => {
|
|||
lookupTimeoutSeconds: 120,
|
||||
maxCheckRunPages: 50,
|
||||
maxCandidatePullRequests: 100,
|
||||
maxCandidatePages: 10,
|
||||
maxHeadComparisons: 20,
|
||||
cacheMaxEntries: 100_000,
|
||||
maxConcurrentLookups: 16,
|
||||
batchTimeoutSeconds: 120,
|
||||
}).success,
|
||||
).toBe(true);
|
||||
expect(parse({ maxHeadComparisons: 0 }).success).toBe(true);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,10 @@ import { ComponentTypes, SettingTypes, OptionTypes } from './generate';
|
|||
import { STATEFUL_CODE_ENVIRONMENTS } from './stateful-code';
|
||||
import { specsConfigSchema, TSpecsConfig } from './models';
|
||||
import { fileConfigSchema } from './file-config';
|
||||
import {
|
||||
PULL_REQUEST_BATCH_VERSION,
|
||||
PULL_REQUEST_BATCH_TIMEOUT_MAX_SECONDS,
|
||||
} from './types/pullRequest';
|
||||
import { isActionTool } from './types/tools';
|
||||
import { apiBaseUrl } from './api-endpoints';
|
||||
import { FileSources } from './types/files';
|
||||
|
|
@ -1876,6 +1880,17 @@ export const agentsEndpointSchema = baseEndpointSchema
|
|||
* Deployment-wide: when principals configure different values, the largest applies.
|
||||
* Raise it when many tenants each configure their own token. */
|
||||
cacheMaxCredentials: z.number().int().min(1).max(10_000).optional().default(256),
|
||||
/** Pull request lookups a single sidebar request runs at once. Each lookup is a few
|
||||
* GitHub requests, so this bounds how hard one request leans on the token. */
|
||||
maxConcurrentLookups: z.number().int().min(1).max(16).optional().default(4),
|
||||
/** Seconds one sidebar request may stay open in total, whatever its lookups are doing. */
|
||||
batchTimeoutSeconds: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(PULL_REQUEST_BATCH_TIMEOUT_MAX_SECONDS)
|
||||
.optional()
|
||||
.default(20),
|
||||
/** Longest one GitHub request may take. Raise it behind a slow proxy. */
|
||||
requestTimeoutSeconds: z.number().int().min(1).max(60).optional().default(10),
|
||||
/** Longest a whole lookup, every request together, may hold the header request. */
|
||||
|
|
@ -1885,6 +1900,9 @@ export const agentsEndpointSchema = baseEndpointSchema
|
|||
/** Pull requests listed per state when matching a branch's history to the commit a chat
|
||||
* last ran at. Raise it for branch names that are reused many times. */
|
||||
maxCandidatePullRequests: z.number().int().min(1).max(100).optional().default(10),
|
||||
/** Pages of those candidates read per state, so a branch name reused more often than one
|
||||
* page holds can still reach an older match. Each page is one request. */
|
||||
maxCandidatePages: z.number().int().min(1).max(10).optional().default(1),
|
||||
/** Candidates compared with that commit before the search gives up. Each is one request. */
|
||||
maxHeadComparisons: z.number().int().min(0).max(20).optional().default(3),
|
||||
})
|
||||
|
|
@ -3140,6 +3158,11 @@ export type TStartupConfig = {
|
|||
insightsEnabled?: boolean;
|
||||
/** `endpoints.agents.pullRequests.enabled`; the header does not ask for a pull request without it. */
|
||||
pullRequestsEnabled?: boolean;
|
||||
/** Present with `pullRequestsEnabled` once this server has the batch route the sidebar uses. */
|
||||
pullRequestsBatchVersion?: typeof PULL_REQUEST_BATCH_VERSION;
|
||||
/** `endpoints.agents.pullRequests.maxConcurrentLookups`, so the single-route fallback of an
|
||||
* upgrade in progress keeps to the limit the operator configured. */
|
||||
pullRequestsMaxConcurrentLookups?: number;
|
||||
/** Manual context compaction, gated by the same `summarization.enabled`
|
||||
* switch that governs the automatic detour. */
|
||||
compactionEnabled?: boolean;
|
||||
|
|
|
|||
|
|
@ -1229,8 +1229,16 @@ export function cancelBackgroundTasks(
|
|||
|
||||
export function getConversationPullRequest(
|
||||
conversationId: string,
|
||||
options?: { signal?: AbortSignal },
|
||||
): Promise<t.TConversationPullRequestResponse> {
|
||||
return request.get(endpoints.conversationPullRequest(conversationId));
|
||||
return request.get(endpoints.conversationPullRequest(conversationId), options);
|
||||
}
|
||||
|
||||
export function getConversationPullRequests(
|
||||
conversationIds: string[],
|
||||
options?: { signal?: AbortSignal },
|
||||
): Promise<t.TConversationPullRequestsResponse> {
|
||||
return request.post(endpoints.conversationPullRequests(), { conversationIds }, options);
|
||||
}
|
||||
|
||||
export function getPrompt(id: string): Promise<{ prompt: t.TPrompt }> {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ async function _getResponse<T = unknown>(
|
|||
return await axios.get<T>(url, { ...options });
|
||||
}
|
||||
|
||||
async function _post(url: string, data?: any) {
|
||||
async function _post(url: string, data?: any, options?: AxiosRequestConfig) {
|
||||
const response = await axios.post(url, JSON.stringify(data), {
|
||||
...options,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
return response.data;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,29 @@ export type TConversationPullRequest = {
|
|||
checks: PullRequestChecks;
|
||||
};
|
||||
|
||||
/** Most conversations one batch lookup may name. It bounds the fan-out to GitHub of a single
|
||||
* request; the lookups themselves stay governed by the configured limits and cache. */
|
||||
export const PULL_REQUEST_BATCH_MAX = 50;
|
||||
|
||||
/** Version of the batch lookup route. The server advertises it with `pullRequestsEnabled`, and a
|
||||
* client that lists conversations asks for batches only when it matches, so during a rolling
|
||||
* upgrade it never sends a batch to a replica that does not have the route yet. */
|
||||
export const PULL_REQUEST_BATCH_VERSION = 1 as const;
|
||||
|
||||
/** The most a deployment may set `batchTimeoutSeconds` to. The server answers by its own deadline,
|
||||
* so a client that waits just past this never gives up before the server does. */
|
||||
export const PULL_REQUEST_BATCH_TIMEOUT_MAX_SECONDS = 120;
|
||||
|
||||
export type TConversationPullRequestsRequest = { conversationIds: string[] };
|
||||
|
||||
/** One conversation's answer: its pull request (null when it has none), or a stable failure code. */
|
||||
export type TConversationPullRequestsEntry =
|
||||
| { conversationId: string; pullRequest: TConversationPullRequest | null }
|
||||
| { conversationId: string; error: { code: string } };
|
||||
|
||||
/** An array rather than an object keyed by id, so no client-supplied id is ever a property name. */
|
||||
export type TConversationPullRequestsResponse = { results: TConversationPullRequestsEntry[] };
|
||||
|
||||
/** `pullRequest` is null when the conversation has no pull request, which is not an error. */
|
||||
export type TConversationPullRequestResponse = {
|
||||
pullRequest: TConversationPullRequest | null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue