Compare commits

...

2 Commits

Author SHA1 Message Date
suyao
185eff16b6 Merge remote-tracking branch 'origin/v2' into fix/v2/inputbar-cache 2025-12-01 13:53:27 +08:00
suyao
13abc2d653 Backport: PR 11558 to v2 2025-12-01 03:23:46 +08:00
2 changed files with 8 additions and 5 deletions

View File

@@ -45,7 +45,7 @@ const logger = loggerService.withContext('AgentSessionInputbar')
const DRAFT_CACHE_TTL = 24 * 60 * 60 * 1000 // 24 hours
const getAgentDraftCacheKey = (agentId: string) => `agent-session-draft-${agentId}`
const getAgentDraftCacheKey = (agentId: string) => `agent.session.draft.${agentId}`
type Props = {
agentId: string

View File

@@ -51,10 +51,10 @@ import TokenCount from './TokenCount'
const logger = loggerService.withContext('Inputbar')
const INPUTBAR_DRAFT_CACHE_KEY = 'inputbar-draft'
const INPUTBAR_DRAFT_CACHE_KEY = 'inputbar.draft.text'
const DRAFT_CACHE_TTL = 24 * 60 * 60 * 1000 // 24 hours
const getMentionedModelsCacheKey = (assistantId: string) => `inputbar-mentioned-models-${assistantId}`
const getMentionedModelsCacheKey = (assistantId: string) => `inputbar.mentioned.models.${assistantId}`
const getValidatedCachedModels = (assistantId: string): Model[] => {
const cached = cacheService.get<Model[]>(getMentionedModelsCacheKey(assistantId))
@@ -134,6 +134,10 @@ const InputbarInner: FC<InputbarInnerProps> = ({ assistant: initialAssistant, se
const { setFiles, setMentionedModels, setSelectedKnowledgeBases } = useInputbarToolsDispatch()
const { setCouldAddImageFile } = useInputbarToolsInternalDispatch()
const { text, setText } = useInputText({
initialValue: cacheService.get<string>(INPUTBAR_DRAFT_CACHE_KEY) ?? '',
onChange: (value) => cacheService.set(INPUTBAR_DRAFT_CACHE_KEY, value, DRAFT_CACHE_TTL)
})
const { text, setText } = useInputText({
initialValue: cacheService.get<string>(INPUTBAR_DRAFT_CACHE_KEY) ?? '',
onChange: (value) => cacheService.set(INPUTBAR_DRAFT_CACHE_KEY, value, DRAFT_CACHE_TTL)
@@ -213,8 +217,7 @@ const InputbarInner: FC<InputbarInnerProps> = ({ assistant: initialAssistant, se
useEffect(() => {
return () => onUnmount(assistant.id)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [assistant.id])
}, [assistant.id, onUnmount])
const placeholderText = enableQuickPanelTriggers
? t('chat.input.placeholder', { key: getSendMessageShortcutLabel(sendMessageShortcut) })