{#if message.from === "assistant"}
(isTapped = !isTapped)} onkeydown={() => (isTapped = !isTapped)} >
{#if focusedPersonaId && hasMultipleCards} {@const currentIndex = responses.findIndex(r => r.personaId === focusedPersonaId)} {@const hasPrev = currentIndex > 0} {@const hasNext = currentIndex < responses.length - 1} {#if hasPrev}
navigateFocused('prev')} class="absolute -left-12 top-1/2 z-10 -translate-y-1/2 rounded-full p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200 transition-all" aria-label="Previous persona" >
{/if} {#if hasNext}
navigateFocused('next')} class="absolute -right-12 top-1/2 z-10 -translate-y-1/2 rounded-full p-2 text-gray-500 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200 transition-all" aria-label="Next persona" >
{/if} {/if}
{#if isPersonaMode && responses.length === 0 && isLast && loading}
{/if} {#each responses as response (response.personaId)} {@const isExpanded = expandedStates[response.personaId]} {@const displayName = response.personaName || personaName || 'Assistant'} {@const isFocused = focusedPersonaId === response.personaId} {@const shouldHide = focusedPersonaId && !isFocused} {@const isGenerating = isLast && loading && (!response.content || response.content.length === 0)} {#if !shouldHide}
{#if isPersonaMode}
openPersonaSettings(response.personaId)} aria-label="Open settings for {displayName}" title="View {displayName} settings" > {displayName}
{:else}
{displayName}
{/if}
{#if !loading && onretry}
{ e.stopPropagation(); onretry?.({ id: message.id, personaId: response.personaId }); }} aria-label="Regenerate {displayName}'s response" title="Regenerate this response" >
{/if} {#if !loading && onbranch} {@const isBranchClicked = branchClickedPersonaId === response.personaId}
{ e.stopPropagation(); // Trigger animation branchClickedPersonaId = response.personaId; if (branchClickTimeout) { clearTimeout(branchClickTimeout); } branchClickTimeout = setTimeout(() => { branchClickedPersonaId = null; }, 500); onbranch?.(message.id, response.personaId); }} aria-label="Branch conversation with {displayName}" title="Start private conversation with {displayName}" >
{/if}
{#if !isPersonaMode && message.files?.length}
{#each message.files as file (file.value)}
{/each}
{/if} {#if !isPersonaMode && hasServerReasoning && loading && message.content.length === 0}
{/if}
{#if isGenerating}
{:else} {@const segments = splitThinkSegments(response.content ?? "")} {#each segments as part, _i} {#if part && part.startsWith("
")} {@const trimmed = part.trimEnd()} {@const isClosed = trimmed.endsWith("
")} {#if !isClosed}
{/if} {:else if part && part.trim().length > 0}
{/if} {/each} {/if} {#if response.routerMetadata}
{response.routerMetadata.route}
•
{response.routerMetadata.model}
{/if}
{#if hasOverflow(response.personaId)}
{ // In multi-card view, "Show more" enters focus mode // "Show less" collapses all and exits focus !isExpanded && hasMultipleCards ? setFocus(response.personaId) : toggleExpanded(response.personaId); }} class="mt-3 flex w-full items-center justify-center gap-1 rounded-md border border-gray-200 bg-gray-50 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700" > {#if isExpanded}
Show less
{:else}
Show more
{/if}
{/if}
{/if} {/each}
{#if !isPersonaMode && (!isLast || !loading) && onbranch && personaName} {@const branchCount = personaBranches.length} {@const hasExistingBranches = branchCount > 0}
{#if hasExistingBranches}
({branchCount})
{/if}
{/if}
{#if message.routerMetadata && (!isLast || !loading)}
{message.routerMetadata.route}
with
{#if publicConfig.isHuggingChat}
{message.routerMetadata.model.split("/").pop()}
{:else}
{message.routerMetadata.model.split("/").pop()}
{/if}
{#if alternatives.length > 1 && editMsdgId === null}
onshowAlternateMsg?.(payload)} /> {/if}
{/if}
{/if} {#if message.from === "user"}
(isTapped = !isTapped)} onkeydown={() => (isTapped = !isTapped)} >
{#if message.files?.length}
{#each message.files as file}
{/each}
{/if}
{#if !editMode}
{message.content.trim()}
{:else}
{ e.preventDefault(); onretry?.({ content: editContentEl?.value, id: message.id }); editMsdgId = null; }} >
Send
{ editMsdgId = null; }} > Cancel
{/if}
{#if alternatives.length > 1 && editMsdgId === null}
onshowAlternateMsg?.(payload)} /> {/if} {#if (alternatives.length > 1 && editMsdgId === null) || (!loading && !editMode)}
(editMsdgId = message.id)} >
Edit
{/if}
{/if}