Merge branch 'main' into luoling8192/feat/floating-character-rail

This commit is contained in:
RainbowBird 2026-11-23 21:24:27 +08:00 • committed by GitHub
commit dde320b90a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 54 additions and 226 deletions

View file

@ -279,10 +279,8 @@ chat:
done-selecting: Done
delete-selected: Delete {count}
confirm-delete-selected: Confirm delete {count}
all: All
all-conversations: All conversations
switch-place: Switch view
filter-by-character: Filter by character
unknown-character: Unknown character
pinned: Pinned
folders: Folders
@ -297,8 +295,6 @@ chat:
new-folder: New folder
create-folder: Create
new-in-folder: New conversation in {folder}
new-with-character: New conversation with {name}
new-in-folder-with-character: New conversation with {name} in {folder}
folder-name: Folder name
folder-name-placeholder: Enter a folder name
save-folder: Save folder
@ -309,10 +305,7 @@ chat:
confirm-delete-folder: Confirm delete folder
selected: '{count} selected'
empty-folder: '{folder} is empty. Use the button above to start a conversation here, or choose Move to folder in the menu of a conversation.'
empty-folder-character: '{folder} has no conversations with {name} yet. Use the button above to start one.'
empty-archive: No archived conversations. Archived conversations stay here.
empty-archive-character: No archived conversations with {name}. Archived conversations stay here.
empty-character: No conversations with {name} yet. Use the button above to start the first one.
save-failed: The change could not be saved
avatar-model-missing:
title: No model selected

View file

@ -285,10 +285,8 @@ chat:
done-selecting: 完成
delete-selected: 删除 {count} 个对话
confirm-delete-selected: 确认删除 {count} 个对话
all: 全部
all-conversations: 全部对话
switch-place: 切换位置
filter-by-character: 按角色筛选
unknown-character: 未知角色
pinned: 置顶
folders: 文件夹
@ -303,8 +301,6 @@ chat:
new-folder: 新建文件夹
create-folder: 创建
new-in-folder: 在“{folder}”新建对话
new-with-character: 新建 {name} 的对话
new-in-folder-with-character: 在“{folder}”新建 {name} 的对话
folder-name: 文件夹名称
folder-name-placeholder: 输入文件夹名称
save-folder: 保存文件夹
@ -315,10 +311,7 @@ chat:
confirm-delete-folder: 确认删除文件夹
selected: 已选 {count} 个
empty-folder: “{folder}”还是空的。点上面的按钮新建,或在对话的菜单里选“移到文件夹”。
empty-folder-character: “{folder}”里还没有和 {name} 的对话。点上面的按钮开始。
empty-archive: 没有归档的对话。归档的对话放在这里。
empty-archive-character: 没有和 {name} 的归档对话。归档的对话放在这里。
empty-character: 还没有和 {name} 的对话。点上面的按钮开始第一段。
save-failed: 这次修改没能保存
avatar-model-missing:
title: 还没有选择模型

View file

