mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-16 20:40:01 +00:00
* fix(web): align sharing with session state * fix(web): keep share state in sync * fix(web): fail closed for trimmed active turns * fix(web): refresh prepared share images * fix(web): preserve sharing during queued thinking * fix: track a stable active turn boundary * fix: anchor active turns to persisted messages * fix(web): include Pi reasoning in share metadata * fix(hub): refresh queued thinking grace on retry * test(web): isolate mobile thread scroll setup * fix(hub): advance queued turn boundaries * fix(hub): guard queued boundary advancement * perf(web): precompute running turn sharing * fix(hub): use hub time for turn boundaries * perf(web): pause closed share metadata timer
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import type { SessionHeaderMetadataPreferences } from '@/hooks/useSessionHeaderMetadata'
|
|
import { formatReasoningLabel, getReasoningEffortForFlavor } from '@/lib/codexStatusLabels'
|
|
|
|
export type ShareTurnMetadataKey = Exclude<keyof SessionHeaderMetadataPreferences, 'showLabels'>
|
|
|
|
export type ShareTurnMetadataItem = {
|
|
key: ShareTurnMetadataKey
|
|
text: string
|
|
flavor?: string | null
|
|
}
|
|
|
|
export function getShareTurnReasoningLabel(
|
|
agentFlavor: string | null | undefined,
|
|
modelReasoningEffort: string | null | undefined,
|
|
effort: string | null | undefined,
|
|
showLabels: boolean
|
|
): string | null {
|
|
const reasoningEffort = getReasoningEffortForFlavor(agentFlavor, modelReasoningEffort, effort)
|
|
return reasoningEffort ? formatReasoningLabel(reasoningEffort, showLabels) : null
|
|
}
|
|
|
|
const SESSION_HEADER_METADATA_ORDER: ReadonlyArray<ShareTurnMetadataKey> = [
|
|
'agent',
|
|
'machine',
|
|
'lastActive',
|
|
'model',
|
|
'reasoning',
|
|
'fastMode',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'worktree',
|
|
]
|
|
|
|
export function selectShareTurnMetadata(
|
|
preferences: SessionHeaderMetadataPreferences,
|
|
available: Partial<Record<ShareTurnMetadataKey, Omit<ShareTurnMetadataItem, 'key'>>>
|
|
): ShareTurnMetadataItem[] {
|
|
return SESSION_HEADER_METADATA_ORDER.flatMap((key) => {
|
|
const item = available[key]
|
|
return preferences[key] && item?.text ? [{ key, ...item }] : []
|
|
})
|
|
}
|