GeezerVison is showing github.com — fix(server): recover side-chat fork history from its parent by ScottN-PV · Pull Request #28849 · pingdotgg/t3code
fix(server): recover side-chat fork history from its parent
#28849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.ts
(3)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
fix(server): recover side-chat fork history from its parent
Loading branch information
Uh oh!
There was an error while loading. Please reload this page.
commit 633a0b6ed78e76a5715302c3421c6fdf66df26e1
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -69,6 +69,8 @@ export interface ContextHandoffServiceV2Shape {
}) => Effect.Effect<OrchestrationV2ContextHandoff, ContextHandoffServiceV2Error>;
readonly prepareProviderHandoff: (input: {
readonly threadId: ThreadId;
/** Source history may live outside the thread that owns this handoff. */
readonly historyThreadId?: ThreadId | undefined;
readonly targetRunId: RunId;
readonly transferId: OrchestrationV2ContextHandoff["transferId"];
readonly fromProviderThreadIds: ReadonlyArray<ProviderThreadId>;
Expand Down
Expand Up
@@ -485,6 +487,7 @@ const makeContextHandoffService = Effect.fn("orchestrationV2.ContextHandoffServi
"orchestrationV2.contextHandoff.prepareProviderHandoff",
)(function* (input: {
readonly threadId: ThreadId;
readonly historyThreadId?: ThreadId | undefined;
readonly targetRunId: RunId;
readonly transferId: OrchestrationV2ContextHandoff["transferId"];
readonly fromProviderThreadIds: ReadonlyArray<ProviderThreadId>;
Expand Down
Expand Up
@@ -519,7 +522,10 @@ const makeContextHandoffService = Effect.fn("orchestrationV2.ContextHandoffServi
),
);
const runStatuses = new Map(input.runs?.map((run) => [run.id, run.status]));
const coverage = handoffCoverage(input);
const coverage = handoffCoverage({
...input,
threadId: input.historyThreadId ?? input.threadId,
});
const selected = selectHistory({
messages: input.items.flatMap((item) => {
const message = historicalMessage(item);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -6673,6 +6673,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
: yield* contextHandoffService
.prepareProviderHandoff({
threadId: command.threadId,
historyThreadId: sideChatFork ? sourceProjection.thread.id : undefined,
targetRunId: runId,
transferId: pendingForkTransfer.id,
fromProviderThreadIds:
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -923,6 +923,58 @@ it.effect("resolves an explicit checkpoint fork to its source run", () =>
}).pipe(Effect.provide(forkCases[0]!.layer)),
);
it.effect.each([true, false])(
"portable fork recovery uses the readable history thread (sideChat=%s)",
(sideChat) =>
Effect.gen(function* () {
const orchestrator = yield* Orchestrator.OrchestratorV2;
const parentId = ThreadId.make("recovery-parent");
const childId = ThreadId.make("recovery-child");
yield* createParent(parentId);
yield* writeParentRun({
threadId: parentId,
runId: RunId.make("recovery-stable-run"),
ordinal: 1,
status: "completed",
text: "Earlier parent history",
stable: true,
});
yield* writeParentRun({
threadId: parentId,
runId: RunId.make("recovery-busy-run"),
ordinal: 2,
status: "running",
text: "Parent work in progress",
});
yield* orchestrator.dispatch({
type: "thread.fork",
commandId: CommandId.make("recovery-fork"),
sourceThreadId: parentId,
targetThreadId: childId,
sourcePoint: { type: "latest_stable" },
sideChat,
createdBy: "user",
creationSource: "web",
});
yield* askSideChat(childId, "recovery-first-message");
const child = yield* orchestrator.getThreadProjection(childId);
const handoff = child.contextHandoffs.find((item) => item.strategy === "full_thread_summary");
assert.isDefined(handoff);
assert.equal(child.contextTransfers[0]?.resolution?.strategy, "portable_context");
assert.equal(handoff!.threadId, childId);
assert.equal(handoff!.targetRunId, child.runs[0]?.id);
const historyThreadId = sideChat ? parentId : childId;
assert.include(
handoff!.history?.coverage ?? "",
`t3_thread_read({threadId:"${historyThreadId}"`,
);
if (sideChat) {
assert.notInclude(handoff!.history?.coverage ?? "", `threadId:"${childId}"`);
}
}).pipe(Effect.provide(forkCases[0]!.layer)),
);
it.effect("a side chat of an idle parent still starts with the framing note", () =>
Effect.gen(function* () {
const orchestrator = yield* Orchestrator.OrchestratorV2;
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.