mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(cloud): CR-title a generated '<Agent> <id>' vault title never names a tab
A session whose first turn failed (expired sign-in, network, the harness's fake token) has no transcript title or prompt, so the vault answers the generated 'Claude 6ebe07c5' and the tab-title sync wrote it over the tab's own title. The sync now skips that generated name; the tab keeps 'Claude' or its launch title. The generator moves to shared so main and the renderer agree on it.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { basename, extname } from 'node:path'
|
||||
import {
|
||||
aiVaultAgentLabel,
|
||||
type AiVaultAgent,
|
||||
type AiVaultSession,
|
||||
type AiVaultSessionTitleKind
|
||||
import { generatedAiVaultSessionTitle } from '../../shared/ai-vault/contracts/generated-session-title'
|
||||
import type {
|
||||
AiVaultAgent,
|
||||
AiVaultSession,
|
||||
AiVaultSessionTitleKind
|
||||
} from '../../shared/ai-vault/contracts/ai-vault-types'
|
||||
import { buildAiVaultResumeCommand } from '../../shared/ai-vault/resume/ai-vault-resume-command'
|
||||
import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../shared/execution-host'
|
||||
@@ -155,7 +155,7 @@ export function finalizeSession(
|
||||
|
||||
/** Shared fallback lets sidecar enrichment distinguish generated titles from transcript titles. */
|
||||
export function generatedSessionTitle(agent: AiVaultAgent, sessionId: string): string {
|
||||
return `${aiVaultAgentLabel(agent)} ${sessionId.slice(0, 8)}`
|
||||
return generatedAiVaultSessionTitle(agent, sessionId)
|
||||
}
|
||||
|
||||
export function updateTimeline(accumulator: SessionAccumulator, timestamp: unknown): void {
|
||||
|
||||
@@ -9,6 +9,23 @@ import { startAiVaultTabTitleSync } from './ai-vault-tab-title-sync'
|
||||
import { makeState, titleResult } from './ai-vault-tab-title-test-fixture'
|
||||
|
||||
describe('AI Vault tab title sync', () => {
|
||||
it('never names a tab with the generated "<Agent> <id>" title (CR-title)', async () => {
|
||||
const store = makeState({
|
||||
agent: 'claude',
|
||||
executionHostId: 'runtime:server-1',
|
||||
worktreeId: 'worktree-1',
|
||||
path: '/workspace/albacore'
|
||||
})
|
||||
// A failed first turn leaves the transcript with no title or prompt: the host answers the
|
||||
// generated name, "Claude" + the session id's first 8 characters.
|
||||
const resolveSessionTitles = vi.fn(async () => titleResult('claude', 'Claude claude-s'))
|
||||
const stop = startAiVaultTabTitleSync({ ...store, resolveSessionTitles })
|
||||
await vi.waitFor(() => expect(resolveSessionTitles).toHaveBeenCalled())
|
||||
await new Promise((resolve) => setTimeout(resolve, 0))
|
||||
expect(store.getState().tabsByWorktree['worktree-1'][0].aiVaultTitle).toBeUndefined()
|
||||
stop()
|
||||
})
|
||||
|
||||
it('retains a recovered sleeping title after its lifecycle record disappears', async () => {
|
||||
const store = makeState({
|
||||
executionHostId: 'ssh:dev-box',
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
AiVaultSessionTitlesArgs,
|
||||
AiVaultSessionTitlesResult
|
||||
} from '../../../../../../shared/ai-vault/contracts/ai-vault-session-title'
|
||||
import { generatedAiVaultSessionTitle } from '../../../../../../shared/ai-vault/contracts/generated-session-title'
|
||||
import type { AppState } from '@/store/types'
|
||||
import {
|
||||
collectAiVaultTitleRequests,
|
||||
@@ -99,7 +100,12 @@ export function startAiVaultTabTitleSync(dependencies: SyncDependencies): () =>
|
||||
}
|
||||
const titleByIdentity = new Map<string, Pick<AiVaultSessionTitle, 'title' | 'kind'>>()
|
||||
for (const title of result.titles) {
|
||||
if (title.title.trim()) {
|
||||
// A generated "Claude 6ebe07c5" (no transcript title or prompt yet, e.g. a failed first turn)
|
||||
// never replaces the tab's own title (CR-title).
|
||||
if (
|
||||
title.title.trim() &&
|
||||
title.title.trim() !== generatedAiVaultSessionTitle(title.agent, title.sessionId)
|
||||
) {
|
||||
titleByIdentity.set(`${first.executionHostId}\0${title.agent}\0${title.sessionId}`, {
|
||||
title: title.title.trim(),
|
||||
kind: title.kind
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { aiVaultAgentLabel, type AiVaultAgent } from './ai-vault-types'
|
||||
|
||||
/** The name a session gets when its transcript has no title or prompt yet: "Claude 6ebe07c5". */
|
||||
export function generatedAiVaultSessionTitle(agent: AiVaultAgent, sessionId: string): string {
|
||||
return `${aiVaultAgentLabel(agent)} ${sessionId.slice(0, 8)}`
|
||||
}
|
||||
Reference in New Issue
Block a user