mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 16:03:20 +00:00
* Use bounded OpenCode context for vault session continuation OpenCode database and synthetic row paths are not text transcripts. Use the vault preview or captured pane context, preserving actual transcript paths containing a hash and supporting both OpenCode lanes and Windows paths. Adapted the intent of #11859 and extended it to actual installed v2 vault rows. Co-authored-by: mrcha033 <mrcha033@users.noreply.github.com> * Read real OpenCode sessions in terminal-backed native Chat Reuse the bounded AI Vault SQLite worker for v1 and v2 session pages and live updates. Keep terminal input as the real execution path and pace OpenCode Stop through its two-Escape interrupt. Co-authored-by: xodmd45-ctrl <xodmd45-ctrl@users.noreply.github.com> * fix(opencode): publish approval cards for permission requests * Send OpenCode native approval through its Enter selector * Resolve mobile Chat readability for folder workspaces * Bound OpenCode part batches and preserve v2 image attachments * Prefer live migrated OpenCode sessions over legacy copies * Consolidate mobile Chat eligibility test imports * Consolidate OpenCode SQLite protocol type imports * Update native chat settings contract for both OpenCode agents * fix(native-chat): reconcile bounded OpenCode transcript reads * fix(native-chat): dispatch OpenCode questions safely * fix(native-chat): keep native discovery and transcript windows current * feat(accounts): link standalone GLM Coding Plans (#24618) * feat(accounts): link standalone GLM Coding Plans Adapt the reviewed GLM accounts contribution to current main, retain Antigravity behavior, guard late credential results, expose storage protection, and redact quota errors. Co-authored-by: Luchong <lu740528977@gmail.com> * fix(accounts): retain GLM credential results during quota refresh * fix(accounts): make GLM credential editing desktop-only * fix(accounts): mirror the host GLM site in paired clients * fix(accounts): report unknown GLM host details and split web settings tests Apply the independently reviewed Accounts correction from697284a without the v2 adapter commits. Preserve the saved-key store and serialized write behavior. * fix(zcode): ship required GLM account translation entries * chore: record GLM reconciliation hook validation * chore: validate installed GLM commit hooks * test: complete GLM account fixtures and web API inventory --------- Co-authored-by: Luchong <lu740528977@gmail.com> * fix(native-chat): route transcript requests through shared SQLite worker * fix(ci): prevent concurrent pnpm refresh during mobile typechecks (#24776) * fix(ci): run mobile typechecks without concurrent dependency refresh * test(ci): check effective Linux E2E package list * test(ci): preserve the mobile production compiler barrier --------- Co-authored-by: Orca Integration Recovery <orca-validation@invalid.example> * test(terminal): restore the live fish fixture prerequisites (#24947) A restored pane waits for the initial status replay before subscribing to PTY output. This fixture never settled that replay, so fish printed its mode-2031 arm before the renderer connected. Its PTY API also omitted the reset-input listener required by the serializer, aborting attachment. Settle and dispose the existing startup-snapshot registration and provide the same reset-listener mock used by the other PTY tests. The real fish child-stdin assertions and timeouts remain unchanged. No production change. * fix(shortcuts): defer TUI editing chords in terminal-first mode (#24640) Restack the original focused change onto current main, preserving every owned source and test blob and the merged CI contract and journal cleanup fixes. Original-commit:f707cde14afix(shortcuts): defer TUI editing chords in terminal-first mode Original-commit:0c6348e49edocs(shortcuts): describe deferred preview terminal chords Original-commit:be62c1b6c6Align worktree history shortcut metadata with terminal conflict policy Restacked-from:be62c1b6c6Restacked-onto:f7b1f9d8be* Register supervised Qoder China and Qwen Code (#24616) * Add Qoder session history and search with real CLI coverage * Allow the real Qoder marker file to end with a newline * Keep Qoder tool output out of history previews and search * Keep Qoder search pages readable by older clients * Verify persisted Qoder history after a real generated and resumed task * Negotiate Qoder filters before searching an older execution host * Combine search client imports for the CI plugin gate * Keep the relay search oracle aligned with legacy agent filtering * Register supervised Qoder China and Qwen lifecycle integration * Cover Qoder China mobile assets and mixed-host resume gates * Verify Qoder provider tags against the older released wire parser * Verify China and Qwen keep independent Windows hook scripts * Verify Qoder registrations against the installed older Windows release * test(qoder): align search capability contracts and pin old-host fencing * fix(qoder): rank exact picker identities and command aliases first * test(qoder): preserve the regional CLI shared icon expectation Keep the full bundled-asset and no-remote-image checks, with an explicit shared-logo basename for Qoder China. The map also works with older catalog type unions. * fix(qoder): align China catalog entry with fallback order --------- Co-authored-by: Orca Integration Recovery <orca-validation@invalid.example> * Use the measured pnpm lookup policy automatically in hosted root CI (#24951) * Select lookup automatically for the measured hosted root-install profile * Record hosted automatic-mode cold cache publication proof * fix(native-chat): keep OpenCode history usable at read limits Continue past failed database probes while preserving discovery cancellation. Verify rows displaced by a capped tail before deciding whether to replace history. Represent oversized v1/v2 rows with the existing omission text and stable cursors. * Continue Antigravity IDE and 2.0 history in new CLI conversations (#24692) * feat(antigravity): bridge IDE history into new CLI conversations * fix(antigravity): preserve fresh-launch model and environment for IDE references * fix(antigravity): forward IDE history opt-in through desktop IPC * fix(antigravity): rebuild remote IDE reference startup on its host * fix(antigravity): register IDE continuation action labels * fix(antigravity): confine IDE references and bound metadata reads * fix(antigravity): localize IDE continuation badges * Preserve scanner service cache assertions and refresh Antigravity opening metadata * Preserve Antigravity opening joins and target folder runtime authority * fix(opencode): retry timed-out SSH plugin updates (#24666) Preserve bounded retry behavior and the current-main status-envelope fields. Original-PR: #24124 Reviewed-source:103144f9c5Co-authored-by: Justas Brazauskas <brazauskasjustas@gmail.com> * fix(opencode): keep Go credentials private and resolve backend keys (#24615) Preserve the complete credential storage, migration, IPC, Settings and rate-limit refresh change alongside standalone GLM plans, current-main database diagnostics and the reviewed unknown-backend environment correction. Keep native discovery cancellation third and selected environment fourth. Original-topic-commit:7903f1cddbOriginal-topic-commit:588117b5cfOriginal-topic-commit:dedd4f8c86Original-topic-commit:6645dae104Original-topic-commit: a25b80c02c1af7830b0e6a65e72d965b3ad98276 Restacked-from: a25b80c02c1af7830b0e6a65e72d965b3ad98276 Restacked-onto:b032867021Co-authored-by: kespineira <kespineira@users.noreply.github.com> Co-authored-by: kevimux <kevimux@users.noreply.github.com> Reported-by: pullfrog Reviewed-full-source: 849fe093073f4c1606bd65d79a0c725d955d0d1f Native-helper-source:80dbe23237Reviewed-full-current-source: 36acb57d44adb3d378c0289c8c15f7da0fda214c --------- Co-authored-by: mrcha033 <mrcha033@users.noreply.github.com> Co-authored-by: xodmd45-ctrl <xodmd45-ctrl@users.noreply.github.com> Co-authored-by: Luchong <lu740528977@gmail.com> Co-authored-by: Orca Integration Recovery <orca-validation@invalid.example> Co-authored-by: Justas Brazauskas <brazauskasjustas@gmail.com>
226 lines
8.0 KiB
TypeScript
226 lines
8.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
NATIVE_CHAT_INTERRUPTED_STATUS_TEXT,
|
|
type NativeChatBlock,
|
|
type NativeChatMessage
|
|
} from './native-chat-types'
|
|
import {
|
|
extractPendingAsk,
|
|
nativeChatAskDismissKey,
|
|
parseAskFromStatus,
|
|
resolveNativeChatAsk
|
|
} from './native-chat-ask'
|
|
|
|
function message(id: string, blocks: NativeChatBlock[]): NativeChatMessage {
|
|
return { id, role: 'assistant', blocks, timestamp: 1, source: 'transcript' }
|
|
}
|
|
|
|
function call(name: string, input: unknown): NativeChatBlock {
|
|
return { type: 'tool-call', name, input }
|
|
}
|
|
|
|
function result(): NativeChatBlock {
|
|
return { type: 'tool-result', output: 'ok' }
|
|
}
|
|
|
|
/** The row the transcript decoders emit for an interrupted turn. */
|
|
function interrupted(id: string): NativeChatMessage {
|
|
return {
|
|
id,
|
|
role: 'system',
|
|
blocks: [{ type: 'text', text: NATIVE_CHAT_INTERRUPTED_STATUS_TEXT }],
|
|
timestamp: 1,
|
|
source: 'transcript'
|
|
}
|
|
}
|
|
|
|
function userTurn(id: string, text: string): NativeChatMessage {
|
|
return { id, role: 'user', blocks: [{ type: 'text', text }], timestamp: 1, source: 'transcript' }
|
|
}
|
|
|
|
/** Claude delivers tool results on their own turn, which decodes as role 'tool'. */
|
|
function toolTurn(id: string): NativeChatMessage {
|
|
return { id, role: 'tool', blocks: [result()], timestamp: 1, source: 'transcript' }
|
|
}
|
|
|
|
const QUESTIONS_INPUT = {
|
|
questions: [{ question: 'Deploy?', options: [{ label: 'Yes' }, { label: 'No' }] }]
|
|
}
|
|
|
|
describe('nativeChatAskDismissKey', () => {
|
|
it('uses the full canonical prompt and stays stable across object instances', () => {
|
|
const first = parseAskFromStatus(JSON.stringify(QUESTIONS_INPUT))
|
|
const same = parseAskFromStatus(JSON.stringify(QUESTIONS_INPUT))
|
|
const changed = parseAskFromStatus(
|
|
JSON.stringify({ questions: [{ question: 'Deploy?', options: [{ label: 'Later' }] }] })
|
|
)
|
|
|
|
expect(nativeChatAskDismissKey(first)).toBe(nativeChatAskDismissKey(same))
|
|
expect(nativeChatAskDismissKey(first)).not.toBe(nativeChatAskDismissKey(changed))
|
|
expect(nativeChatAskDismissKey(null)).toBeNull()
|
|
})
|
|
})
|
|
|
|
describe('extractPendingAsk', () => {
|
|
it('recognizes an unregistered tool whose input matches the canonical questions shape', () => {
|
|
// The live path (parseAskFromStatus) accepts this shape from any tool name;
|
|
// transcript replay must not silently drop the same pending question.
|
|
const pending = extractPendingAsk([message('m1', [call('CustomAskTool', QUESTIONS_INPUT)])])
|
|
expect(pending?.questions[0]?.question).toBe('Deploy?')
|
|
})
|
|
|
|
it('resolves calls FIFO so a sibling result cannot clear a newer pending ask', () => {
|
|
const pending = extractPendingAsk([
|
|
message('m1', [
|
|
call('Bash', { command: 'ls' }),
|
|
call('AskUserQuestion', QUESTIONS_INPUT),
|
|
// FIFO: this result answers the Bash call, not the ask.
|
|
result()
|
|
])
|
|
])
|
|
expect(pending?.questions[0]?.question).toBe('Deploy?')
|
|
})
|
|
|
|
it("clears the ask when its own result arrives, keeping the newest ask's identity", () => {
|
|
const first = { questions: [{ question: 'First?', options: [] }] }
|
|
const pending = extractPendingAsk([
|
|
message('m1', [
|
|
call('AskUserQuestion', first),
|
|
call('AskUserQuestion', QUESTIONS_INPUT),
|
|
// Resolves the FIRST ask (FIFO); the newer one stays pending.
|
|
result()
|
|
])
|
|
])
|
|
expect(pending?.questions[0]?.question).toBe('Deploy?')
|
|
})
|
|
|
|
it('does not strand an answered ask behind a tool call orphaned by an interrupt', () => {
|
|
// ESC on a running tool: Claude writes its interrupt record instead of a
|
|
// tool result, so that call's FIFO slot never resolves (#11761).
|
|
const pending = extractPendingAsk([
|
|
message('m1', [call('Bash', { command: 'sleep 999' })]),
|
|
interrupted('m2'),
|
|
message('m3', [call('AskUserQuestion', QUESTIONS_INPUT)]),
|
|
message('m4', [result()])
|
|
])
|
|
expect(pending).toBeNull()
|
|
})
|
|
|
|
it('drops an ask abandoned by an interrupt', () => {
|
|
const pending = extractPendingAsk([
|
|
message('m1', [call('AskUserQuestion', QUESTIONS_INPUT)]),
|
|
interrupted('m2')
|
|
])
|
|
expect(pending).toBeNull()
|
|
})
|
|
|
|
it('keeps an ask that is still awaiting its result after an earlier interrupt', () => {
|
|
const pending = extractPendingAsk([
|
|
message('m1', [call('Bash', { command: 'sleep 999' })]),
|
|
interrupted('m2'),
|
|
message('m3', [call('AskUserQuestion', QUESTIONS_INPUT)])
|
|
])
|
|
expect(pending?.questions[0]?.question).toBe('Deploy?')
|
|
})
|
|
|
|
it('drops an ask the user typed past instead of answering', () => {
|
|
// Real transcripts hold asks that never get a result because the user
|
|
// escaped the selector and sent a new prompt — the question is over.
|
|
const pending = extractPendingAsk([
|
|
message('m1', [call('AskUserQuestion', QUESTIONS_INPUT)]),
|
|
userTurn('m2', 'never mind, do this instead'),
|
|
message('m3', [{ type: 'text', text: 'on it' }])
|
|
])
|
|
expect(pending).toBeNull()
|
|
})
|
|
|
|
it('does not strand an answered ask behind an orphan left by a plain-text interrupt', () => {
|
|
// Claude also writes the interrupt as a bare user turn (no
|
|
// `interruptedMessageId`), which decodes as a user message, not a status row.
|
|
const pending = extractPendingAsk([
|
|
message('m1', [call('Bash', { command: 'sleep 999' })]),
|
|
userTurn('m2', '[Request interrupted by user]'),
|
|
message('m3', [call('AskUserQuestion', QUESTIONS_INPUT)]),
|
|
toolTurn('m4')
|
|
])
|
|
expect(pending).toBeNull()
|
|
})
|
|
|
|
it('resolves an ask whose result arrives on its own tool-role turn', () => {
|
|
const pending = extractPendingAsk([
|
|
message('m1', [call('AskUserQuestion', QUESTIONS_INPUT)]),
|
|
toolTurn('m2')
|
|
])
|
|
expect(pending).toBeNull()
|
|
})
|
|
|
|
it('ignores malformed question payloads', () => {
|
|
expect(
|
|
extractPendingAsk([
|
|
message('m1', [
|
|
call('AskUserQuestion', { questions: [] }),
|
|
call('AskUserQuestion', { questions: [{}] }),
|
|
call('AskUserQuestion', 'not-an-object')
|
|
])
|
|
])
|
|
).toBeNull()
|
|
})
|
|
})
|
|
|
|
describe('parseAskFromStatus', () => {
|
|
it('preserves OpenCode question envelope multiple selection on live status and replay', () => {
|
|
const input = {
|
|
id: 'question',
|
|
sessionID: 'session',
|
|
questions: [
|
|
{
|
|
header: 'Choice',
|
|
question: 'Pick both?',
|
|
multiple: true,
|
|
options: [
|
|
{ label: 'One', description: 'first' },
|
|
{ label: 'Two', description: 'second' }
|
|
]
|
|
}
|
|
]
|
|
}
|
|
const prompt = parseAskFromStatus(JSON.stringify(input), 'AskUserQuestion')
|
|
expect(prompt?.questions[0]).toMatchObject({ multiSelect: true, header: 'Choice' })
|
|
expect(extractPendingAsk([message('m1', [call('question', input)])])).toEqual(prompt)
|
|
})
|
|
it('accepts the canonical shape from any tool name and rejects broken JSON', () => {
|
|
expect(
|
|
parseAskFromStatus(JSON.stringify(QUESTIONS_INPUT), 'SomeNewTool')?.questions
|
|
).toHaveLength(1)
|
|
expect(parseAskFromStatus('{not json', 'AskUserQuestion')).toBeNull()
|
|
expect(parseAskFromStatus(null)).toBeNull()
|
|
})
|
|
|
|
it('parses string options into labels', () => {
|
|
const prompt = parseAskFromStatus(
|
|
JSON.stringify({ questions: [{ question: 'Pick', options: ['a', 'b'] }] })
|
|
)
|
|
expect(prompt?.questions[0]?.options.map((o) => o.label)).toEqual(['a', 'b'])
|
|
})
|
|
})
|
|
|
|
describe('resolveNativeChatAsk', () => {
|
|
const transcript = [message('m1', [call('AskUserQuestion', QUESTIONS_INPUT)])]
|
|
|
|
it('withholds transcript state until the read settles', () => {
|
|
expect(
|
|
resolveNativeChatAsk({ liveAsk: null, messages: transcript, transcriptSettled: false })
|
|
).toBeNull()
|
|
expect(
|
|
resolveNativeChatAsk({ liveAsk: null, messages: transcript, transcriptSettled: true })
|
|
)?.toMatchObject(QUESTIONS_INPUT)
|
|
})
|
|
|
|
it('keeps a live ask authoritative while transcript history is unsettled', () => {
|
|
const liveAsk = { questions: [{ question: 'Live?', options: [], multiSelect: false }] }
|
|
expect(resolveNativeChatAsk({ liveAsk, messages: transcript, transcriptSettled: false })).toBe(
|
|
liveAsk
|
|
)
|
|
})
|
|
})
|