Files
archived-orca/src/shared/structured-agent-session-composer-failure.ts
T
OrcaWinandOrcaWin 924d757ad6 fix(i18n): code shared validation errors; translate speech model, setup source and project group copy (#35737)
* fix(i18n): code shared validation errors and translate speech model, setup source and project group copy

* fix(i18n): keep detected label for unknown setup import providers

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-28 23:49:27 -07:00

33 lines
1.4 KiB
TypeScript

// One English table for composer command refusals: `error` stays English, desktop translates by code.
export const STRUCTURED_COMPOSER_FAILURE_COPY = {
goalObjectiveMissing: 'Describe the goal after /goal.',
commandUnavailable:
'/{{name}} is not available in chat sessions. Use the slash menu to see available commands.',
commandTakesNoArguments: 'Use /{{name}} without arguments.',
commandUnsupportedByHost: '/{{name}} is not supported by this chat host.',
modelPickerFailed: 'Could not open the model picker.',
effortPickerFailed: 'Could not open the effort picker.',
modelApplyFailed: 'Could not apply model {{value}}.',
effortApplyFailed: 'Could not apply effort {{value}}.'
} as const
export type StructuredComposerFailureCode = keyof typeof STRUCTURED_COMPOSER_FAILURE_COPY
export type StructuredComposerFailureParams = { name?: string; value?: string }
export function structuredComposerFailure(
errorCode: StructuredComposerFailureCode,
errorParams?: StructuredComposerFailureParams
): {
error: string
errorCode: StructuredComposerFailureCode
errorParams?: StructuredComposerFailureParams
} {
// One pass so a value containing "{{name}}" stays verbatim.
const error = STRUCTURED_COMPOSER_FAILURE_COPY[errorCode].replace(
/\{\{(name|value)\}\}/g,
(_slot, slot: 'name' | 'value') => errorParams?.[slot] ?? ''
)
return { error, errorCode, ...(errorParams ? { errorParams } : {}) }
}