mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
Offer forks on all completed copied replies
This commit is contained in:
@@ -294,6 +294,7 @@ it('offers an inherited OpenCode tip after the child advances and submits its di
|
||||
})
|
||||
await settle()
|
||||
expect(latest?.offerFor(copied)).toBe('reserved')
|
||||
expect(latest?.offerFor(older)).toBe('reserved')
|
||||
expect(latest?.offerFor(own)).toBe('available')
|
||||
await act(async () => {
|
||||
renderer!.update(
|
||||
@@ -303,7 +304,7 @@ it('offers an inherited OpenCode tip after the child advances and submits its di
|
||||
)
|
||||
})
|
||||
expect(latest?.offerFor(copied)).toBe('available')
|
||||
expect(latest?.offerFor(older)).toBe('reserved')
|
||||
expect(latest?.offerFor(older)).toBe('available')
|
||||
await act(async () => {
|
||||
renderer!.update(
|
||||
createElement(ForkProbe, {
|
||||
|
||||
+14
-5
@@ -144,11 +144,14 @@ describe('the side chat fork point the transcript finds while laying out', () =>
|
||||
})
|
||||
})
|
||||
|
||||
it('offers only the copied fork-point tip while a later child response is running', () => {
|
||||
it('offers inherited ancestor replies in a fork of a fork while the child is running', () => {
|
||||
const { input, latestTurnKey } = conversation(
|
||||
[
|
||||
{ ask: 'older-user', replies: [row('legacy:opencode:source:reply-0', 'assistant', 1)] },
|
||||
{ ask: 'inherited-user', replies: [row('legacy:opencode:source:reply-1', 'assistant', 3)] },
|
||||
{
|
||||
ask: 'inherited-user',
|
||||
replies: [row('legacy:opencode:parent-fork:reply-1', 'assistant', 3)]
|
||||
},
|
||||
{ ask: 'own-user', replies: [row('legacy:opencode:child:reply-2', 'assistant', 6)] }
|
||||
],
|
||||
true
|
||||
@@ -164,7 +167,7 @@ it('offers only the copied fork-point tip while a later child response is runnin
|
||||
}
|
||||
},
|
||||
{
|
||||
itemId: 'legacy:opencode:source:reply-1',
|
||||
itemId: 'legacy:opencode:parent-fork:reply-1',
|
||||
sequence: 3,
|
||||
body: { kind: 'message', role: 'assistant', blocks: [{ type: 'text', text: 'copied' }] }
|
||||
},
|
||||
@@ -194,7 +197,13 @@ it('offers only the copied fork-point tip while a later child response is runnin
|
||||
turnWorking: false,
|
||||
inLatestTurn: false
|
||||
}
|
||||
expect(nativeChatRowOffersFork(olderRow, chat)).toBe(false)
|
||||
expect(nativeChatRowOffersFork(olderRow, chat)).toBe(true)
|
||||
expect(
|
||||
nativeChatRowOffersFork(olderRow, {
|
||||
...chat,
|
||||
support: { kind: 'known', fork: 'tip' }
|
||||
})
|
||||
).toBe(false)
|
||||
// Checkpoint providers still offer earlier inherited replies without original-tip support.
|
||||
expect(
|
||||
nativeChatRowOffersFork(olderRow, {
|
||||
@@ -210,7 +219,7 @@ it('offers only the copied fork-point tip while a later child response is runnin
|
||||
).toEqual({ kind: 'reply-running' })
|
||||
expect(
|
||||
buildNativeChatTranscript({ ...input, forkOffer: { chat, latestTurnKey } }).forkPoint
|
||||
).toEqual({ kind: 'ready', throughItemId: 'legacy:opencode:source:reply-1' })
|
||||
).toEqual({ kind: 'ready', throughItemId: 'legacy:opencode:parent-fork:reply-1' })
|
||||
expect(
|
||||
buildNativeChatTranscript({
|
||||
...input,
|
||||
|
||||
+18
-8
@@ -325,7 +325,7 @@ it('reconciles a lost create first and retains uncertainty when a later proof ca
|
||||
})
|
||||
})
|
||||
|
||||
it('rederives a restored tip fork requirement from the child before resubmitting', async () => {
|
||||
it('rederives a restored ancestor fork requirement from the child before resubmitting', async () => {
|
||||
const call = await remoteForkTransport()
|
||||
const prior = inheritedIntent()
|
||||
const restored = restoreStructuredAgentSessionLaunchIntent({
|
||||
@@ -359,18 +359,28 @@ it('rederives a restored tip fork requirement from the child before resubmitting
|
||||
body: { kind: 'message', role: 'assistant', blocks: [] }
|
||||
},
|
||||
{
|
||||
itemId: 'orca:forked-from',
|
||||
itemId: 'parent-fork-u2',
|
||||
sequence: 3,
|
||||
body: { kind: 'status', presentation: 'forked-from', text: 'Forked from source' }
|
||||
},
|
||||
{
|
||||
itemId: 'child-u2',
|
||||
sequence: 4,
|
||||
body: { kind: 'message', role: 'user', blocks: [] }
|
||||
},
|
||||
{
|
||||
itemId: 'legacy:opencode:child:reply-2',
|
||||
itemId: 'legacy:opencode:parent-fork:reply-2',
|
||||
sequence: 4,
|
||||
body: { kind: 'message', role: 'assistant', blocks: [] }
|
||||
},
|
||||
{
|
||||
itemId: 'orca:forked-from',
|
||||
sequence: 5,
|
||||
body: { kind: 'status', presentation: 'forked-from', text: 'Forked from source' }
|
||||
},
|
||||
{
|
||||
itemId: 'child-u3',
|
||||
sequence: 6,
|
||||
body: { kind: 'message', role: 'user', blocks: [] }
|
||||
},
|
||||
{
|
||||
itemId: 'legacy:opencode:child:reply-3',
|
||||
sequence: 7,
|
||||
body: { kind: 'message', role: 'assistant', blocks: [] }
|
||||
}
|
||||
]
|
||||
|
||||
@@ -48,15 +48,13 @@ export function nativeChatForkInventory(
|
||||
items: readonly Pick<AgentJournalRenderItem, 'itemId' | 'body' | 'agentId' | 'sequence'>[]
|
||||
): { forkableItemIds: ReadonlySet<string>; inheritedThroughSequence: number } {
|
||||
const forkableItemIds = new Set<string>()
|
||||
// The inherited tip is the last root response before the divider, not every copied response.
|
||||
let inheritedThroughSequence = 0
|
||||
let lastRootReplySequence = 0
|
||||
for (const item of items) {
|
||||
if (
|
||||
item.body.kind === 'status' &&
|
||||
item.body.presentation === AGENT_SESSION_FORKED_FROM_PRESENTATION
|
||||
) {
|
||||
inheritedThroughSequence = lastRootReplySequence
|
||||
inheritedThroughSequence = item.sequence
|
||||
}
|
||||
if (
|
||||
item.body.kind === 'message' &&
|
||||
@@ -64,7 +62,6 @@ export function nativeChatForkInventory(
|
||||
isRootAgentJournalItem(item)
|
||||
) {
|
||||
forkableItemIds.add(item.itemId)
|
||||
lastRootReplySequence = item.sequence
|
||||
}
|
||||
}
|
||||
return { forkableItemIds, inheritedThroughSequence }
|
||||
@@ -124,11 +121,11 @@ export function nativeChatRowOffersFork(
|
||||
(chat.support.kind === 'unknown' ||
|
||||
chat.support.fork === 'checkpoint' ||
|
||||
row.inLatestTurn ||
|
||||
(chat.support.inheritedOriginal === true && sequence === chat.inheritedThroughSequence))
|
||||
(chat.support.inheritedOriginal === true && sequence <= (chat.inheritedThroughSequence ?? 0)))
|
||||
)
|
||||
}
|
||||
|
||||
/** Only a nonlatest inherited tip needs the host's original-resolution extension. */
|
||||
/** Nonlatest copied replies of tip-only agents need the host's original-resolution extension. */
|
||||
export function nativeChatForkRequiresInheritedOriginal(
|
||||
items: readonly AgentJournalRenderItem[],
|
||||
fork: 'tip' | 'checkpoint',
|
||||
|
||||
Reference in New Issue
Block a user