Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions src/renderer/src/mock/mocks/v32-room-context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import type { ReactNode } from 'react'
import { BookmarkPlus, Copy, CornerDownRight, MessageSquarePlus, Plus, Trash2 } from 'lucide-react'
import { BotAvatar } from '@/components/ui/Avatar'
import { Button } from '@/components/ui/Button'
import { SwitchPill } from '@/components/ui/Controls'
import { TextInput } from '@/components/ui/Field'
import { IconButton } from '@/components/ui/IconButton'
import { MENU_SURFACE } from '@/components/ui/Menu'
import { cn } from '@/lib/cn'

/**
* v32:群聊共享背景(PR goxf/feat-room-context)。
* 左 = 群设置新分区「背景」:群背景文字、成员视角、群共享技能。
* 右 = 群聊:顶部「新话题」,消息菜单「沉淀为群背景」,新话题分界线。
* 背景/技能/视角只在变了、或成员换新会话时整段发给成员一次。
*/
const noop = () => {}
const NEW_TAG = 'inline-flex h-5 items-center rounded-full bg-accent-50 px-2 text-[11px] font-medium text-accent-700 dark:text-accent-400'

function Section({ title, hint, action, children }: { title: string; hint?: string; action?: ReactNode; children: ReactNode }) {
return (
<div className="flex flex-col gap-2 border-t border-line px-4 py-3.5">
<div className="flex items-center justify-between gap-2">
<div className="min-w-0">
<p className="text-[13px] font-medium text-ink">{title}</p>
{hint && <p className="text-[12px] text-ink-muted">{hint}</p>}
</div>
{action}
</div>
{children}
</div>
)
}

const CONTEXT = `项目:BotArk 自用版,Electron + TypeScript。
目标用户只有自己,Windows 便携版。

[本轮结论 · 2026-12-03 10:40]
- @Claude: 本地存储用 SQLite,不上云。
- @GPT: 更新包走 GitHub Release。`

function SettingsPanel() {
return (
<div className="flex w-[340px] flex-col rounded-2xl border border-line bg-main shadow-soft">
<div className="flex items-center gap-2 px-4 pt-4 pb-3">
<p className="text-[15px] font-semibold text-ink">群设置</p>
<span className={NEW_TAG}>背景</span>
</div>
<Section title="群背景" hint="所有成员共享,最多 8000 字,超出时删掉最旧的内容">
<textarea
readOnly
value={CONTEXT}
rows={7}
className="w-full resize-none rounded-lg border border-line-strong bg-surface px-3 py-2 text-[13px] leading-5 text-ink shadow-soft outline-none"
/>
<div className="flex items-center justify-between">
<span className="text-[11px] text-ink-muted tabular-nums">112 / 8000</span>
<Button size="sm" variant="ghost"><Trash2 aria-hidden /> 清空</Button>
</div>
</Section>
<Section title="成员视角" hint="每位成员从自己的角度发言">
{[['Claude', 'a', '安全审查'], ['GPT', 'b', '性能与体积'], ['Hark', 'c', '']].map(([name, seed, role]) => (
<div key={name} className="flex items-center gap-2.5">
<BotAvatar emoji="🤖" seed={seed!} platformId="meta-muse" size="sm" />
<span className="w-14 shrink-0 truncate text-[13px] text-ink">{name}</span>
<TextInput readOnly value={role} placeholder="例如:安全审查" aria-label={`${name} 的视角`} className="h-8 text-[13px]" />
</div>
))}
</Section>
<Section title="群共享技能" hint="启用的技能发给每位成员,合计约 4000 字封顶"
action={<IconButton size="sm" label="添加技能"><Plus aria-hidden /></IconButton>}>
{[
{ name: '先给结论', body: '回答先给一句结论,再列理由,不超过 5 条。', on: true },
{ name: '中文 + 北京时间', body: '用中文回答,时间写北京时间并标明。', on: true },
{ name: '代码评审清单', body: '逐条检查:边界条件、错误处理、测试覆盖……', on: false }
].map((s) => (
<div key={s.name} className="flex items-center gap-3 rounded-lg px-1 py-1">
<div className="min-w-0 flex-1">
<p className={cn('truncate text-[13px] font-medium', s.on ? 'text-ink' : 'text-ink-muted')}>{s.name}</p>
<p className="truncate text-[12px] text-ink-muted">{s.body}</p>
</div>
<SwitchPill size="sm" checked={s.on} onCheckedChange={noop} aria-label={`启用 ${s.name}`} />
</div>
))}
</Section>
<p className="border-t border-line px-4 py-3 text-[12px] text-ink-muted">
改了背景、技能或视角后,下一轮会把新内容发给每位成员一次;平时不重复发。
</p>
</div>
)
}

