Refine travel reimbursement steward flow
Align planner, runtime rules, and policy assets so travel guidance matches the updated reimbursement workflow.
This commit is contained in:
@@ -4,17 +4,18 @@ import {
|
||||
buildStewardSuggestedActions,
|
||||
normalizeStewardPlan
|
||||
} from './stewardPlanModel.js'
|
||||
import { resolveStewardTypewriterNextIndex } from './stewardTypewriter.js'
|
||||
import { SESSION_TYPE_STEWARD } from './travelReimbursementConversationModel.js'
|
||||
|
||||
const STEWARD_TYPEWRITER_INTERVAL_MS = 10
|
||||
const STEWARD_THINKING_TYPEWRITER_INTERVAL_MS = 8
|
||||
const STEWARD_TYPEWRITER_CHUNK_SIZE = 4
|
||||
const STEWARD_THINKING_TYPEWRITER_CHUNK_SIZE = 5
|
||||
|
||||
export function useStewardPlanFlow({
|
||||
activeSessionType,
|
||||
attachedFiles,
|
||||
composerDraft,
|
||||
conversationId,
|
||||
currentUser,
|
||||
fileInputRef,
|
||||
messages,
|
||||
@@ -30,6 +31,7 @@ export function useStewardPlanFlow({
|
||||
submitting,
|
||||
reviewActionBusy,
|
||||
sessionSwitchBusy,
|
||||
stewardState,
|
||||
toast
|
||||
}) {
|
||||
const stewardTypewriterTimers = new Map()
|
||||
@@ -108,9 +110,19 @@ export function useStewardPlanFlow({
|
||||
const requestPayload = buildStewardPlanRequest({
|
||||
rawText,
|
||||
files,
|
||||
currentUser: currentUser.value || {}
|
||||
currentUser: currentUser.value || {},
|
||||
conversationId: conversationId?.value || '',
|
||||
stewardState: stewardState?.value || null
|
||||
})
|
||||
const plan = await fetchPlanWithStreaming(pendingMessage.id, requestPayload, streamRunId)
|
||||
const nextConversationId = String(plan?.conversation_id || plan?.conversationId || '').trim()
|
||||
if (nextConversationId && conversationId) {
|
||||
conversationId.value = nextConversationId
|
||||
}
|
||||
const nextStewardState = plan?.steward_state || plan?.stewardState || null
|
||||
if (nextStewardState && typeof nextStewardState === 'object' && stewardState) {
|
||||
stewardState.value = nextStewardState
|
||||
}
|
||||
await waitForStewardThinkingQueue(streamRunId)
|
||||
const typedThinkingEvents = resolveStewardThinkingEvents(pendingMessage.id)
|
||||
const normalizedPlan = normalizeStewardPlan(plan, {
|
||||
@@ -176,7 +188,7 @@ export function useStewardPlanFlow({
|
||||
if (runId !== stewardTypewriterRunId) {
|
||||
return
|
||||
}
|
||||
index = resolveStewardTypewriterNextIndex(chars, index)
|
||||
index = Math.min(total, index + STEWARD_TYPEWRITER_CHUNK_SIZE)
|
||||
const message = messages.value.find((item) => item.id === messageId)
|
||||
if (!message) {
|
||||
return
|
||||
@@ -188,7 +200,9 @@ export function useStewardPlanFlow({
|
||||
...normalizedPlan,
|
||||
streamStatus: 'typing'
|
||||
}
|
||||
nextTick(scrollToBottom)
|
||||
if (index % 4 === 0 || index === total) {
|
||||
nextTick(scrollToBottom)
|
||||
}
|
||||
}
|
||||
|
||||
const message = messages.value.find((item) => item.id === messageId)
|
||||
|
||||
Reference in New Issue
Block a user