@ -85,7 +85,6 @@ function createHarness(rows = [
:open="true"
:rows="rows"
:folders="[]"
:characters="[]"
:is-desktop="isDesktop"
:is-creating-session="false"
@new-session="created += 1"
@ -115,7 +114,6 @@ describe('sessions dialog actions', () => {
v-model:open="open"
:rows="rows"
:folders="[]"
:characters="[]"
:is-desktop="true"
:is-creating-session="false"
desktop-mode="popover"
@ -150,7 +148,6 @@ describe('sessions dialog actions', () => {
v-model:open="open"
:rows="rows"
:folders="[]"
:characters="[]"
:is-desktop="true"
:is-creating-session="false"
desktop-mode="popover"

View file

@ -12,7 +12,6 @@ import SessionsList from './sessions-list.vue'
const props = withDefaults(defineProps<{
open: boolean
rows: SessionRow[]
characters: Array<{ id: string, name: string, preview?: string }>
folders: readonly ChatSessionFolder[]
isDesktop: boolean
isCreatingSession: boolean
@ -24,7 +23,7 @@ const props = withDefaults(defineProps<{
const emit = defineEmits<{
'deleteSession': [sessionId: string]
'deleteSessions': [sessionIds: string[]]
'newSession': [payload: { folderId?: string, characterId?: string }]
'newSession': [payload: { folderId?: string }]
'renameSession': [payload: { sessionId: string, title: string }]
'selectSession': [sessionId: string]
'pinSession': [payload: { sessionId: string, pinned: boolean }]
@ -36,9 +35,8 @@ const emit = defineEmits<{
'update:open': [open: boolean]
}>()
/** The place and the character of the list. The owner can keep them, so the list opens where the user left it. */
/** The place of the list. The owner can keep it, so the list opens where the user left it. */
const place = defineModel<ChatSessionsPlace>('place', { default: () => ({ kind: 'all' }) })
const characterId = defineModel<string>('characterId')
const { t } = useI18n()
// Every open starts outside selection mode, so a closed list never keeps a selection.
@ -69,9 +67,7 @@ function preserveTriggerFocus(event: Event) {
<SessionsList
v-model:selecting="selecting"
v-model:place="place"
v-model:character-id="characterId"
:rows="rows"
:characters="characters"
:folders="folders"
:is-creating-session="isCreatingSession"
@new-session="emit('newSession', $event)"
@ -105,10 +101,8 @@ function preserveTriggerFocus(event: Event) {
<SessionsList
v-model:selecting="selecting"
v-model:place="place"
v-model:character-id="characterId"
compact
:rows="rows"
:characters="characters"
:folders="folders"
:is-creating-session="isCreatingSession"
@new-session="emit('newSession', $event)"
@ -147,9 +141,7 @@ function preserveTriggerFocus(event: Event) {
<SessionsList
v-model:selecting="selecting"
v-model:place="place"
v-model:character-id="characterId"
:rows="rows"
:characters="characters"
:folders="folders"
:is-creating-session="isCreatingSession"
@new-session="emit('newSession', $event)"

View file

@ -114,6 +114,9 @@ describe('sessions drawer orchestration', () => {
chatSession.sessionMessages['session-b'] = [
{ id: 'b', role: 'user', content: 'Earlier', createdAt: now - 14_400_000 },
]
// The list shows the current character only. A chat with another character stays out of it.
chatSession.sessionMetas['session-other'] = { ...sessionMeta('session-other', 'Chat of another character', 4), characterId: 'other' }
chatSession.sessionMessages['session-other'] = []
vi.spyOn(chatSession, 'loadSession').mockResolvedValue(true)
await screen.rerender({ modelValue: true })
await expect.element(screen.getByRole('button', { name: /^Chat A/ })).toHaveTextContent('2 hours ago')
@ -154,6 +157,9 @@ describe('sessions drawer orchestration', () => {
{ id: 'undated', role: 'user', content: 'No date' },
{ id: 'invalid', role: 'user', content: 'Invalid date', createdAt: Number.NaN },
]
// The list shows the current character only. A chat with another character stays out of it.
chatSession.sessionMetas['session-other'] = { ...sessionMeta('session-other', 'Chat of another character', 4), characterId: 'other' }
chatSession.sessionMessages['session-other'] = []
vi.spyOn(chatSession, 'loadSession').mockResolvedValue(true)
await screen.rerender({ modelValue: true })
await expect.element(screen.getByRole('button', { name: /^Chat A/ })).toHaveTextContent('2 hours ago')

View file

@ -42,8 +42,8 @@ const chatSession = useChatSessionStore()
const chat = useChatStore()
const { sessionMetas, sessionMessages, activeSessionId, index } = storeToRefs(chatSession)
const { activeCardId, cards } = storeToRefs(useAiriCardStore())
// The list keeps its place and filter in memory, so a closed and reopened list shows them again.
const { place: listPlace, characterId: listCharacterId } = storeToRefs(useChatSessionsViewStore())
// The list keeps its place in memory, so a closed and reopened list shows it again.
const { place: listPlace } = storeToRefs(useChatSessionsViewStore())
const characterPreviews = useCharacterPreviews()
const { userId } = storeToRefs(useAuthStore())
const { activeModel } = storeToRefs(useConsciousnessStore())
@ -55,10 +55,13 @@ const isCreatingSession = ref(false)
const effectiveUserId = computed(() => userId.value || 'local')
const currentCharacterId = computed(() => activeCardId.value || 'default')
// The list shows the conversations of the current character only. The user changes the character to see the others.
// Keep another account's sessions hidden while an account swap rehydrates.
// Background recipe sessions are hidden too. Their results reach the conversation as notices.
const ownedSessions = computed(() => Object.values(sessionMetas.value)
.filter(meta => meta.userId === effectiveUserId.value && !meta.hidden))
.filter(meta => meta.userId === effectiveUserId.value && !meta.hidden && chatSession.characterMembersOf(meta.sessionId).includes(currentCharacterId.value)))
/**
* Normalizes a session into its one-line drawer preview.
@ -124,9 +127,6 @@ const rows = computed<SessionRow[]>(() => {
}))
})
/** Every character card, so the filter can pick a character that has no conversation yet. */
const characters = computed(() => [...cards.value].map(([id, card]) => ({ id, name: card.name, preview: characterPreviews.value.get(id) })))
/**
* Runs an action of the list and explains a failure with a toast, as the other chat controls do. The list keeps its
* state, so the user can try again.
@ -154,15 +154,15 @@ async function selectSession(sessionId: string) {
}
/**
* Creates a conversation and opens it. Without a character ID, it belongs to the active character.
* Creates a conversation with the current character and opens it.
* A folder ID puts the conversation into that folder.
*/
async function startNewSession(payload: { folderId?: string, characterId?: string }) {
async function startNewSession(payload: { folderId?: string }) {
if (isCreatingSession.value)
return
isCreatingSession.value = true
try {
const characterId = payload.characterId ?? (activeCardId.value || 'default')
const characterId = currentCharacterId.value
const selectionBeforeCreation = activeSessionId.value
// Creation runs in the synchronized leader, while navigation belongs to
// this window. Activating inside createSession would navigate the leader.
@ -252,9 +252,7 @@ watch(showDialog, async (open) => {
<SessionsDialog
v-model:open="showDialog"
v-model:place="listPlace"
v-model:character-id="listCharacterId"
:rows="rows"
:characters="characters"
:folders="folders"
:is-desktop="isDesktop"
:is-creating-session="isCreatingSession"

View file

@ -16,30 +16,24 @@ const folders: ChatSessionFolder[] = [
{ id: 'work', name: 'Work', createdAt: CREATED_AT + 1 },
]
const characters = [
{ id: 'airi', name: 'AIRI' },
{ id: 'mira', name: 'Mira' },
{ id: 'nova', name: 'Nova' },
]
function rowOf(sessionId: string, title: string, characterId: string, details: Partial<ChatSessionMeta> & { label: string, isActive?: boolean }): SessionRow {
function rowOf(sessionId: string, title: string, details: Partial<ChatSessionMeta> & { label: string, isActive?: boolean }): SessionRow {
const { label, isActive = false, ...meta } = details
return {
meta: { sessionId, userId: 'local', characterId, title, createdAt: CREATED_AT, updatedAt: CREATED_AT, ...meta },
meta: { sessionId, userId: 'local', characterId: 'airi', title, createdAt: CREATED_AT, updatedAt: CREATED_AT, ...meta },
preview: title,
isActive,
activityAtLabel: label,
characterName: characters.find(character => character.id === characterId)?.name ?? 'Unknown character',
characterName: 'AIRI',
}
}
const rows: SessionRow[] = [
rowOf('weekend', 'Weekend trip ideas', 'airi', { label: '2 minutes ago', isActive: true, folderId: 'trips' }),
rowOf('book', 'Notes on the new book', 'airi', { label: '1 hour ago', pinnedAt: CREATED_AT }),
rowOf('review', 'Review a pull request', 'mira', { label: '3 hours ago', folderId: 'work', cloudChatId: 'cloud-review' }),
rowOf('bug', 'Draft a bug report', 'mira', { label: 'yesterday', folderId: 'work' }),
rowOf('groceries', 'Grocery list for the week', 'airi', { label: '2 days ago' }),
rowOf('intro', 'Practice a self-introduction', 'mira', { label: 'last week', archivedAt: CREATED_AT }),
rowOf('weekend', 'Weekend trip ideas', { label: '2 minutes ago', isActive: true, folderId: 'trips' }),
rowOf('book', 'Notes on the new book', { label: '1 hour ago', pinnedAt: CREATED_AT }),
rowOf('review', 'Review a pull request', { label: '3 hours ago', folderId: 'work', cloudChatId: 'cloud-review' }),
rowOf('bug', 'Draft a bug report', { label: 'yesterday', folderId: 'work' }),
rowOf('groceries', 'Grocery list for the week', { label: '2 days ago' }),
rowOf('intro', 'Practice a self-introduction', { label: 'last week', archivedAt: CREATED_AT }),
]
const popoverPlace = ref<ChatSessionsPlace>({ kind: 'all' })
@ -47,34 +41,33 @@ const drawerPlace = ref<ChatSessionsPlace>({ kind: 'all' })
const folderPlace = ref<ChatSessionsPlace>({ kind: 'folder', folderId: 'work' })
const archivePlace = ref<ChatSessionsPlace>({ kind: 'archive' })
const emptyPlace = ref<ChatSessionsPlace>({ kind: 'all' })
const filteredCharacter = ref<string | undefined>('mira')
</script>
<template>
<Story title="Conversation List" group="chat">
<Variant id="popover" title="Popover">
<div :class="['w-88 rounded-xl bg-white p-2 dark:bg-neutral-900']">
<SessionsList v-model:place="popoverPlace" compact :rows="rows" :characters="characters" :folders="folders" :is-creating-session="false" />
<SessionsList v-model:place="popoverPlace" compact :rows="rows" :folders="folders" :is-creating-session="false" />
</div>
</Variant>
<Variant id="drawer" title="Drawer">
<div :class="['max-w-lg bg-neutral-50 p-5 dark:bg-neutral-900']">
<SessionsList v-model:place="drawerPlace" :rows="rows" :characters="characters" :folders="folders" :is-creating-session="false" />
<SessionsList v-model:place="drawerPlace" :rows="rows" :folders="folders" :is-creating-session="false" />
</div>
</Variant>
<Variant id="folder-and-character" title="Folder with a character filter">
<Variant id="folder" title="Folder">
<div :class="['max-w-lg bg-neutral-50 p-5 dark:bg-neutral-900']">
<SessionsList v-model:place="folderPlace" v-model:character-id="filteredCharacter" :rows="rows" :characters="characters" :folders="folders" :is-creating-session="false" />
<SessionsList v-model:place="folderPlace" :rows="rows" :folders="folders" :is-creating-session="false" />
</div>
</Variant>
<Variant id="archive" title="Archive">
<div :class="['max-w-lg bg-neutral-50 p-5 dark:bg-neutral-900']">
<SessionsList v-model:place="archivePlace" :rows="rows" :characters="characters" :folders="folders" :is-creating-session="false" />
<SessionsList v-model:place="archivePlace" :rows="rows" :folders="folders" :is-creating-session="false" />
</div>
</Variant>
<Variant id="empty" title="No conversations">
<div :class="['max-w-lg bg-neutral-50 p-5 dark:bg-neutral-900']">
<SessionsList v-model:place="emptyPlace" :rows="[]" :characters="characters" :folders="[]" :is-creating-session="false" />
<SessionsList v-model:place="emptyPlace" :rows="[]" :folders="[]" :is-creating-session="false" />
</div>
</Variant>
<Variant id="row-states" title="Row states">

View file

@ -2,9 +2,9 @@
import type { ChatSessionFolder, ChatSessionsPlace } from '../../../../types/chat-session'
import type { SessionRow } from './session-row-model'
import { AnimatedHeight, Avatar, BasicButton, Button, DropdownMenu, GhostButton, ScrollableArea } from '@proj-airi/ui'
import { useEventListener, usePreferredReducedMotion, useResizeObserver, useScroll } from '@vueuse/core'
import { computed, nextTick, onMounted, shallowRef, useTemplateRef, watch } from 'vue'
import { AnimatedHeight, BasicButton, Button, DropdownMenu, GhostButton, ScrollableArea } from '@proj-airi/ui'
import { useEventListener, useResizeObserver } from '@vueuse/core'
import { computed, shallowRef, useTemplateRef, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import SessionFolderTargets from './session-folder-targets.vue'
@ -14,10 +14,8 @@ import SessionsListHeader from './sessions-list-header.vue'
import { useListReorderMotion } from '../composables/use-list-reorder-motion'
const props = withDefaults(defineProps<{
/** Every conversation of the user, archived ones included. */
/** Every conversation of the user with the current character, archived ones included. */
rows: SessionRow[]
/** Every character of the user. The filter offers each one, also one without conversations, so a first conversation can go to it. */
characters: Array<{ id: string, name: string, preview?: string }>
folders: readonly ChatSessionFolder[]
isCreatingSession: boolean
/** The desktop popover. Rows are denser, and the list keeps a fixed maximum height. */
@ -29,8 +27,8 @@ const props = withDefaults(defineProps<{
const emit = defineEmits<{
deleteSession: [sessionId: string]
deleteSessions: [sessionIds: string[]]
/** Creates a conversation in the folder and for the character of the payload. Each one left out uses the default. */
newSession: [payload: { folderId?: string, characterId?: string }]
/** Creates a conversation with the current character. A folder ID puts it into that folder. */
newSession: [payload: { folderId?: string }]
renameSession: [payload: { sessionId: string, title: string }]
selectSession: [sessionId: string]
pinSession: [payload: { sessionId: string, pinned: boolean }]
@ -49,8 +47,6 @@ const { t } = useI18n()
* The place that the user chose. The owner can keep it after the list closes, so the list opens where the user left it.
*/
const chosenPlace = defineModel<ChatSessionsPlace>('place', { default: () => ({ kind: 'all' }) })
/** The character that the user chose for the filter. `undefined` shows every character. The owner can keep it too. */
const chosenCharacterId = defineModel<string>('characterId')
// The swipe area that is open belongs to this open list, never to persisted session state.
const expandedSessionId = shallowRef<string>()
/** The compact row that waits for the second press on its delete button. */
@ -63,8 +59,6 @@ const confirmingBatchDelete = shallowRef(false)
const confirmingFolderDelete = shallowRef(false)
const batchMoveOpen = shallowRef(false)
const chips = useTemplateRef<HTMLElement>('chips')
/** The chosen folder. It is missing when this list or another window deleted it. */
const currentFolder = computed(() => {
const chosen = chosenPlace.value
@ -85,39 +79,18 @@ const folderCounts = computed(() => {
return counts
})
/** The conversations of the current place, before the character filter. */
const placeRows = computed(() => {
const current = place.value
if (current.kind === 'archive')
return props.rows.filter(row => row.meta.archivedAt !== undefined)
if (current.kind === 'folder')
return liveRows.value.filter(row => row.meta.folderId === current.folderId)
return liveRows.value
})
/** Every character with the number of its conversations in the current place. */
const characterChips = computed(() => {
const counts = new Map<string, number>()
for (const row of placeRows.value)
counts.set(row.meta.characterId, (counts.get(row.meta.characterId) ?? 0) + 1)
return props.characters.map(character => ({ ...character, count: counts.get(character.id) ?? 0 }))
})
/**
* The character that the filter applies. A new conversation goes to it, and the empty state and the primary action
* name it. A chosen character that no longer exists applies no filter.
*/
const filteredCharacter = computed(() => characterChips.value.find(chip => chip.id === chosenCharacterId.value))
const characterFilter = computed(() => filteredCharacter.value?.id)
/** The rows that the list shows. Pinned conversations come first, and the rows already arrive in the order of their last message. */
const visibleRows = computed(() => {
const rows = placeRows.value.filter(row => characterFilter.value === undefined || row.meta.characterId === characterFilter.value)
const current = place.value
let rows = liveRows.value
if (current.kind === 'archive')
rows = props.rows.filter(row => row.meta.archivedAt !== undefined)
else if (current.kind === 'folder')
rows = liveRows.value.filter(row => row.meta.folderId === current.folderId)
return [...rows].sort((first, second) => Number(!!second.meta.pinnedAt) - Number(!!first.meta.pinnedAt))
})
// The selection survives a change of place or character. Only the rows that the list shows count and take a batch action.
// The selection survives a change of place. Only the rows that the list shows count and take a batch action.
const selectedRows = computed(() => visibleRows.value.filter(row => selectedIds.value.has(row.meta.sessionId)))
const allSelected = computed(() => visibleRows.value.length > 0 && selectedRows.value.length === visibleRows.value.length)
/** The folder that every selected conversation is in. The batch menu marks it, also in all conversations and the archive. */
@ -187,26 +160,11 @@ const actionButtons = computed(() => {
})
const emptyState = computed(() => {
const name = filteredCharacter.value?.name
if (place.value.kind === 'archive') {
return {
icon: 'i-mingcute:archive-line',
text: name === undefined ? t('stage.chat.sessions.empty-archive') : t('stage.chat.sessions.empty-archive-character', { name }),
}
}
if (place.value.kind === 'folder') {
const folder = currentFolder.value?.name ?? ''
return {
icon: 'i-mingcute:folder-line',
text: name === undefined
? t('stage.chat.sessions.empty-folder', { folder })
: t('stage.chat.sessions.empty-folder-character', { folder, name }),
}
}
return {
icon: 'i-mingcute:chat-1-line',
text: name === undefined ? t('stage.chat.sessions.empty') : t('stage.chat.sessions.empty-character', { name }),
}
if (place.value.kind === 'archive')
return { icon: 'i-mingcute:archive-line', text: t('stage.chat.sessions.empty-archive') }
if (place.value.kind === 'folder')
return { icon: 'i-mingcute:folder-line', text: t('stage.chat.sessions.empty-folder', { folder: currentFolder.value?.name ?? '' }) }
return { icon: 'i-mingcute:chat-1-line', text: t('stage.chat.sessions.empty') }
})
watch(selectedIds, () => {
@ -222,7 +180,7 @@ watch(selecting, (value) => {
}
})
watch([place, characterFilter], () => {
watch(place, () => {
expandedSessionId.value = undefined
pendingDeleteSessionId.value = undefined
confirmingBatchDelete.value = false
@ -261,18 +219,12 @@ function toggleAllSelected() {
function newSessionLabel() {
const folder = currentFolder.value?.name
const name = filteredCharacter.value?.name
if (folder !== undefined) {
return name === undefined
? t('stage.chat.sessions.new-in-folder', { folder })
: t('stage.chat.sessions.new-in-folder-with-character', { folder, name })
}
return name === undefined ? t('stage.chat.sessions.new') : t('stage.chat.sessions.new-with-character', { name })
return folder === undefined ? t('stage.chat.sessions.new') : t('stage.chat.sessions.new-in-folder', { folder })
}
function runPrimaryAction() {
if (!selecting.value) {
emit('newSession', { folderId: currentFolder.value?.id, characterId: characterFilter.value })
emit('newSession', { folderId: currentFolder.value?.id })
return
}
const sessionIds = selectedRows.value.map(row => row.meta.sessionId)
@ -412,46 +364,6 @@ const { holdLeavingItem } = useListReorderMotion({
keyOf: item => item.dataset.sessionKey,
leaveActiveClass: 'session-item-leave-active',
})
// The character row scrolls sideways. A faded edge shows that more characters are there.
const { arrivedState, measure: measureChips } = useScroll(chips)
const chipsFade = computed(() => {
const start = !arrivedState.left
const end = !arrivedState.right
if (start && end)
return 'session-chips--fade-both'
if (start)
return 'session-chips--fade-start'
if (end)
return 'session-chips--fade-end'
return undefined
})
useResizeObserver(chips, () => measureChips())
onMounted(() => measureChips())
const reducedMotion = usePreferredReducedMotion()
watch([characterChips, characterFilter], async () => {
await nextTick()
measureChips()
chips.value?.querySelector('[aria-pressed="true"]')?.scrollIntoView({
block: 'nearest',
inline: 'nearest',
behavior: reducedMotion.value === 'reduce' ? 'auto' : 'smooth',
})
})
function chipClasses(pressed: boolean) {
return [
'shrink-0 inline-flex items-center gap-1.5 rounded-full active:scale-95',
'transition-[color,background-color,transform] duration-200 motion-reduce:transition-none',
'focus-visible:outline-2 focus-visible:outline-primary-500',
props.compact ? 'h-7 text-xs' : 'h-8 text-sm',
pressed
? 'bg-primary-100 font-semibold text-primary-700 dark:bg-primary-900/60 dark:text-primary-200'
: 'bg-neutral-100 text-neutral-600 hover:bg-neutral-200/80 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700/80',
]
}
</script>
<template>
@ -521,43 +433,6 @@ function chipClasses(pressed: boolean) {
</component>
</div>
<!-- The character filter stays while selecting, so a selection can be made one character at a time. -->
<div
ref="chips"
role="group"
:aria-label="t('stage.chat.sessions.filter-by-character')"
:class="['session-chips flex shrink-0 gap-1.5 overflow-x-auto scroll-px-6 p-0.5', props.compact ? 'mt-1' : 'mt-2.5', chipsFade]"
>
<button
type="button"
:aria-pressed="characterFilter === undefined"
:class="[chipClasses(characterFilter === undefined), props.compact ? 'px-2.5' : 'px-3']"
@click="chosenCharacterId = undefined"
>
{{ t('stage.chat.sessions.all') }}
<span :class="['tabular-nums opacity-60']">{{ placeRows.length }}</span>
</button>
<button
v-for="chip in characterChips"
:key="chip.id"
type="button"
:aria-pressed="characterFilter === chip.id"
:class="[chipClasses(characterFilter === chip.id), props.compact ? 'pl-1 pr-2.5' : 'pl-1 pr-3']"
@click="chosenCharacterId = characterFilter === chip.id ? undefined : chip.id"
>
<Avatar
:src="chip.preview"
:class="[props.compact ? 'size-5' : 'size-6', 'block shrink-0 rounded-full bg-white text-neutral-400 dark:bg-neutral-700', '[&_[data-avatar-image]]:object-top']"
>
<template #fallback>
<span aria-hidden="true" :class="['i-mingcute:user-3-line size-3.5']" />
</template>
</Avatar>
<span :class="['max-w-24 truncate']">{{ chip.name }}</span>
<span :class="['tabular-nums opacity-60']">{{ chip.count }}</span>
</button>
</div>
<div v-if="props.compact" :class="['mb-1 mt-1.5 h-px shrink-0 bg-neutral-200/70 dark:bg-neutral-700/70']" />
<!--
The list grows with its rows until its surface reaches the maximum height of the surface. `AnimatedHeight` is the
@ -677,22 +552,6 @@ function chipClasses(pressed: boolean) {
justify-content: flex-start;
}
.session-chips {
scrollbar-width: none;
}
.session-chips::-webkit-scrollbar {
display: none;
}
.session-chips--fade-start {
mask-image: linear-gradient(to right, transparent, #000 1.75rem);
}
.session-chips--fade-end {
mask-image: linear-gradient(to right, #000 calc(100% - 1.75rem), transparent);
}
.session-chips--fade-both {
mask-image: linear-gradient(to right, transparent, #000 1.75rem, #000 calc(100% - 1.75rem), transparent);
}
.session-action-swap-enter-active,
.session-action-swap-leave-active {
transition: opacity 120ms ease, transform 120ms ease;

View file

@ -4,18 +4,15 @@ import { defineStore } from 'pinia'
import { shallowRef } from 'vue'
/**
* The view of the conversation list: the place and the character of the filter that the user chose.
* The view of the conversation list: the place that the user chose.
*
* The list closes with its drawer or popover. This store keeps the view while the window lives, so the list opens again
* where the user left it. The view stays in memory and is not saved.
*/
export const useChatSessionsViewStore = defineStore('chat-sessions-view', () => {
const place = shallowRef<ChatSessionsPlace>({ kind: 'all' })
/** `undefined` shows every character. */
const characterId = shallowRef<string>()
return {
place,
characterId,
}
})