function MockItem({ icon, children, hint }: { icon: ReactNode; children: ReactNode; hint?: ReactNode }) {
return (
<div className="flex min-h-[30px] items-center gap-2 rounded-md px-2 py-1.5 text-[13px] leading-[18px] text-ink [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-ink-secondary">
{icon}
<span className="flex-1">{children}</span>
{hint}
</div>
)
}

function Reply({ name, seed, text, final }: { name: string; seed: string; text: string; final?: boolean }) {
return (
<div className="flex items-start gap-2.5">
<BotAvatar emoji="🤖" seed={seed} platformId="meta-muse" size="sm" />
<div className="flex min-w-0 flex-1 flex-col gap-1">
<span className="flex items-center gap-1.5 text-[12px] font-medium text-ink">
{name}{final && <span className="rounded-full bg-sunken px-1.5 text-[11px] text-ink-secondary">最终答复</span>}
</span>
<div className="w-fit max-w-[92%] rounded-2xl bg-bubble px-4 py-2.5 text-[13px] leading-5 text-ink">{text}</div>
</div>
</div>
)
}

function Human({ text }: { text: string }) {
return (
<div className="flex justify-end">
<div className="max-w-[76%] rounded-[20px] bg-bubble-user px-4 py-2.5 text-[14px] leading-[22px] text-main">{text}</div>
</div>
)
}

function RoomPane() {
return (
<div className="flex w-[600px] flex-col rounded-2xl border border-line bg-main shadow-soft">
<div className="flex items-center gap-2 border-b border-line px-4 py-2.5">
<p className="min-w-0 flex-1 truncate text-[14px] font-medium text-ink">架构评审 · 3 位成员</p>
<Button size="sm" title="所有成员换新会话,重新收到群背景;之前的消息不再发给成员">
<MessageSquarePlus aria-hidden /> 新话题
</Button>
</div>
<div className="relative flex flex-col gap-4 p-5">
<Human text="本地数据怎么存?更新包放哪?" />
<Reply name="Claude" seed="a" final text="结论:本地存储用 SQLite,不上云;更新包走 GitHub Release,zip 便携版自更新。" />
<div className={cn('absolute top-[150px] right-6 flex w-56 flex-col gap-0.5', MENU_SURFACE)}>
<MockItem icon={<CornerDownRight aria-hidden />}>引用</MockItem>
<MockItem icon={<Copy aria-hidden />}>复制</MockItem>
<div className="mx-1 my-0.5 h-px bg-line" />
<div className="rounded-md bg-hover">
<MockItem icon={<BookmarkPlus aria-hidden />} hint={<span className="text-[12px] text-ink-muted">追加摘要</span>}>沉淀为群背景</MockItem>
</div>
</div>
<div className="h-[96px]" />
<p className="self-center rounded-full bg-sunken px-3 py-1 text-[12px] text-ink-secondary">已沉淀到群背景 · 112 / 8000 字</p>
<div className="flex items-center gap-3 py-1">
<div className="h-px flex-1 bg-line" />
<span className="text-[12px] text-ink-muted">新话题 · 成员已换新会话,群背景会重新发给每位成员</span>
<div className="h-px flex-1 bg-line" />
</div>
<Human text="接下来评审一下自动更新的签名校验。" />
</div>
</div>
)
}

export function V32RoomContextMock() {
return (
<div className="flex flex-col gap-3">
<div className="flex items-start gap-6">
<SettingsPanel />
<RoomPane />
</div>
<p className="px-1 text-[12px] text-ink-muted">
右键 / 「更多」菜单里的「沉淀为群背景」:有 [FINAL] 时取最终答复,否则取最近一轮回复,摘要追加到群背景末尾。Hark 成员收到的是去掉群聊措辞的中性版本。
</p>
</div>
)
}
55 changes: 55 additions & 0 deletions src/renderer/src/mock/mocks/v32b-room-context-live.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Menu, MenuContent, MenuItem, MenuTrigger } from '@/components/ui/Menu'
import { Copy, CornerDownRight } from 'lucide-react'
import type { CollabRoom } from '@/rooms/model'
import { RoomContextSections } from '@/rooms/RoomContextSections'
import { DistillMenuItem, NewTopicButton, NewTopicDivider } from '@/rooms/RoomContextUi'
import { useRooms } from '@/rooms/roomStore'

