GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge branch 'main' into feat/sidebar-thread-ports · pingdotgg/t3code@b8fad1e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps
    • server/src
      • orchestration-v2
        • ProjectionStore.ts
      • project
        • ProjectEnrichmentService.ts
    • web/src/components/pullRequest
      • PullRequestCodeTab.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration-v2/ProjectionStore.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/ProjectionStore.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,9 +4098,10 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
40984098
AND EXISTS (
40994099
SELECT 1 FROM orchestration_v2_projection_nodes AS node
41004100
WHERE node.thread_id = subagents.child_thread_id
4101-
AND node.run_id IS NULL
4101+
-- Matches nodes_live_idx; +run_id keeps thread_run_idx from scanning settled nodes.
4102+
AND node.status IN ('pending', 'starting', 'running', 'waiting')
4103+
AND +node.run_id IS NULL
41024104
AND node.kind = 'root_turn'
4103-
AND node.status IN ('pending', 'running', 'waiting')
41044105
)
41054106
UNION
41064107
-- No native subagent outlives the provider process that ran it.
Collapse file

‎apps/server/src/project/ProjectEnrichmentService.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/project/ProjectEnrichmentService.ts
+52-48Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -210,63 +210,67 @@ export const make = Effect.fn("ProjectEnrichmentService.make")(function* (
210210
{ concurrency: "unbounded", discard: true },
211211
);
212212

213-
const requestLane = Effect.fn("ProjectEnrichmentService.requestLane")(function* (
213+
// Every project read lands here; only an actual enqueue gets a span, the resolve workers trace the work.
214+
const requestLane = Effect.fnUntraced(function* (
214215
lane: EnrichmentWorkLane,
215216
workspaceRoot: string,
216217
field: "repositoryIdentity" | "faviconPath",
217218
) {
218219
if (!(yield* reservePending(lane, workspaceRoot))) return;
219-
if (!(yield* Queue.offer(lane.queue, workspaceRoot))) {
220-
yield* removePending(lane, workspaceRoot);
221-
yield* Effect.logWarning("Project metadata enrichment queue is full", {
222-
workspaceRoot,
223-
field,
224-
});
225-
}
220+
yield* Effect.gen(function* () {
221+
if (!(yield* Queue.offer(lane.queue, workspaceRoot))) {
222+
yield* removePending(lane, workspaceRoot);
223+
yield* Effect.logWarning("Project metadata enrichment queue is full", {
224+
workspaceRoot,
225+
field,
226+
});
227+
}
228+
}).pipe(Effect.withSpan("ProjectEnrichmentService.requestLane"));
226229
});
227230

228-
const peek: ProjectEnrichmentService["Service"]["peek"] = Effect.fn(
229-
"ProjectEnrichmentService.peek",
230-
)(function* (workspaceRoot) {
231-
const [repositoryIdentity, faviconPath] = yield* Effect.all(
232-
[
233-
Cache.getSuccess(repositoryIdentityCache, workspaceRoot),
234-
Cache.getSuccess(faviconCache, workspaceRoot),
235-
] as const,
236-
{ concurrency: "unbounded" },
237-
);
238-
return {
239-
repositoryIdentity: availableValue(repositoryIdentity),
240-
faviconPath: availableValue(faviconPath),
241-
repositoryIdentityResolved: isSuccessfullyResolved(repositoryIdentity),
242-
};
243-
});
231+
// peek/request/getAvailable run per project on every shell read, inside the caller's span; own spans were ~0ms noise.
232+
const peek: ProjectEnrichmentService["Service"]["peek"] = Effect.fnUntraced(
233+
function* (workspaceRoot) {
234+
const [repositoryIdentity, faviconPath] = yield* Effect.all(
235+
[
236+
Cache.getSuccess(repositoryIdentityCache, workspaceRoot),
237+
Cache.getSuccess(faviconCache, workspaceRoot),
238+
] as const,
239+
{ concurrency: "unbounded" },
240+
);
241+
return {
242+
repositoryIdentity: availableValue(repositoryIdentity),
243+
faviconPath: availableValue(faviconPath),
244+
repositoryIdentityResolved: isSuccessfullyResolved(repositoryIdentity),
245+
};
246+
},
247+
);
244248

245-
const request: ProjectEnrichmentService["Service"]["request"] = Effect.fn(
246-
"ProjectEnrichmentService.request",
247-
)(function* (workspaceRoot) {
248-
const [hasRepositoryIdentity, hasFaviconPath] = yield* Effect.all(
249-
[Cache.has(repositoryIdentityCache, workspaceRoot), Cache.has(faviconCache, workspaceRoot)],
250-
{ concurrency: "unbounded" },
251-
);
252-
yield* Effect.all(
253-
[
254-
hasRepositoryIdentity
255-
? Effect.void
256-
: requestLane(repositoryIdentityLane, workspaceRoot, "repositoryIdentity"),
257-
hasFaviconPath ? Effect.void : requestLane(faviconLane, workspaceRoot, "faviconPath"),
258-
],
259-
{ concurrency: "unbounded", discard: true },
260-
);
261-
});
249+
const request: ProjectEnrichmentService["Service"]["request"] = Effect.fnUntraced(
250+
function* (workspaceRoot) {
251+
const [hasRepositoryIdentity, hasFaviconPath] = yield* Effect.all(
252+
[Cache.has(repositoryIdentityCache, workspaceRoot), Cache.has(faviconCache, workspaceRoot)],
253+
{ concurrency: "unbounded" },
254+
);
255+
yield* Effect.all(
256+
[
257+
hasRepositoryIdentity
258+
? Effect.void
259+
: requestLane(repositoryIdentityLane, workspaceRoot, "repositoryIdentity"),
260+
hasFaviconPath ? Effect.void : requestLane(faviconLane, workspaceRoot, "faviconPath"),
261+
],
262+
{ concurrency: "unbounded", discard: true },
263+
);
264+
},
265+
);
262266

263-
const getAvailable: ProjectEnrichmentService["Service"]["getAvailable"] = Effect.fn(
264-
"ProjectEnrichmentService.getAvailable",
265-
)(function* (workspaceRoot) {
266-
const available = yield* peek(workspaceRoot);
267-
yield* request(workspaceRoot);
268-
return available;
269-
});
267+
const getAvailable: ProjectEnrichmentService["Service"]["getAvailable"] = Effect.fnUntraced(
268+
function* (workspaceRoot) {
269+
const available = yield* peek(workspaceRoot);
270+
yield* request(workspaceRoot);
271+
return available;
272+
},
273+
);
270274

271275
const readRepositoryIdentity: ProjectEnrichmentService["Service"]["readRepositoryIdentity"] =
272276
Effect.fn("ProjectEnrichmentService.readRepositoryIdentity")(function* (workspaceRoot) {
Collapse file

‎apps/web/src/components/pullRequest/PullRequestCodeTab.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
+79-37Lines changed: 79 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,76 @@ function parseSlice(slice: DiffSlice, cacheKey: string, ignoreWhitespace: boolea
176176
return parsed;
177177
}
178178

179+
type DiffModel = {
180+
readonly parsedSlices: ReadonlyArray<RenderablePatch | null>;
181+
readonly loadedFiles: ReadonlyArray<Extract<RenderablePatch, { kind: "files" }>["files"][number]>;
182+
readonly sourceFileStats: ReadonlyMap<string, ReturnType<typeof getDiffLineStat>>;
183+
};
184+
const diffModels = new WeakMap<ReadonlyArray<DiffSlice>, Map<string, DiffModel>>();
185+
const patchHashes = new WeakMap<DiffSlice, number>();
186+
187+
// Hashing, ordering and counting every file of a huge pull request costs a second, and the tab
188+
// renders far more often than its slices change, so the model is kept per slice list.
189+
function diffModel(
190+
slices: ReadonlyArray<DiffSlice>,
191+
keyPrefix: string,
192+
ignoreWhitespace: boolean,
193+
): DiffModel {
194+
let models = diffModels.get(slices);
195+
if (models === undefined) diffModels.set(slices, (models = new Map()));
196+
const cached = models.get(keyPrefix);
197+
if (cached !== undefined) return cached;
198+
const parsedSlices = slices.map((slice) => {
199+
let hash = patchHashes.get(slice);
200+
if (hash === undefined) patchHashes.set(slice, (hash = fnv1a32(slice.patch)));
201+
// The cache key carries the theme, which the tokenizer caches against, and the patch's
202+
// hash: a refreshed page reuses its cursor, so position alone would return a stale parse.
203+
return parseSlice(slice, `${keyPrefix}:${slice.cursor ?? "first"}:${hash}`, ignoreWhitespace);
204+
});
205+
const model: DiffModel = {
206+
parsedSlices,
207+
loadedFiles: orderDiffFilesLikeTree(
208+
parsedSlices.flatMap((parsed) =>
209+
parsed?.kind === "files" ? orderDiffFiles(parsed.files) : [],
210+
),
211+
),
212+
sourceFileStats: new Map(
213+
parsedSlices.flatMap((parsed) =>
214+
parsed?.kind === "files"
215+
? parsed.files.map(
216+
(file, index) =>
217+
[
218+
buildFileDiffRenderKey(file),
219+
getDiffLineStat([parsed.sourceFiles[index] ?? file]),
220+
] as const,
221+
)
222+
: [],
223+
),
224+
),
225+
};
226+
models.set(keyPrefix, model);
227+
return model;
228+
}
229+
230+
const threadsByPathCache = new WeakMap<
231+
ReadonlyArray<PullRequestReviewThread>,
232+
ReadonlyMap<string, ReadonlyArray<PullRequestReviewThread>>
233+
>();
234+
235+
function reviewThreadsByPath(threads: ReadonlyArray<PullRequestReviewThread>) {
236+
let byPath = threadsByPathCache.get(threads);
237+
if (byPath === undefined) {
238+
const grouped = new Map<string, PullRequestReviewThread[]>();
239+
for (const thread of threads) {
240+
const list = grouped.get(thread.path);
241+
if (list) list.push(thread);
242+
else grouped.set(thread.path, [thread]);
243+
}
244+
threadsByPathCache.set(threads, (byPath = grouped));
245+
}
246+
return byPath;
247+
}
248+
179249
interface FileViewedToggleState {
180250
readonly enabled: boolean;
181251
readonly isViewed: (path: string) => boolean;
@@ -491,20 +561,10 @@ function PullRequestCodeTab({
491561
// Agent context is local, so it does not require host comment permission.
492562
const canSelectLines =
493563
commit === null && (review.inlineComment || onAddToAgentSelection !== undefined);
494-
// The cache key carries the theme, which is what the tokenizer caches against, so a theme
495-
// change is still a fresh parse. The patch's own hash is part of it too: a refreshed page
496-
// reuses its cursor, and a key of position alone would hand back the parse it replaced.
497-
const parsedSlices = loadedSlices.map((slice) =>
498-
parseSlice(
499-
slice,
500-
`pull-request:${scopeKey}:${resolvedTheme}:${ignoreWhitespace}:${slice.cursor ?? "first"}:${fnv1a32(slice.patch)}`,
501-
ignoreWhitespace,
502-
),
503-
);
504-
const loadedFiles = orderDiffFilesLikeTree(
505-
parsedSlices.flatMap((parsed) =>
506-
parsed?.kind === "files" ? orderDiffFiles(parsed.files) : [],
507-
),
564+
const { parsedSlices, loadedFiles, sourceFileStats } = diffModel(
565+
loadedSlices,
566+
`pull-request:${scopeKey}:${resolvedTheme}:${ignoreWhitespace}`,
567+
ignoreWhitespace,
508568
);
509569
const testFileCount = loadedFiles.filter((file) =>
510570
isTestChangedFile(resolveFileDiffPath(file)),
@@ -523,33 +583,16 @@ function PullRequestCodeTab({
523583
slice.omittedFileStats.map((file) => [file.path, file] as const),
524584
),
525585
);
526-
const sourceFileStats = new Map(
527-
parsedSlices.flatMap((parsed) =>
528-
parsed?.kind === "files"
529-
? parsed.files.map(
530-
(file, index) =>
531-
[
532-
buildFileDiffRenderKey(file),
533-
getDiffLineStat([parsed.sourceFiles[index] ?? file]),
534-
] as const,
535-
)
536-
: [],
537-
),
538-
);
539586
const fileTreeEntries = diffFileTreeEntries(files);
587+
const threadsByPath = reviewThreadsByPath(detail.reviewThreads);
540588
// File membership does not guarantee a rendered hunk for the thread.
541589
const placedThreadIds = (() => {
542590
const placed = new Set<string>();
543591
// Commit diffs use different line coordinates; list conversations separately.
544592
if (commit !== null) return placed;
545593
for (const file of files) {
546-
const path = resolveFileDiffPath(file);
547-
for (const thread of detail.reviewThreads) {
548-
if (
549-
thread.path === path &&
550-
thread.line !== null &&
551-
isLineInFileDiff(file, thread.side, thread.line)
552-
) {
594+
for (const thread of threadsByPath.get(resolveFileDiffPath(file)) ?? []) {
595+
if (thread.line !== null && isLineInFileDiff(file, thread.side, thread.line)) {
553596
placed.add(thread.id);
554597
}
555598
}
@@ -576,9 +619,8 @@ function PullRequestCodeTab({
576619
return created;
577620
};
578621

579-
for (const thread of detail.reviewThreads) {
580-
if (thread.path !== path || thread.line === null) continue;
581-
if (!placedThreadIds.has(thread.id)) continue;
622+
for (const thread of threadsByPath.get(path) ?? []) {
623+
if (thread.line === null || !placedThreadIds.has(thread.id)) continue;
582624
groupAt(thread.side, thread.line).threads.push(thread);
583625
}
584626
if (commit === null) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.