Skip to content

Commit 9252e3d

Browse files
t3dotggclaude
andcommitted
chore(server): format the history window code and shorten one comment
Co-Authored-By: Claude Fable 5.2 <[email protected]>
1 parent e6cc534 commit 9252e3d

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5857,7 +5857,11 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
58575857
attachments: [],
58585858
});
58595859
const notification = () =>
5860-
add("notification", { source: { kind: "system" }, outcome: "completed", summary: "Wake" });
5860+
add("notification", {
5861+
source: { kind: "system" },
5862+
outcome: "completed",
5863+
summary: "Wake",
5864+
});
58615865
const wakes =
58625866
kind === "one row"
58635867
? run % 10 !== 0
@@ -5871,7 +5875,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
58715875
: kind === "stopped"
58725876
? 320 + Math.floor(random() * 60)
58735877
: kind === "folds work"
5874-
? 155 + Math.floor(random() * 60)
5878+
? 155 + Math.floor(random() * 60)
58755879
: kind === "one row"
58765880
? 0
58775881
: Math.floor(random() * 30);
@@ -5881,7 +5885,8 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
58815885
// A reply deep in a stopped run: a page that ends on it has enough work below it
58825886
// to fold, and only the stop request above it says that it does not.
58835887
const reply = kind === "stopped" && row === 200;
5884-
if (reply) repliesInStoppedRuns.push(`turn-item:window-equivalence:${round}:${items.length}`);
5888+
if (reply)
5889+
repliesInStoppedRuns.push(`turn-item:window-equivalence:${round}:${items.length}`);
58855890
if (reply || chance(0.02))
58865891
add("assistant_message", {
58875892
messageId: `message:window-equivalence:${round}:${items.length}`,
@@ -5975,7 +5980,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
59755980
[false, undefined],
59765981
[true, undefined],
59775982
] as const) {
5978-
for (let cursor: string | null = firstCursor; cursor !== null; ) {
5983+
for (let cursor: string | null = firstCursor; cursor !== null;) {
59795984
const page: OrchestrationV2ThreadHistoryPage = yield* windowed(
59805985
history(cursor, undefined, conversationOnly, workMode),
59815986
);
@@ -5995,7 +6000,7 @@ it.layer(layerTest)("ProjectionStoreV2", (it) => {
59956000
}
59966001
foldedGroups += groups.size;
59976002
for (const [anchorId, groupCursor] of groups) {
5998-
for (let cursor: string | null = groupCursor; cursor !== null; )
6003+
for (let cursor: string | null = groupCursor; cursor !== null;)
59996004
cursor = (yield* windowed(history(cursor, anchorId, false, "work"))).nextCursor;
60006005
}
60016006
for (const view of ["messages", "activity"] as const) {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6528,7 +6528,6 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
65286528
item,
65296529
});
65306530

6531-
65326531
/**
65336532
* Reads parts of a thread's own timeline without indexing all of it. Null when callers read
65346533
* the full index instead: the thread shows fork ancestry, so its rows come from other threads,
@@ -6540,7 +6539,9 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
65406539
) {
65416540
// A read that only the full index can answer left it cached, and it answers faster than
65426541
// a window. The key is the one `readSnapshotTimelineIndex` uses.
6543-
const cached = timelineIndexes.get(`${includePersistentOutput ? "work" : "plain"}:${threadId}`);
6542+
const cached = timelineIndexes.get(
6543+
`${includePersistentOutput ? "work" : "plain"}:${threadId}`,
6544+
);
65446545
if (
65456546
cached !== undefined &&
65466547
(yield* latestThreadEventSequence(threadId, cached.index.threadIds)) === cached.sequence
@@ -6733,11 +6734,9 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
67336734
});
67346735

67356736
/**
6736-
* Selects an older history page from the rows near its cursor instead of the whole thread.
6737-
* `select` must give the same page as it does on the full index, so the window grows until
6738-
* the page ends inside rows whose inputs are all known. Null when only the full index can
6739-
* answer: a cursor that names no visible row of this thread. With `workMode` "work" the
6740-
* caller passes the group's first row as `throughEntryId`, and without it passes none.
6737+
* Selects an older history page from the rows near its cursor. The window grows until the
6738+
* page ends inside rows whose inputs are all known, so `select` gives the page it gives on
6739+
* the full index. Null when the cursor names no visible row, which needs the full index.
67416740
*/
67426741
const selectHistoryPageInWindow = Effect.fn("ProjectionStore.selectHistoryPageInWindow")(
67436742
function* <
@@ -7010,8 +7009,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
70107009
).flatMap(({ sourceThreadId, item }) =>
70117010
(workMode === "work" ||
70127011
(item.runId !== null &&
7013-
(item.runStatus === "completed" ||
7014-
item.attemptStatus === "superseded"))) &&
7012+
(item.runStatus === "completed" || item.attemptStatus === "superseded"))) &&
70157013
!scannedRuns.has(`${sourceThreadId}:${item.runId}`)
70167014
? [
70177015
[

0 commit comments

Comments
 (0)