Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b48552c
feat(seer): Seer SCM Overview
ryan953 Mar 23, 2026
6a77ba3
review comment
ryan953 Mar 23, 2026
c6c4a94
Merge branch 'master' into ryan953/seer-scm-overview
ryan953 Mar 23, 2026
42d1203
iterate on loading state
ryan953 Mar 23, 2026
353911c
split component to make stories better
ryan953 Mar 24, 2026
8d0c066
squash
ryan953 Mar 20, 2026
0b7c980
split it up[
ryan953 Mar 22, 2026
06df154
Iterate!
ryan953 Mar 24, 2026
5d35c75
Iterate some more
ryan953 Mar 25, 2026
70f8adb
add autofix section stories
ryan953 Mar 25, 2026
ceff1b5
rm unused helpers
ryan953 Mar 25, 2026
d0034ef
tweak styles
ryan953 Mar 25, 2026
b9592a6
show Connect Projects and Repos button
ryan953 Mar 25, 2026
605aa60
Merge branch 'master' into ryan953/seer-overview
ryan953 Mar 25, 2026
38eecc4
Merge branch 'master' into ryan953/seer-overview
ryan953 Mar 26, 2026
45b0e63
iterate
ryan953 Mar 27, 2026
133b65d
iterate - w/ fancy radios
ryan953 Mar 30, 2026
1f98574
fix create pr counts
ryan953 Mar 30, 2026
6fd63ff
Merge branch 'master' into ryan953/seer-overview
ryan953 Mar 30, 2026
defedcb
fix test
ryan953 Mar 30, 2026
d840e5f
add bulk-edit of ser agent name
ryan953 Mar 30, 2026
743781b
add bulk-edit of seer create-pr field
ryan953 Mar 30, 2026
d6a7389
add busy state to the bulk edit buttons
ryan953 Mar 30, 2026
bb791b3
catch 429s and throw an error to the user. This happens because we ar…
ryan953 Mar 30, 2026
54fa762
rm connectedrepo and stopping point forms for now
ryan953 Mar 31, 2026
0785ab7
do chunking to avoid 429s a bit more
ryan953 Mar 31, 2026
0aa772b
disable buttons while requests are in-flight
ryan953 Mar 31, 2026
d5b4714
add tests for processInChunks
ryan953 Mar 31, 2026
f393df4
rm defaultAutomatedRunStoppingPoint field for now
ryan953 Mar 31, 2026
657bb6c
rm extra changes
ryan953 Mar 31, 2026
0d1fe15
fix issue while loading: shouldnt fallback to comparing to seer
ryan953 Mar 31, 2026
6b9ff53
handle case when were loading agent options
ryan953 Mar 31, 2026
c1c2cc1
mv organizationIntegrationsQueryOptions
ryan953 Mar 31, 2026
08249dd
Merge branch 'master' into ryan953/seer-overview
ryan953 Mar 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {useEffect, useMemo} from 'react';

import {organizationRepositoriesInfiniteOptions} from 'sentry/components/events/autofix/preferences/hooks/useOrganizationRepositories';
import {organizationConfigIntegrationsQueryOptions} from 'sentry/components/repositories/scmIntegrationTree/organizationConfigIntegrationsQueryOptions';
import {organizationIntegrationsQueryOptions} from 'sentry/endpoints/organizations/organizationsIntegrationsQueryOptions';
import type {
IntegrationProvider,
IntegrationRepository,
Expand All @@ -12,6 +11,7 @@ import type {
import {apiOptions} from 'sentry/utils/api/apiOptions';
import {useInfiniteQuery, useQueries, useQuery} from 'sentry/utils/queryClient';
import {useOrganization} from 'sentry/utils/useOrganization';
import {organizationIntegrationsQueryOptions} from 'sentry/views/settings/seer/overview/utils/organizationIntegrationsQueryOptions';

type ScmIntegrationTreeData = {
connectedIdentifiers: Set<string>;
Expand Down
4 changes: 2 additions & 2 deletions static/app/types/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export interface Organization extends OrganizationSummary {
dataScrubberDefaults: boolean;
debugFilesRole: string;
defaultCodeReviewTriggers: CodeReviewTrigger[];
defaultCodingAgent: string | null | undefined;
defaultCodingAgentIntegrationId: number | null | undefined;
defaultCodingAgent: string | null;
defaultCodingAgentIntegrationId: string | number | null;
defaultRole: string;
enhancedPrivacy: boolean;
eventsMemberAdmin: boolean;
Expand Down
108 changes: 108 additions & 0 deletions static/app/utils/array/procesInChunks.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import {processInChunks} from 'sentry/utils/array/procesInChunks';

describe('processInChunks', () => {
it('returns an empty array for empty input', async () => {
const fn = jest.fn().mockResolvedValue('x');
const results = await processInChunks({items: [], chunkSize: 3, fn});
expect(results).toEqual([]);
expect(fn).not.toHaveBeenCalled();
});

it('processes all items when count is less than chunkSize', async () => {
const fn = jest.fn((x: number) => Promise.resolve(x * 2));
const results = await processInChunks({items: [1, 2], chunkSize: 5, fn});
expect(results).toEqual([
{status: 'fulfilled', value: 2},
{status: 'fulfilled', value: 4},
]);
});

it('processes all items when count equals chunkSize exactly', async () => {
const fn = jest.fn((x: number) => Promise.resolve(x * 2));
const results = await processInChunks({items: [1, 2, 3], chunkSize: 3, fn});
expect(results).toHaveLength(3);
expect(results.every(r => r.status === 'fulfilled')).toBe(true);
});

it('processes all items across multiple chunks', async () => {
const fn = jest.fn((x: number) => Promise.resolve(x));
const results = await processInChunks({
items: [1, 2, 3, 4, 5],
chunkSize: 2,
fn,
});
expect(results).toHaveLength(5);
expect(fn).toHaveBeenCalledTimes(5);
expect(results.map(r => (r.status === 'fulfilled' ? r.value : null))).toEqual([
1, 2, 3, 4, 5,
]);
});

it('preserves result order matching input order', async () => {
// Simulate varying async latency: later items resolve faster
const fn = jest.fn(
(x: number) =>
new Promise<number>(resolve => setTimeout(() => resolve(x), (10 - x) * 10))
);
const results = await processInChunks({items: [1, 2, 3, 4, 5], chunkSize: 5, fn});
expect(results.map(r => (r.status === 'fulfilled' ? r.value : null))).toEqual([
1, 2, 3, 4, 5,
]);
});

it('processes chunks sequentially, not all at once', async () => {
const callOrder: number[] = [];
const fn = jest.fn((x: number) => {
callOrder.push(x);
return Promise.resolve(x);
});

await processInChunks({items: [1, 2, 3, 4, 5, 6], chunkSize: 2, fn});

// Each chunk of 2 must start only after the previous chunk completes.
// Because fn is synchronous here, within each chunk the call order is
// preserved and chunks are processed sequentially.
expect(callOrder).toEqual([1, 2, 3, 4, 5, 6]);
});

it('marks rejected items as rejected without stopping other items', async () => {
const fn = jest.fn((x: number) =>
x === 3 ? Promise.reject(new Error('boom')) : Promise.resolve(x)
);
const results = await processInChunks({items: [1, 2, 3, 4, 5], chunkSize: 5, fn});
expect(results).toHaveLength(5);
expect(results[0]).toEqual({status: 'fulfilled', value: 1});
expect(results[1]).toEqual({status: 'fulfilled', value: 2});
expect(results[2]).toMatchObject({status: 'rejected', reason: expect.any(Error)});
expect(results[3]).toEqual({status: 'fulfilled', value: 4});
expect(results[4]).toEqual({status: 'fulfilled', value: 5});
});

it('continues processing later chunks when an earlier chunk has failures', async () => {
const fn = jest.fn((x: number) =>
x === 1 ? Promise.reject(new Error('first chunk error')) : Promise.resolve(x)
);
// chunk 1: [1] (fails), chunk 2: [2, 3] (succeeds)
const results = await processInChunks({items: [1, 2, 3], chunkSize: 1, fn});
expect(results).toHaveLength(3);
expect(results[0]).toMatchObject({status: 'rejected'});
expect(results[1]).toEqual({status: 'fulfilled', value: 2});
expect(results[2]).toEqual({status: 'fulfilled', value: 3});
});

it('handles chunkSize of 1 by processing items one at a time', async () => {
const fn = jest.fn((x: number) => Promise.resolve(x));
const results = await processInChunks({items: [10, 20, 30], chunkSize: 1, fn});
expect(results).toHaveLength(3);
expect(results.map(r => (r.status === 'fulfilled' ? r.value : null))).toEqual([
10, 20, 30,
]);
});

it('handles chunkSize larger than item count', async () => {
const fn = jest.fn((x: number) => Promise.resolve(x));
const results = await processInChunks({items: [1, 2], chunkSize: 100, fn});
expect(results).toHaveLength(2);
expect(fn).toHaveBeenCalledTimes(2);
});
});
19 changes: 19 additions & 0 deletions static/app/utils/array/procesInChunks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
interface Props<Item, Result> {
chunkSize: number;
fn: (item: Item) => Promise<Result>;
items: Item[];
}

export async function processInChunks<Item, Result>({
items,
chunkSize,
fn,
}: Props<Item, Result>): Promise<Array<PromiseSettledResult<Result>>> {
const results: Array<PromiseSettledResult<Result>> = [];
for (let i = 0; i < items.length; i += chunkSize) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero chunk size causes endless loop

Low Severity

processInChunks does not validate chunkSize. With chunkSize <= 0, for (let i = 0; i &lt; items.length; i += chunkSize) never advances correctly, so the function can loop forever and hang the caller.

Fix in Cursor Fix in Web

const chunk = items.slice(i, i + chunkSize);
const chunkResults = await Promise.allSettled(chunk.map(fn));
results.push(...chunkResults);
}
return results;
}
Loading
Loading