feat: add independent conversation branching
Local conversations can now continue in a new branch after stable content is persisted. Each branch uses new conversation and message IDs, keeps its source visible, and remains independent without copying Tasks, queue items, runs, memories, or artifact ownership. Conversation Task rows are also denser, align status markers at the right edge, and use an accessible checked success marker without redundant completion text. Release note: 本地会话现在可从“在新会话中继续”创建独立分支并显示来源;Task 子项布局更紧凑,状态统一显示在右侧。
This commit is contained in:
@@ -377,6 +377,16 @@ const api: DesktopApi = {
|
||||
list: vi.fn(async () => []),
|
||||
replace: vi.fn(async () => {}),
|
||||
saveLocal: vi.fn(async () => {}),
|
||||
branchLocal: vi.fn(async (input) => ({
|
||||
id: crypto.randomUUID(),
|
||||
branch: {
|
||||
sourceConversationId: input.sourceConversationId,
|
||||
sourceTitle: '新对话'
|
||||
},
|
||||
title: input.title,
|
||||
updatedAt: Date.now(),
|
||||
messages: []
|
||||
})),
|
||||
deleteLocal: vi.fn(async () => true),
|
||||
onChanged: vi.fn(() => () => undefined)
|
||||
},
|
||||
@@ -867,6 +877,18 @@ describe('App', () => {
|
||||
vi.mocked(api.conversations.saveLocal)
|
||||
.mockReset()
|
||||
.mockResolvedValue()
|
||||
vi.mocked(api.conversations.branchLocal)
|
||||
.mockReset()
|
||||
.mockImplementation(async (input) => ({
|
||||
id: crypto.randomUUID(),
|
||||
branch: {
|
||||
sourceConversationId: input.sourceConversationId,
|
||||
sourceTitle: '新对话'
|
||||
},
|
||||
title: input.title,
|
||||
updatedAt: Date.now(),
|
||||
messages: []
|
||||
}))
|
||||
vi.mocked(api.conversations.deleteLocal)
|
||||
.mockReset()
|
||||
.mockResolvedValue(true)
|
||||
@@ -1404,9 +1426,11 @@ describe('App', () => {
|
||||
expect(within(taskRegion).getByText('Execute')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('uses shared status dots for Conversation Task children', async () => {
|
||||
it('keeps completed Conversation Task metadata compact and accessible', async () => {
|
||||
const conversationId =
|
||||
'00000000-0000-4000-8000-000000000824'
|
||||
const scheduleId =
|
||||
'00000000-0000-4000-8000-000000000828'
|
||||
const conversation: ConversationSnapshot = {
|
||||
id: conversationId,
|
||||
projectId,
|
||||
@@ -1419,7 +1443,8 @@ describe('App', () => {
|
||||
id: '00000000-0000-4000-8000-000000000825',
|
||||
projectId,
|
||||
conversationId,
|
||||
title: '已完成任务',
|
||||
scheduleId,
|
||||
title: '归档任务',
|
||||
instructions: '检查完成状态',
|
||||
origin: 'schedule',
|
||||
status: 'completed',
|
||||
@@ -1446,10 +1471,25 @@ describe('App', () => {
|
||||
createdAt: '2026-08-19T01:00:00.000Z'
|
||||
}
|
||||
]
|
||||
const schedule: AssistantSchedule = {
|
||||
id: scheduleId,
|
||||
projectId,
|
||||
taskId: tasks[0]!.id,
|
||||
conversationId,
|
||||
title: tasks[0]!.title,
|
||||
prompt: tasks[0]!.instructions,
|
||||
workMode: 'ask',
|
||||
recurrence: 'once',
|
||||
nextRunAt: '2026-08-19T03:00:00.000Z',
|
||||
enabled: false,
|
||||
createdAt: tasks[0]!.createdAt,
|
||||
updatedAt: tasks[0]!.createdAt
|
||||
}
|
||||
vi.mocked(api.conversations.list).mockResolvedValue([
|
||||
conversation
|
||||
])
|
||||
vi.mocked(api.tasks.list).mockResolvedValue(tasks)
|
||||
vi.mocked(api.schedules.list).mockResolvedValue([schedule])
|
||||
|
||||
render(<App />)
|
||||
|
||||
@@ -1458,8 +1498,32 @@ describe('App', () => {
|
||||
'展开或折叠“任务状态会话”中的 3 个任务'
|
||||
)
|
||||
)
|
||||
const completedTitle = await screen.findByText('归档任务', {
|
||||
selector: '.conversation-task-child__title'
|
||||
})
|
||||
const completedTask = completedTitle.closest('button')
|
||||
const completedStatus = completedTask?.querySelector(
|
||||
'.conversation-task-child__completed-status'
|
||||
)
|
||||
expect(completedStatus).toHaveClass(
|
||||
'task-status-dot',
|
||||
'task-status-dot--completed'
|
||||
)
|
||||
expect(completedStatus).toHaveAttribute('title', '已完成')
|
||||
expect(
|
||||
completedStatus?.querySelector('.lucide-check')
|
||||
).toBeInTheDocument()
|
||||
expect(completedTask?.firstElementChild).toBe(completedTitle)
|
||||
expect(completedTask?.lastElementChild).toBe(completedStatus)
|
||||
expect(completedTask).toHaveAccessibleName(/已完成/u)
|
||||
expect(
|
||||
completedTask?.querySelector('.conversation-task-child__meta')
|
||||
).toHaveTextContent('Ask · 仅一次')
|
||||
expect(
|
||||
completedTask?.querySelector('.conversation-task-child__meta')
|
||||
).not.toHaveTextContent('已完成')
|
||||
|
||||
for (const [title, status, label] of [
|
||||
['已完成任务', 'completed', '已完成'],
|
||||
['运行中任务', 'running', '运行中'],
|
||||
['失败任务', 'failed', '失败']
|
||||
] as const) {
|
||||
@@ -1470,6 +1534,10 @@ describe('App', () => {
|
||||
expect(
|
||||
taskChild?.querySelector('.task-status-dot')
|
||||
).toHaveClass(`task-status-dot--${status}`)
|
||||
expect(taskChild?.firstElementChild).toBe(taskTitle)
|
||||
expect(taskChild?.lastElementChild).toBe(
|
||||
taskChild?.querySelector('.task-status-dot')
|
||||
)
|
||||
expect(
|
||||
taskChild?.querySelector('.conversation-task-child__meta')
|
||||
).toHaveTextContent(label)
|
||||
@@ -2172,6 +2240,242 @@ describe('App', () => {
|
||||
expect(await screen.findByRole('status')).toBeVisible()
|
||||
})
|
||||
|
||||
it('flushes and opens an independent conversation branch with provenance badges', async () => {
|
||||
const sourceConversationId =
|
||||
'00000000-0000-4000-8000-000000000421'
|
||||
const branchConversationId =
|
||||
'00000000-0000-4000-8000-000000000422'
|
||||
const sourceConversation: ConversationSnapshot = {
|
||||
id: sourceConversationId,
|
||||
projectId,
|
||||
title: '方案讨论',
|
||||
updatedAt: 1_775_000_000_000,
|
||||
messages: [
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000423',
|
||||
role: 'user',
|
||||
content: '探索不同发布方案',
|
||||
createdAt: 1_775_000_000_000,
|
||||
state: 'complete'
|
||||
},
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000424',
|
||||
role: 'assistant',
|
||||
content: '可以比较风险、成本和回滚路径。',
|
||||
createdAt: 1_775_000_001_000,
|
||||
state: 'complete'
|
||||
}
|
||||
]
|
||||
}
|
||||
vi.mocked(api.conversations.list).mockResolvedValueOnce([
|
||||
sourceConversation
|
||||
])
|
||||
vi.mocked(api.conversations.branchLocal).mockImplementationOnce(
|
||||
async (input) => ({
|
||||
...sourceConversation,
|
||||
id: branchConversationId,
|
||||
branch: {
|
||||
sourceConversationId,
|
||||
sourceTitle: '方案讨论更新'
|
||||
},
|
||||
contextMetrics: undefined,
|
||||
contextCompressionState: undefined,
|
||||
title: input.title,
|
||||
updatedAt: 1_775_000_002_000,
|
||||
messages: sourceConversation.messages.map((message, index) => ({
|
||||
...message,
|
||||
id: `00000000-0000-4000-8000-${String(
|
||||
430 + index
|
||||
).padStart(12, '0')}`
|
||||
}))
|
||||
})
|
||||
)
|
||||
const { container } = render(<App />)
|
||||
expect(
|
||||
await screen.findByText('探索不同发布方案')
|
||||
).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(
|
||||
await screen.findByLabelText('更多会话操作 方案讨论')
|
||||
)
|
||||
fireEvent.click(
|
||||
screen.getByRole('button', { name: '重命名会话' })
|
||||
)
|
||||
const renameInput = screen.getByLabelText('重命名会话 方案讨论')
|
||||
fireEvent.change(renameInput, {
|
||||
target: { value: '方案讨论更新' }
|
||||
})
|
||||
fireEvent.submit(renameInput.closest('form')!)
|
||||
expect(
|
||||
await screen.findAllByText('方案讨论更新')
|
||||
).toHaveLength(2)
|
||||
vi.mocked(api.conversations.saveLocal).mockClear()
|
||||
|
||||
fireEvent.click(
|
||||
screen.getByLabelText('更多会话操作 方案讨论更新')
|
||||
)
|
||||
const branchButton = screen.getByRole('button', {
|
||||
name: '在新会话中继续'
|
||||
})
|
||||
await waitFor(() => expect(branchButton).toBeEnabled())
|
||||
fireEvent.click(branchButton)
|
||||
|
||||
await waitFor(() =>
|
||||
expect(api.conversations.saveLocal).toHaveBeenCalledWith([
|
||||
expect.objectContaining({
|
||||
header: expect.objectContaining({
|
||||
id: sourceConversationId,
|
||||
title: '方案讨论更新'
|
||||
})
|
||||
})
|
||||
])
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(api.conversations.branchLocal).toHaveBeenCalledWith({
|
||||
sourceConversationId,
|
||||
title: '方案讨论更新 · 分支'
|
||||
})
|
||||
)
|
||||
expect(
|
||||
vi.mocked(api.conversations.saveLocal).mock.invocationCallOrder.at(-1)
|
||||
).toBeLessThan(
|
||||
vi.mocked(api.conversations.branchLocal).mock.invocationCallOrder[0]!
|
||||
)
|
||||
expect(
|
||||
await screen.findAllByLabelText(
|
||||
'分支会话,来源:方案讨论更新'
|
||||
)
|
||||
).toHaveLength(2)
|
||||
const sidebar = container.querySelector('.conversation-list')
|
||||
const badge = within(sidebar as HTMLElement).getByLabelText(
|
||||
'分支会话,来源:方案讨论更新'
|
||||
)
|
||||
expect(badge).toHaveClass('conversation-branch-badge')
|
||||
expect(badge.querySelector('.lucide-git-fork')).toBeInTheDocument()
|
||||
expect(
|
||||
container.querySelector('.conversation-title')
|
||||
).toHaveTextContent('方案讨论更新 · 分支')
|
||||
await waitFor(() =>
|
||||
expect(screen.getByLabelText('向 GoodBuddy 提问')).toHaveFocus()
|
||||
)
|
||||
expect(
|
||||
screen.getAllByText('可以比较风险、成本和回滚路径。').length
|
||||
).toBeGreaterThan(0)
|
||||
expect(
|
||||
await screen.findByText('已创建并打开分支会话')
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps the source conversation open when branch persistence fails', async () => {
|
||||
const sourceConversationId =
|
||||
'00000000-0000-4000-8000-000000000441'
|
||||
vi.mocked(api.conversations.list).mockResolvedValueOnce([
|
||||
{
|
||||
id: sourceConversationId,
|
||||
projectId,
|
||||
title: '保留的来源会话',
|
||||
updatedAt: 1_775_000_000_000,
|
||||
messages: [
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000442',
|
||||
role: 'user',
|
||||
content: '不能丢失的来源内容',
|
||||
createdAt: 1_775_000_000_000,
|
||||
state: 'complete'
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
vi.mocked(api.conversations.branchLocal).mockRejectedValueOnce(
|
||||
new Error('分支数据写入失败')
|
||||
)
|
||||
const { container } = render(<App />)
|
||||
expect(
|
||||
await screen.findByText('不能丢失的来源内容')
|
||||
).toBeInTheDocument()
|
||||
|
||||
const actionTrigger = await screen.findByLabelText(
|
||||
'更多会话操作 保留的来源会话'
|
||||
)
|
||||
fireEvent.click(actionTrigger)
|
||||
const branchButton = screen.getByRole('button', {
|
||||
name: '在新会话中继续'
|
||||
})
|
||||
await waitFor(() => expect(branchButton).toBeEnabled())
|
||||
fireEvent.click(branchButton)
|
||||
|
||||
expect(
|
||||
await screen.findByText('分支数据写入失败')
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
container.querySelector('.conversation-title')
|
||||
).toHaveTextContent('保留的来源会话')
|
||||
expect(
|
||||
screen.getByText('不能丢失的来源内容')
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.queryByLabelText(/^分支会话,来源:/u)
|
||||
).not.toBeInTheDocument()
|
||||
await waitFor(() => expect(actionTrigger).toHaveFocus())
|
||||
})
|
||||
|
||||
it('explains why a queued conversation cannot be branched', async () => {
|
||||
const sourceConversationId =
|
||||
'00000000-0000-4000-8000-000000000451'
|
||||
vi.mocked(api.conversations.list).mockResolvedValueOnce([
|
||||
{
|
||||
id: sourceConversationId,
|
||||
projectId,
|
||||
title: '等待队列的会话',
|
||||
updatedAt: 1_775_000_000_000,
|
||||
messages: [
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000452',
|
||||
role: 'user',
|
||||
content: '还有待发送内容',
|
||||
createdAt: 1_775_000_000_000,
|
||||
state: 'complete'
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
vi.mocked(api.conversationQueue.list).mockResolvedValue([
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000453',
|
||||
conversationId: sourceConversationId,
|
||||
source: 'user',
|
||||
label: '待发送',
|
||||
createdAt: '2026-08-20T08:00:00.000Z'
|
||||
}
|
||||
])
|
||||
render(<App />)
|
||||
expect(
|
||||
await screen.findByText('还有待发送内容')
|
||||
).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(
|
||||
await screen.findByLabelText('更多会话操作 等待队列的会话')
|
||||
)
|
||||
const branchButton = screen.getByRole('button', {
|
||||
name: '在新会话中继续'
|
||||
})
|
||||
await waitFor(() =>
|
||||
expect(branchButton).toHaveAttribute('aria-disabled', 'true')
|
||||
)
|
||||
expect(branchButton).toHaveAccessibleDescription(
|
||||
'会话运行或待发送内容处理完后才能创建分支'
|
||||
)
|
||||
fireEvent.click(branchButton)
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.getAllByText(
|
||||
'会话运行或待发送内容处理完后才能创建分支'
|
||||
)
|
||||
).toHaveLength(2)
|
||||
)
|
||||
expect(api.conversations.branchLocal).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('offers a floating control when more messages remain below', async () => {
|
||||
vi.mocked(api.conversations.list).mockResolvedValueOnce([
|
||||
{
|
||||
|
||||
+243
-13
@@ -11,6 +11,7 @@ import {
|
||||
Download,
|
||||
Edit3,
|
||||
FileText,
|
||||
GitFork,
|
||||
HeartPulse,
|
||||
Info,
|
||||
Library,
|
||||
@@ -119,6 +120,7 @@ import type {
|
||||
} from '../../shared/assistant-contracts'
|
||||
import {
|
||||
conversationAttachmentSchema,
|
||||
conversationBranchSchema,
|
||||
conversationContextCompressionMarkerSchema,
|
||||
conversationContextMetricsSchema,
|
||||
conversationMessageBlocksSchema,
|
||||
@@ -679,6 +681,39 @@ function displayErrorMessage(reason: unknown, fallback: string): string {
|
||||
return fallback
|
||||
}
|
||||
|
||||
function createConversationBranchTitle(
|
||||
sourceTitle: string,
|
||||
suffix: string
|
||||
): string {
|
||||
const trailing = ` · ${suffix}`
|
||||
if (trailing.length >= 200) {
|
||||
return suffix.slice(0, 200)
|
||||
}
|
||||
return `${sourceTitle
|
||||
.slice(0, 200 - trailing.length)
|
||||
.trimEnd()}${trailing}`
|
||||
}
|
||||
|
||||
function ConversationBranchBadge({
|
||||
sourceTitle
|
||||
}: {
|
||||
sourceTitle: string
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation('app')
|
||||
const label = t('conversation.branch.badge', {
|
||||
title: sourceTitle
|
||||
})
|
||||
return (
|
||||
<span
|
||||
aria-label={label}
|
||||
className="conversation-branch-badge"
|
||||
title={label}
|
||||
>
|
||||
<GitFork aria-hidden="true" size={13} />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
function isUnusedConversation(conversation: Conversation): boolean {
|
||||
return (
|
||||
conversation.title === '新对话' &&
|
||||
@@ -1143,6 +1178,8 @@ function isConversation(value: unknown): value is Conversation {
|
||||
(item.knowledgeRetrievalMode === undefined ||
|
||||
item.knowledgeRetrievalMode === 'auto' ||
|
||||
item.knowledgeRetrievalMode === 'always') &&
|
||||
(item.branch === undefined ||
|
||||
conversationBranchSchema.safeParse(item.branch).success) &&
|
||||
(item.remote === undefined ||
|
||||
(typeof item.remote === 'object' &&
|
||||
item.remote !== null &&
|
||||
@@ -1228,6 +1265,7 @@ function toConversationSnapshots(
|
||||
knowledgeRetrievalMode: conversation.knowledgeRetrievalMode,
|
||||
contextMetrics: conversation.contextMetrics,
|
||||
contextCompressionState: conversation.contextCompressionState,
|
||||
...(conversation.branch ? { branch: conversation.branch } : {}),
|
||||
title: conversation.title,
|
||||
updatedAt: conversation.updatedAt,
|
||||
messages: conversation.messages
|
||||
@@ -1269,6 +1307,7 @@ function toLocalConversationHeader(
|
||||
knowledgeRetrievalMode: conversation.knowledgeRetrievalMode,
|
||||
contextMetrics: conversation.contextMetrics,
|
||||
contextCompressionState: conversation.contextCompressionState,
|
||||
...(conversation.branch ? { branch: conversation.branch } : {}),
|
||||
title: conversation.title,
|
||||
updatedAt: conversation.updatedAt
|
||||
}
|
||||
@@ -2284,6 +2323,8 @@ function App(): React.JSX.Element {
|
||||
useState('')
|
||||
const [deletingConversationId, setDeletingConversationId] =
|
||||
useState('')
|
||||
const [branchingConversationId, setBranchingConversationId] =
|
||||
useState('')
|
||||
const [renamingConversationId, setRenamingConversationId] = useState('')
|
||||
const [notifications, notify] = useReducer(
|
||||
appNotificationReducer,
|
||||
@@ -3268,6 +3309,13 @@ function App(): React.JSX.Element {
|
||||
const activeProjectDisplayName = activeProject
|
||||
? getProjectDisplayText(activeProject, tWorkspace).name
|
||||
: undefined
|
||||
const queuedConversationIds = useMemo(
|
||||
() =>
|
||||
new Set(
|
||||
conversationQueueItems.map((item) => item.conversationId)
|
||||
),
|
||||
[conversationQueueItems]
|
||||
)
|
||||
const filteredConversations = useMemo(() => {
|
||||
const query = deferredSearchQuery.trim().toLocaleLowerCase()
|
||||
const candidates = query
|
||||
@@ -5757,6 +5805,80 @@ function App(): React.JSX.Element {
|
||||
setActiveId(replacement.id)
|
||||
}
|
||||
|
||||
const branchConversation = async (
|
||||
sourceConversation: Conversation
|
||||
): Promise<void> => {
|
||||
if (
|
||||
branchingConversationId ||
|
||||
sourceConversation.remote ||
|
||||
!conversationStoreReady ||
|
||||
activeConversationIds.has(sourceConversation.id) ||
|
||||
queuedConversationIds.has(sourceConversation.id)
|
||||
) {
|
||||
return
|
||||
}
|
||||
setBranchingConversationId(sourceConversation.id)
|
||||
try {
|
||||
persistLocalConversationChanges()
|
||||
await conversationPersistenceQueueRef.current
|
||||
if (
|
||||
persistedLocalConversationsRef.current.get(
|
||||
sourceConversation.id
|
||||
) !== sourceConversation ||
|
||||
conversationsRef.current.find(
|
||||
(conversation) =>
|
||||
conversation.id === sourceConversation.id
|
||||
) !== sourceConversation
|
||||
) {
|
||||
throw new Error(t('notices.conversationPersistenceFailed'))
|
||||
}
|
||||
const sourceTitle = getConversationDisplayTitle(
|
||||
sourceConversation,
|
||||
t('conversation.defaultTitle')
|
||||
)
|
||||
const branch = await window.goodbuddy.conversations.branchLocal({
|
||||
sourceConversationId: sourceConversation.id,
|
||||
title: createConversationBranchTitle(
|
||||
sourceTitle,
|
||||
t('conversation.branch.suffix')
|
||||
)
|
||||
})
|
||||
const nextBranch: Conversation = branch
|
||||
persistedLocalConversationsRef.current.set(
|
||||
nextBranch.id,
|
||||
nextBranch
|
||||
)
|
||||
setConversations((current) => [
|
||||
nextBranch,
|
||||
...current.filter(
|
||||
(conversation) => conversation.id !== nextBranch.id
|
||||
)
|
||||
])
|
||||
setSelectedAssistantTaskId(undefined)
|
||||
setActiveId(nextBranch.id)
|
||||
setView('chat')
|
||||
if (narrowWindow) {
|
||||
closeNarrowSidebar()
|
||||
}
|
||||
notify({
|
||||
tone: 'success',
|
||||
message: t('notices.conversationBranched')
|
||||
})
|
||||
requestAnimationFrame(() => inputRef.current?.focus())
|
||||
} catch (error) {
|
||||
notify({
|
||||
tone: 'error',
|
||||
message: displayErrorMessage(
|
||||
error,
|
||||
t('notices.conversationBranchFailed')
|
||||
)
|
||||
})
|
||||
focusConversationActions(sourceConversation.id)
|
||||
} finally {
|
||||
setBranchingConversationId('')
|
||||
}
|
||||
}
|
||||
|
||||
const focusConversationActions = (conversationId: string): void => {
|
||||
requestAnimationFrame(() =>
|
||||
conversationActionTriggerRefs.current.get(conversationId)?.focus()
|
||||
@@ -7445,6 +7567,25 @@ function App(): React.JSX.Element {
|
||||
conversation,
|
||||
t('conversation.defaultTitle')
|
||||
)
|
||||
const branchSourceTitle = conversation.branch
|
||||
? conversationTitles.get(
|
||||
conversation.branch.sourceConversationId
|
||||
) ?? conversation.branch.sourceTitle
|
||||
: undefined
|
||||
const branchUnavailable =
|
||||
activeConversationIds.has(conversation.id) ||
|
||||
queuedConversationIds.has(conversation.id)
|
||||
const branchDisabledReason = !conversationStoreReady
|
||||
? t('conversation.branch.storageUnavailable')
|
||||
: branchingConversationId
|
||||
? branchingConversationId === conversation.id
|
||||
? t('conversation.branch.creating')
|
||||
: t('conversation.branch.anotherCreating')
|
||||
: branchUnavailable
|
||||
? t('conversation.branch.unavailable')
|
||||
: undefined
|
||||
const branchDisabledReasonId =
|
||||
`conversation-branch-disabled-${conversation.id}`
|
||||
return (
|
||||
<div className="conversation-entry" key={conversation.id}>
|
||||
<div
|
||||
@@ -7508,6 +7649,11 @@ function App(): React.JSX.Element {
|
||||
}}
|
||||
>
|
||||
<span className="conversation-item__primary">
|
||||
{branchSourceTitle && (
|
||||
<ConversationBranchBadge
|
||||
sourceTitle={branchSourceTitle}
|
||||
/>
|
||||
)}
|
||||
{conversation.remote && (
|
||||
<b className="conversation-source-badge">
|
||||
{
|
||||
@@ -7595,6 +7741,50 @@ function App(): React.JSX.Element {
|
||||
className="conversation-actions"
|
||||
id={`conversation-actions-${conversation.id}`}
|
||||
>
|
||||
{!conversation.remote && (
|
||||
<>
|
||||
<button
|
||||
aria-describedby={
|
||||
branchDisabledReason
|
||||
? branchDisabledReasonId
|
||||
: undefined
|
||||
}
|
||||
aria-disabled={
|
||||
branchDisabledReason ? true : undefined
|
||||
}
|
||||
onClick={() => {
|
||||
if (branchDisabledReason) {
|
||||
notify({
|
||||
tone: 'info',
|
||||
message: branchDisabledReason
|
||||
})
|
||||
return
|
||||
}
|
||||
setConversationActionsId('')
|
||||
void branchConversation(conversation)
|
||||
}}
|
||||
title={branchDisabledReason}
|
||||
type="button"
|
||||
>
|
||||
<GitFork
|
||||
aria-hidden="true"
|
||||
className="conversation-branch-icon"
|
||||
size={14}
|
||||
/>
|
||||
{branchingConversationId === conversation.id
|
||||
? t('conversation.branch.creating')
|
||||
: t('conversation.actions.branch')}
|
||||
</button>
|
||||
{branchDisabledReason && (
|
||||
<span
|
||||
className="sr-only"
|
||||
id={branchDisabledReasonId}
|
||||
>
|
||||
{branchDisabledReason}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{!conversation.remote && (
|
||||
<button
|
||||
onClick={() => {
|
||||
@@ -7722,6 +7912,24 @@ function App(): React.JSX.Element {
|
||||
task,
|
||||
assistantSchedules
|
||||
)
|
||||
const statusLabel = tWorkspace(
|
||||
`task.status.${task.status}`
|
||||
)
|
||||
const metadata = schedule
|
||||
? [
|
||||
tWorkspace(`task.mode.${schedule.workMode}`),
|
||||
tWorkspace(
|
||||
`sidebar.tasks.schedule.recurrence.${schedule.recurrence}`
|
||||
),
|
||||
task.status === 'completed'
|
||||
? undefined
|
||||
: statusLabel
|
||||
]
|
||||
.filter((value) => value !== undefined)
|
||||
.join(' · ')
|
||||
: task.status === 'completed'
|
||||
? ''
|
||||
: statusLabel
|
||||
return (
|
||||
<li key={task.id}>
|
||||
<button
|
||||
@@ -7738,21 +7946,34 @@ function App(): React.JSX.Element {
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`task-status-dot task-status-dot--${task.status}`}
|
||||
/>
|
||||
<span className="conversation-task-child__title">
|
||||
{task.title}
|
||||
</span>
|
||||
<small className="conversation-task-child__meta">
|
||||
{schedule
|
||||
? `${tWorkspace(`task.mode.${schedule.workMode}`)} · ${tWorkspace(
|
||||
`sidebar.tasks.schedule.recurrence.${schedule.recurrence}`
|
||||
)} · `
|
||||
: ''}
|
||||
{tWorkspace(`task.status.${task.status}`)}
|
||||
</small>
|
||||
{metadata && (
|
||||
<small className="conversation-task-child__meta">
|
||||
{metadata}
|
||||
</small>
|
||||
)}
|
||||
{task.status === 'completed' ? (
|
||||
<span
|
||||
className="task-status-dot task-status-dot--completed conversation-task-child__completed-status"
|
||||
title={statusLabel}
|
||||
>
|
||||
<Check
|
||||
aria-hidden="true"
|
||||
size={7}
|
||||
strokeWidth={3}
|
||||
/>
|
||||
<span className="sr-only">
|
||||
{statusLabel}
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`task-status-dot task-status-dot--${task.status}`}
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
@@ -7847,7 +8068,7 @@ function App(): React.JSX.Element {
|
||||
className="conversation-title"
|
||||
title={activeConversation?.title}
|
||||
>
|
||||
<span>
|
||||
<span className="conversation-title__text">
|
||||
{activeConversation
|
||||
? getConversationDisplayTitle(
|
||||
activeConversation,
|
||||
@@ -7858,6 +8079,15 @@ function App(): React.JSX.Element {
|
||||
? t('conversation.remoteTitle')
|
||||
: t('conversation.defaultTitle'))}
|
||||
</span>
|
||||
{activeConversation?.branch && (
|
||||
<ConversationBranchBadge
|
||||
sourceTitle={
|
||||
conversationTitles.get(
|
||||
activeConversation.branch.sourceConversationId
|
||||
) ?? activeConversation.branch.sourceTitle
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{activeConversation?.remote && (
|
||||
<b className="conversation-source-badge">
|
||||
{
|
||||
|
||||
@@ -178,6 +178,9 @@ describe('WorkspacePrimitives', () => {
|
||||
expect(forcedColors).toMatch(
|
||||
/\.task-status-dot--failed,[\s\S]*?forced-color-adjust:\s*none;/u
|
||||
)
|
||||
expect(forcedColors).toMatch(
|
||||
/:root \.conversation-task-child__completed-status\s*\{[^}]*color:\s*Canvas;/u
|
||||
)
|
||||
expect(forcedColors).toMatch(
|
||||
/\.heartbeat-center__meter\s*\{[^}]*forced-color-adjust:\s*none;/u
|
||||
)
|
||||
@@ -210,6 +213,12 @@ describe('WorkspacePrimitives', () => {
|
||||
})
|
||||
|
||||
it('keeps the conversation action close to the sidebar edge', () => {
|
||||
expect(stylesheet).toMatch(
|
||||
/\.conversation-row:has\(\.conversation-task-toggle\) \.conversation-item\s*\{[^}]*padding-left:\s*34px;/u
|
||||
)
|
||||
expect(stylesheet).toMatch(
|
||||
/\.conversation-task-toggle\s*\{[^}]*left:\s*3px;[^}]*width:\s*28px;[^}]*height:\s*28px;/u
|
||||
)
|
||||
expect(stylesheet).toMatch(
|
||||
/\.conversation-row \.conversation-item\s*\{[^}]*padding-right:\s*36px;/u
|
||||
)
|
||||
@@ -225,6 +234,15 @@ describe('WorkspacePrimitives', () => {
|
||||
expect(stylesheet).not.toContain('.conversation-delete')
|
||||
})
|
||||
|
||||
it('shows conversation provenance with a horizontal fork badge', () => {
|
||||
expect(stylesheet).toMatch(
|
||||
/\.conversation-branch-badge\s*\{[^}]*width:\s*20px;[^}]*height:\s*18px;[^}]*background:\s*var\(--accent-subtle\);[^}]*color:\s*var\(--accent\);/u
|
||||
)
|
||||
expect(stylesheet).toMatch(
|
||||
/\.conversation-branch-badge svg,\s*\.conversation-branch-icon\s*\{[^}]*transform:\s*rotate\(90deg\);/u
|
||||
)
|
||||
})
|
||||
|
||||
it('uses the shared control and menu surfaces for the rich project picker', () => {
|
||||
expect(stylesheet).toMatch(
|
||||
/\.project-switcher__trigger\s*\{[^}]*height:\s*var\(--control-height\);[^}]*border-radius:\s*var\(--radius-control\);[^}]*background:\s*var\(--surface-raised\);/u
|
||||
|
||||
@@ -86,9 +86,20 @@ export const app = {
|
||||
saveName: 'Save conversation name',
|
||||
cancelRename: 'Cancel rename',
|
||||
exportFallbackName: 'GoodBuddy conversation',
|
||||
branch: {
|
||||
badge: 'Branched conversation, source: {{title}}',
|
||||
suffix: 'Branch',
|
||||
creating: 'Creating branch',
|
||||
anotherCreating: 'Another branch is being created. Please wait.',
|
||||
storageUnavailable:
|
||||
'Conversation storage is not ready yet. Please wait.',
|
||||
unavailable:
|
||||
'Finish the active run or pending items before creating a branch'
|
||||
},
|
||||
actions: {
|
||||
more: 'More conversation actions for {{title}}',
|
||||
region: 'Conversation actions for {{title}}',
|
||||
branch: 'Continue in a new conversation',
|
||||
rename: 'Rename conversation',
|
||||
copy: 'Copy full conversation',
|
||||
export: 'Export Markdown'
|
||||
@@ -572,6 +583,9 @@ export const app = {
|
||||
clipboardUnavailable:
|
||||
'Cannot access the clipboard. Check your system permissions.',
|
||||
conversationExported: 'Conversation exported',
|
||||
conversationBranched: 'Branch created and opened',
|
||||
conversationBranchFailed:
|
||||
'Failed to create a conversation branch. Try again.',
|
||||
imageUnavailable: 'Image content is unavailable',
|
||||
imageDownloadStarted: 'Image download started',
|
||||
remoteConversationReadOnly:
|
||||
|
||||
@@ -83,9 +83,18 @@ export const app = {
|
||||
saveName: '保存会话名称',
|
||||
cancelRename: '取消重命名',
|
||||
exportFallbackName: 'GoodBuddy 对话',
|
||||
branch: {
|
||||
badge: '分支会话,来源:{{title}}',
|
||||
suffix: '分支',
|
||||
creating: '正在创建分支',
|
||||
anotherCreating: '另一条分支正在创建,请稍候',
|
||||
storageUnavailable: '会话存储尚未就绪,请稍候',
|
||||
unavailable: '会话运行或待发送内容处理完后才能创建分支'
|
||||
},
|
||||
actions: {
|
||||
more: '更多会话操作 {{title}}',
|
||||
region: '{{title}} 的会话操作',
|
||||
branch: '在新会话中继续',
|
||||
rename: '重命名会话',
|
||||
copy: '复制完整会话',
|
||||
export: '导出 Markdown'
|
||||
@@ -537,6 +546,8 @@ export const app = {
|
||||
conversationCopied: '对话已复制到剪贴板',
|
||||
clipboardUnavailable: '无法访问剪贴板,请检查系统权限',
|
||||
conversationExported: '对话已导出',
|
||||
conversationBranched: '已创建并打开分支会话',
|
||||
conversationBranchFailed: '创建分支会话失败,请重试',
|
||||
imageUnavailable: '图片内容不可用',
|
||||
imageDownloadStarted: '图片下载已开始',
|
||||
remoteConversationReadOnly: '远程通道会话只能从对应消息应用继续发起',
|
||||
|
||||
@@ -95,16 +95,16 @@
|
||||
}
|
||||
|
||||
.conversation-row:has(.conversation-task-toggle) .conversation-item {
|
||||
padding-left: 42px;
|
||||
padding-left: 34px;
|
||||
}
|
||||
|
||||
.conversation-task-toggle {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
left: 7px;
|
||||
left: 3px;
|
||||
display: grid;
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
@@ -180,6 +180,14 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.conversation-task-child__completed-status {
|
||||
display: grid;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
color: var(--text-on-accent);
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.conversation-task-view-all {
|
||||
justify-content: center;
|
||||
color: var(--accent);
|
||||
@@ -2792,6 +2800,7 @@ textarea:focus-visible {
|
||||
|
||||
.conversation-item__primary
|
||||
> :where(
|
||||
.conversation-branch-badge,
|
||||
.conversation-source-badge,
|
||||
.conversation-unread
|
||||
) {
|
||||
@@ -2841,6 +2850,25 @@ textarea:focus-visible {
|
||||
transition-timing-function: linear;
|
||||
}
|
||||
|
||||
.conversation-branch-badge {
|
||||
display: inline-flex;
|
||||
width: 20px;
|
||||
height: 18px;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 5px;
|
||||
margin-right: var(--space-1);
|
||||
background: var(--accent-subtle);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.conversation-branch-badge svg,
|
||||
.conversation-branch-icon {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.conversation-source-badge {
|
||||
display: inline-flex;
|
||||
margin-right: var(--space-1);
|
||||
@@ -3926,12 +3954,17 @@ button > svg {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.conversation-title span {
|
||||
.conversation-title__text {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.conversation-title .conversation-branch-badge {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.topbar__actions {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
@@ -8910,6 +8943,13 @@ details.settings-section > :not(summary) + :not(summary) {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.conversation-actions button[aria-disabled='true'] {
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
cursor: help;
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.conversation-rename {
|
||||
display: grid;
|
||||
padding: var(--space-1);
|
||||
@@ -13253,6 +13293,10 @@ details.settings-section > :not(summary) + :not(summary) {
|
||||
forced-color-adjust: none;
|
||||
}
|
||||
|
||||
:root .conversation-task-child__completed-status {
|
||||
color: Canvas;
|
||||
}
|
||||
|
||||
:root :is(
|
||||
.task-status-dot--failed,
|
||||
.task-status-dot--interrupted,
|
||||
|
||||
Reference in New Issue
Block a user