mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 02:57:36 +00:00
* feat: generate chat names through configured text agents * Project structured chat names across stored tabs and session rows * Name native chats from their first live message * Restore the journal test provider handle import * Fix first-message naming and live Vault title updates * Preserve Unicode characters in bounded chat naming prompts * Read chat naming settings only when a turn needs them * fix(chat): store only generated conversation names * fix(chat): keep ordinary labels across unnamed chat surfaces * fix(chat): preserve naming after fast first turns * Preserve native chat names across command-first sends and Vault lifecycle * Route native chat SQLite contracts through the existing Node test pool * feat(settings): add chat naming controls to Chat page * Preserve chat naming drafts and configure Custom commands through host settings * Scope synthetic command output to its journal thread in naming test * Keep naming test fixtures within their typed project boundaries * Resolve the real Vault hook directly in its integration test * Publish chat naming save refs after render commits * fix: keep Japanese chat naming copy stable during repair * Update test contracts for the naming integration * Keep journal fixture reads on the host clock * Give Chat names a separate settings section
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import type { AgentJournalRenderItem } from './agent-session-journal-types'
|
|
import { isRootAgentJournalItem } from './agent-session-journal-producer'
|
|
import { isStructuredAgentSessionCommandEntry } from './structured-agent-session-command-entry'
|
|
import { sliceAtCodeUnitLimit } from './surrogate-safe-text-slice'
|
|
|
|
export const STRUCTURED_CHAT_NAME_PROMPT_LIMIT = 4000
|
|
|
|
export function hasStructuredChatPromptText(prompt: string): boolean {
|
|
return /[\p{L}\p{N}]/u.test(prompt)
|
|
}
|
|
|
|
export function firstStructuredAgentSessionPrompt(
|
|
items: readonly AgentJournalRenderItem[]
|
|
): string {
|
|
for (const item of items) {
|
|
const body = item.body
|
|
if (
|
|
body.kind !== 'message' ||
|
|
body.role !== 'user' ||
|
|
!isRootAgentJournalItem(item) ||
|
|
isStructuredAgentSessionCommandEntry(body)
|
|
) {
|
|
continue
|
|
}
|
|
let prompt = ''
|
|
for (const block of body.blocks) {
|
|
if (block.type === 'text') {
|
|
if (prompt) {
|
|
prompt += '\n'
|
|
}
|
|
prompt += sliceAtCodeUnitLimit(
|
|
block.text,
|
|
STRUCTURED_CHAT_NAME_PROMPT_LIMIT - prompt.length
|
|
)
|
|
if (prompt.length >= STRUCTURED_CHAT_NAME_PROMPT_LIMIT) {
|
|
break
|
|
}
|
|
}
|
|
}
|
|
if (hasStructuredChatPromptText(prompt)) {
|
|
return prompt.trim()
|
|
}
|
|
}
|
|
return ''
|
|
}
|