/** v32b:真实组件截图(RoomContextSections / RoomContextUi),数据为假群。 */
const ROOM = {
id: 'mock-room-context',
title: '架构评审',
mode: 'manual',
brief: '',
members: [
{ botId: 'a', name: 'Claude', platform: 'meta-muse', cursor: 0 },
{ botId: 'b', name: 'GPT', platform: 'meta-muse', cursor: 0 },
{ botId: 'c', name: 'Hark', platform: 'meta-muse', cursor: 0 }
],
messages: [{ id: 'm1', author: 'Claude', authorBotId: 'a', text: '结论:本地存储用 SQLite,不上云。', createdAt: 0 }],
memberRoles: { a: '安全审查', b: '性能与体积' },
sharedSkills: [
{ id: 's1', name: '先给结论', content: '回答先给一句结论,再列理由,不超过 5 条。', enabled: true },
{ id: 's2', name: '中文 + 北京时间', content: '用中文回答,时间写北京时间并标明。', enabled: true },
{ id: 's3', name: '代码评审清单', content: '逐条检查:边界条件、错误处理、测试覆盖……', enabled: false }
],
sharedContext: '项目:BotArk 自用版,Electron + TypeScript。\n目标用户只有自己,Windows 便携版。\n\n[本轮结论 · 2026-12-03 10:40]\n- @Claude: 本地存储用 SQLite,不上云。'
} as unknown as CollabRoom

useRooms.setState((s) => ({ rooms: [ROOM, ...s.rooms.filter((r) => r.id !== ROOM.id)] }))

export function V32bRoomContextLiveMock() {
const room = useRooms((s) => s.rooms.find((r) => r.id === ROOM.id)) ?? ROOM
return (
<div className="flex items-start gap-6">
<div className="w-[340px] rounded-2xl border border-line bg-main shadow-soft">
<RoomContextSections room={room} />
</div>
<div className="flex w-[600px] flex-col gap-4 rounded-2xl border border-line bg-main p-4 shadow-soft">
<div className="flex justify-end"><NewTopicButton roomId={room.id} /></div>
<p className="self-center rounded-full bg-sunken px-3 py-1 text-[12px] text-ink-secondary">已沉淀到群背景 · {room.sharedContext?.length ?? 0} / 8000 字</p>
<NewTopicDivider />
<div className="h-[200px]">
<Menu open modal={false}>
<MenuTrigger asChild><span className="block size-0" /></MenuTrigger>
<MenuContent align="start" side="bottom" className="min-w-52">
<MenuItem><CornerDownRight aria-hidden /> 引用</MenuItem>
<MenuItem><Copy aria-hidden /> 复制</MenuItem>
<DistillMenuItem roomId={room.id} message={room.messages[0]!} />
</MenuContent>
</Menu>
</div>
</div>
</div>
)
}
4 changes: 4 additions & 0 deletions src/renderer/src/mock/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { V29ProxyAssignOpenMock, V29ProxyAssignPageMock, V29ProxyRemoveConfirmMo
import { V28ProxyPoolEmptyMock, V28ProxyPoolStepsMock } from './mocks/v28-proxy-pool-steps'
import { V30RoomRoutedMock } from './mocks/v30-room-routed'
import { V31ProjectRowMock } from './mocks/v31-project-row'
import { V32RoomContextMock } from './mocks/v32-room-context'
import { V32bRoomContextLiveMock } from './mocks/v32b-room-context-live'
import { V32RoomWorkflowMock } from './mocks/v32-room-workflow'
import { V32RoomWorkflowRealMock } from './mocks/v32-room-workflow-real'

Expand All @@ -39,6 +41,8 @@ export const MOCKS: Record<string, ComponentType> = {
'v29-proxy-assign-open': V29ProxyAssignOpenMock,
'v29-proxy-remove-confirm': V29ProxyRemoveConfirmMock,
'v30-room-routed': V30RoomRoutedMock,
'v32-room-context': V32RoomContextMock,
'v32b-room-context-live': V32bRoomContextLiveMock,
'v32-room-workflow': V32RoomWorkflowMock,
'v32-room-workflow-real': V32RoomWorkflowRealMock
}
Loading