mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
* fix(quick-commands): save agent prompts whole, bounded by what a chat message carries Agent quick-command prompts were silently cut to 6,000 characters on save: the editor accepted a long paste, settings normalization trimmed it, and reopening showed the shortened copy. The 6,000 was a Windows launch speed threshold, not a limit on prompts. - Storage no longer trims. A save is refused, never trimmed, when a prompt's chat text block is over 256 KiB of JSON (measured on its real escaped size, the measure the chat send schema applies) or the list is too large for one paired reply. Host and desktop store both check before writing. - The editor shows the size against the limit and blocks Save past it, and stays open with the text when the host refuses the save. - terminal.quick-commands.long-prompts.v1: hosts withhold prompts over 6,000 characters from clients that do not advertise it (older clients reject a whole list holding one); editors keep an older host's 6,000 cap. - The phone editor no longer drops pasted text past 6,000 via maxLength. Launch delivery of long prompts is left to the launch-prompt series (#24257, #23962, #24080); this branch's earlier paste-after-ready delivery duplicated it and is removed. * fix(quick-commands): drop a stale duplicate doc comment * fix(quick-commands): advertise long prompts to this build's own host too * fix(quick-commands): keep submitted editor immutable until save settles * test(quick-commands): keep storage and save lifecycle coverage focused * fix(quick-commands): keep portalled choices within pending form ownership * Preserve retained credentials when settings validation refuses a save --------- Co-authored-by: OrcaWin <alpha-eng@stably.ai>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
LEGACY_MAX_QUICK_COMMAND_AGENT_PROMPT_LENGTH,
|
|
MAX_QUICK_COMMAND_AGENT_PROMPT_MESSAGE_BYTES
|
|
} from '../../../src/shared/terminal-quick-command-prompt-limit'
|
|
import { terminalQuickCommandAgentPromptMaxLength } from '../terminal/quick-commands'
|
|
import { TERMINAL_QUICK_COMMAND_LONG_PROMPTS_RUNTIME_CAPABILITY } from '../../../src/shared/terminal-quick-command-capabilities'
|
|
import {
|
|
createEmptyQuickCommandDraft,
|
|
draftToQuickCommand,
|
|
isQuickCommandDraftPromptTooLong,
|
|
type QuickCommandDraft
|
|
} from './quick-command-draft'
|
|
|
|
function agentDraft(prompt: string): QuickCommandDraft {
|
|
return {
|
|
...createEmptyQuickCommandDraft({ type: 'global' }),
|
|
label: 'Review',
|
|
action: 'agent-prompt',
|
|
agent: 'claude',
|
|
prompt
|
|
}
|
|
}
|
|
|
|
describe('quick command drafts', () => {
|
|
it('saves a long prompt whole on a host that stores long prompts', () => {
|
|
const prompt = 'x'.repeat(100_000)
|
|
|
|
expect(draftToQuickCommand(agentDraft(prompt))).toMatchObject({ prompt })
|
|
// Past what a chat message carries, measured on the prompt's real size.
|
|
expect(
|
|
draftToQuickCommand(agentDraft('x'.repeat(MAX_QUICK_COMMAND_AGENT_PROMPT_MESSAGE_BYTES)))
|
|
).toBeNull()
|
|
})
|
|
|
|
it('reads the host cap from its capabilities', () => {
|
|
expect(terminalQuickCommandAgentPromptMaxLength(['terminal.quick-commands.v1'])).toBe(
|
|
LEGACY_MAX_QUICK_COMMAND_AGENT_PROMPT_LENGTH
|
|
)
|
|
expect(
|
|
terminalQuickCommandAgentPromptMaxLength([
|
|
TERMINAL_QUICK_COMMAND_LONG_PROMPTS_RUNTIME_CAPABILITY
|
|
])
|
|
).toBeNull()
|
|
// Unknown capabilities must not block a save; an older host refuses visibly itself.
|
|
expect(terminalQuickCommandAgentPromptMaxLength(undefined)).toBeNull()
|
|
})
|
|
|
|
it('refuses rather than trims a prompt over an older host cap', () => {
|
|
const draft = agentDraft('x'.repeat(LEGACY_MAX_QUICK_COMMAND_AGENT_PROMPT_LENGTH + 1))
|
|
|
|
expect(
|
|
isQuickCommandDraftPromptTooLong(draft, LEGACY_MAX_QUICK_COMMAND_AGENT_PROMPT_LENGTH)
|
|
).toBe(true)
|
|
expect(draftToQuickCommand(draft, LEGACY_MAX_QUICK_COMMAND_AGENT_PROMPT_LENGTH)).toBeNull()
|
|
})
|
|
})
|