Compare commits

...
52 changed files with 755 additions and 66 deletions
+1 -1
View File
@@ -18,5 +18,5 @@
"No uncaught browser errors, API/external requests, microphone or camera requests"
],
"errors": [],
"requests": 56
"requests": 54
}
Binary file not shown.
+31
View File
@@ -0,0 +1,31 @@
{
"task": "HEL-823 视觉总监:把 HEL-815 的日子、已分享生活详情、共同回忆、首次创建、设置管理完整页面接到正式 React 产品(A3)",
"baseline_version": "1.10",
"read_commit": "cef8ae5581f68ae81991533698ef05abcb82e659",
"read_notes": "唯一施工基底为远端 hel-822-candidate 提交 cef8ae5(总管 git archive 附件 HEL-823-A3-base-cef8ae5.zip,SHA256 245dab3f124c0c987a322c4dd788dbb7e7f5e24c4fb96f9eb50f4ec6c61a3894,本机复算一致)。本机实际阅读该包内根 AGENTS.md、docs/requirements/README.md、current.md(v1.10,59项)、coverage.md、changes.md、task-handoff-template.md、handoff-HEL-824.json,并按编号核对 CG-006/007/012–016/018/024/029–031、VIS-001–013、AM-001–003、UX-001–006、GOV-001–005、DEL-001 原文与边界。页面设计依据为本人 HEL-815 原稿附件 01a16845-b50a-7335-a87e-61bf11c44703(README、src/pages.js、boards/01)。授权原话:主卡评论 01a169a8-5884-7c26-a00f-c23a5f5399a9「继续吧,现在没什么主要的内容需要我确认的」。模板里的旧 1.7 字样不覆盖当前入口 v1.10。",
"requirement_ids": ["CG-006", "CG-007", "CG-012", "CG-013", "CG-014", "CG-015", "CG-016", "CG-018", "CG-024", "CG-029", "CG-030", "CG-031", "VIS-001", "VIS-002", "VIS-003", "VIS-004", "VIS-005", "VIS-006", "VIS-007", "VIS-008", "VIS-009", "VIS-010", "VIS-011", "VIS-012", "VIS-013", "AM-001", "AM-002", "AM-003", "UX-001", "UX-002", "UX-003", "UX-004", "UX-005", "UX-006", "GOV-001", "GOV-002", "GOV-003", "GOV-004", "GOV-005", "DEL-001"],
"deliverable": "在 cef8ae5 上改 web 下 15 个文件(10 个源码、5 个测试)、新增本交接,无删除(清单与前后哈希见 CHANGES-HEL-823.json)。(1) web/src/life/LifePanel.tsx 重写为 HEL-815 日子页:标题区「她的日子 / 我们的回忆」+ 宽屏「日子 · 演示数据」/ ≤1100「她此刻 · …」;页签行附说明;列表按「她说过的打算」置顶、其余按日分组,行=时间·状态点(实心已发生/呼吸点正在/虚线打算)·标题·一句摘要·少量标签;分页「看更早的日子」→ 加载中 → 到底「再往前,就是她刚住进来的那天了」;演示失败开关下的读取失败卡与「再试一次」(加载骨架);空状态(首晚 / 真实后台未接)。详情:类别·时间·地点、何时告诉你、带身份的她的原话、关联回忆卡、那时候的聊天(只取已通过 publicView 的消息)、「在交谈里看这段」、演示说明。回忆四组带计数,详情「她是这样记得的」、成长注明不改写底色并可跳到设置·她、来自这些日子的反链或说明。任何解析不到的选择(过期、删除或从未讲过)统一显示「这一条现在打不开」,不暗示记录存在。每个页签保留自己的滚动位置,面板隐藏再打开(交谈返回日子)恢复;手机 Esc 先关推入详情。(2) web/src/manage/CreationWizard.tsx:左侧叙事随步骤与创建中/失败/完成变化;名字为空并有占位,错误时焦点落到出问题的字段(名字/生日/关系);生日「随机生成 / 我来指定」(默认随机一个满 19–35 岁的生日,可再随机;手动改日期或时辰即为指定);关系改为两张说明卡且不预选;新增可选相处边界(后端 CreationInput 已接受 boundary,未改 API);汇总含边界;创建中提示、失败「返回修改 / 再试一次」资料保留;真实 409「已经有一位她」时禁用再次创建并提供「重新打开,恢复已有的她」(只 reload,不覆盖);完成页「第一晚」。(3) web/src/manage/ManagePanel.tsx:分区列表加能力说明与手机推入箭头、底注「首版只有一位她 · 没有重建或清空」;分区标题旁能力标签(只读/可以调整/演示数据/未接入/文字已接通/本机生效);「她」改为名字只读+生辰只读、底色(沿用 BaseColor 真实排盘)、「她怎么理解自己」诚实未接卡(不放固定段落)、最初就有的/后来慢慢有的分栏(成长只取已分享来源的回忆);关系改为分段按钮,确认框写明「把关系从「X」改成「Y」?」并保留记忆与信任说明;真实城市/外观/备份/语音视觉开头加「还没有接上」说明卡(接上后做什么、现在什么都不会发生),原有待接入细节保留;减少动效改为开关样式。(4) web/src/stage/Presenter.tsx 新增「她此刻」浮签:面板打开且宽度 >1100 时贴在她下方,随相机落定与窗口变化跟随命中区;≤1100 改写在面板标题上方。(5) App.tsx / RealApp.tsx 传入此刻文字、演示失败开关与「在设置里看底色与成长」跳转;domain/model.ts LifeEvent 增可选 told;demo/fixtures.ts 演示条目补 told;adapters/storage.ts 恢复时只为已分享条目保留 told。(6) styles/components.css 追加 A3 区块(两主题共用 token,状态色只用于点、细线与短字;≤1100、≤720、≤720×620、≤360 断点)。(7) tests:domain.test.ts 新增 told 只保留在已分享记录的单测;browser_check / real_browser_check / import_check / rework_browser_check 只按本次有意的界面变化改选择器(关系下拉→分段按钮,「看那段聊天」→「在交谈里看这段」,私有深链断言改为中性「这一条现在打不开」),其余断言不动。",
"acceptance": [
"日子(演示 ?demo=1,载入三天记录):打算置顶并标「计划可能会变」,正在为呼吸点;列表与详情、回忆、搜索不出现未分享条目;#event=secret 深链只显示「这一条现在打不开。」,页面不含「秘密散步/私密地点」(browser_check 已改断言)。",
"长记录:首屏 18 条,看更早的日子后 30 条;选第 11 条 → 在交谈里看这段 → 结束交谈 · 回到日子,列表滚动位置与选中项不变(import_check 原断言)。",
"我们的回忆:真实入口四组各显示「暂无可核实的回忆」(.pane .list .grp = 4,rework 原断言);演示入口四组带计数,成长条目可跳到设置·她。",
"首建:名字为空、关系不预选(两张卡 aria-pressed=false)、未满 18 岁与未选关系被拦并聚焦对应字段;勾选确认前「确认创建」禁用;演示失败后资料保留、再试一次成功;真实入口 409 不覆盖已有档案。",
"设置:名字与生辰只读,无改名/新建/切换/清空/重建入口;改关系类型须确认,取消恢复,保存失败修改保留;离开有未保存修改须确认(原守卫未改);未接入能力全部标「未接入」且按钮不可用,演示能力标「演示数据」。",
"两主题结构一致(同一 DOM,只换 token);1600×1000、1024、390×844、320×568、390×430 键盘等效下无关键遮挡——需总工以浏览器检查与截图实测,本机未能运行。",
"未触碰 A1/A2:ChatPanel、reading.ts、lineStage、Viewport、compact/typing 规则、真实适配器/TurnGate/epoch 均未修改。"
],
"deferred": [
"本机(Windows 运行时)没有 node/npm、python、git,也找不到可用的 TypeScript:未执行 npm ci/typecheck/lint/test/build、四份浏览器检查、check_requirements.py、git diff --check,也没有正式 React 页面截图或录屏;全部交总工机械执行,未运行即未通过,不以静态阅读或 HEL-815 静态样图代替。",
"未提交、未开 PR:按 CHANGES-HEL-823.json 落到 hel-822-candidate(cef8ae5)之上的独立分支,产品目标仍为 agent/agent/de8874a3803b,不指 main;不合并、不部署 8320,8300/8310 未触碰。",
"HEL-815 中「看接入后的设计稿」只作施工参照,按原稿施工须知未放进正式产品;城市、外观、备份、语音、视觉观察、生活、长期记忆、主动消息的真实能力仍未接通(R2–R7)。",
"「她怎么理解自己」与最初小习惯在真实入口显示未接说明,由 R1 人格深度承接(CG-013/014/015、UX-004);不以固定模板填充。",
"真机软键盘、Safari/Firefox、读屏未测;等效视口不冒充真机(UX-001)。人物仍为参考静帧,真实日常视频/首尾衔接/语音口型由主卡 HEL-797 与 HEL-802/803 承接(DEL-001)。"
],
"requirement_changes": [],
"verification": [
"附件 SHA256 复算 245dab3f124c0c987a322c4dd788dbb7e7f5e24c4fb96f9eb50f4ec6c61a3894,与卡片一致;解包为只读 before 与可写 work 两份,修改只在 work,before 全部 250 个文件哈希另存。",
"修改前后文件哈希与改/增/删清单见交付包 CHANGES-HEL-823.json。",
"静态自查:逐文件回读 JSX 结构与类型(新增 props 均为可选、noUnusedLocals 下无多余变量),核对测试所依赖的可访问名称(她的名字、出生日期(公历)、1 / 4 · 出生资料、朋友/恋人 aria-pressed、确认创建、再试一次、去看看她、看更早的日子、结束交谈 · 回到日子、设置分区各按钮名、她怎么称呼你、相处边界、取消修改/保存/重试保存、.kv/.ev/.list/.grp/.city-list/.svc、关闭日子/关闭设置、has-detail 类串)保持不变。静态自查不等于构建或测试通过。",
"待总工执行:cd web && npm ci && npm run typecheck && npm run lint && npm test && npm run build;PYTHONPATH=src python3.12 web/tests/{browser_check,import_check,real_browser_check,rework_browser_check}.py;python3 scripts/check_requirements.py --base-ref origin/main --handoff docs/requirements/handoff-HEL-823.json 及实际目标引用;git diff --check;并补 1600×1000、1024、390×844、320×568、390×430 两主题截图。"
]
}
+31
View File
@@ -0,0 +1,31 @@
{
"task": "HEL-825 总工:HEL-823(日子/回忆/首建/设置 A3)功能+界面独立审核,通过后更新 8320 隔离测试版",
"baseline_version": "1.10",
"read_commit": "cef8ae5581f68ae81991533698ef05abcb82e659",
"read_notes": "独立审核分支 hel-825-review 自 cef8ae5(hel-822-candidate 远端头,本机核验一致)。实际阅读根 AGENTS.md、docs/requirements/README.md、current.md(v1.10,59项)、coverage.md、changes.md、task-handoff-template.md,及 sources/design-acceptance-v1.md、visual-confirmation-v2.md、integration-plan-v1.md、dynamic-sample-effect-acceptance-20261023.md;核对 CG-006/007/012–016/018/024/029–031、VIS-001–013、AM-001–003、UX-001–006、GOV-001–005、DEL-001 原文与边界。交付包 SHA256 3a8e1720f347f7b5449c2ac5af116553a41a28982046d4d19eadbb1f4e2f2b27 本机独立复算一致;15改1增的 before 对 git cef8ae5、after 对源码字节逐项独立核验一致,无未列明改动、无删除、无路径越界。",
"requirement_ids": ["CG-006", "CG-007", "CG-012", "CG-013", "CG-014", "CG-015", "CG-016", "CG-018", "CG-024", "CG-029", "CG-030", "CG-031", "VIS-001", "VIS-002", "VIS-003", "VIS-004", "VIS-005", "VIS-006", "VIS-007", "VIS-008", "VIS-009", "VIS-010", "VIS-011", "VIS-012", "VIS-013", "AM-001", "AM-002", "AM-003", "UX-001", "UX-002", "UX-003", "UX-004", "UX-005", "UX-006", "GOV-001", "GOV-002", "GOV-003", "GOV-004", "GOV-005", "DEL-001"],
"deliverable": "审核通过并部署。分支 hel-825-review(cef8ae5 之上三提交:0bc4a9e 作者交付原字节、e32a1ac 审核接线修正与证据、本 handoff 提交)。审核接线修正仅一处:web/tests/browser_check.py 关联回忆卡点击改 exact=False——新版 link-card 可访问名称由「标题+来源」拼接,作者改版时漏改该选择器,断言强度不变(heading 断言保留),不放宽隐私或回归断言。另新增 web/tests/hel825_shot.py、hel825_tag_probe.py 两个审核证据脚本。8320 更新为新 release 并存切 current,数据目录与档案不动。",
"acceptance": [
"机械构建:npm ci/typecheck/lint/test/build 全通过;lint 0 errors 2 warnings(ChatPanel:156 为基线已有,ManagePanel:123 unused-directive 为本次引入的非阻塞建议项)。前端 vitest 26/26;后端回归 pytest 142/142(与上批基线一致,本轮实际数字)。",
"四份浏览器脚本全部通过:browser_check 16 PASS(1440/1280/390 三视口:创建校验/失败重试/重开、两主题日子/交谈/设置往返、私密深链中性文案、取消隔离、IME/XSS、发送失败重试、离开摘要过滤);import_check 7 PASS(分页18→12滚动保持、损坏持久化不覆盖首建等);real_browser_check 8 PASS(真实网关流式/取消/epoch 重启/SSE 错误/手机关系恢复);rework_browser_check 9 PASS(12 视口主题组合无遮挡、390×430 首击命中、reading 真实时钟、演示零 API)。",
"需求检查:check_requirements.py --base-ref origin/main 与 origin/agent/agent/de8874a3803b(均带 --handoff handoff-HEL-823.json)通过,59项;git diff --check 干净。",
"隐私与深链:#event=secret 只显示「这一条现在打不开。」,页面无「秘密散步/私密地点」;列表/详情/回忆/摘要无未分享条目(脚本断言+人工核对 LifePanel publicView 路径)。",
"首建:名字空拦、未成年拦、关系不预选(朋友/恋人 aria-pressed=false)、未勾选确认创建禁用、失败资料保留、409 只提供恢复已有她(源码 74-75 行核对+脚本验证)。",
"设置:名字/生辰只读;关系确认框含「记忆与信任都保留」;未保存离开确认守卫(beforeunload+cg:leave-settings 双路径,ManagePanel:43-49 核对);未接入能力如实标注。",
"她此刻浮签几何实测:1600/1440/1101 now-chip 显示于角色下方;1100/1024/390 面板标题上方 .k-near「她此刻 · 在窗边待着」(hel825_tag_probe.py 六档全过)。",
"截图证据:两主题 × 1600×1000/1024/390×844/320×568/390×430 键盘等效共 46 张(docs/frontend/screenshots/hel825/)+ 宽屏/手机两段录屏(docs/frontend/recordings/)。"
],
"deferred": [
"真机软键盘、Safari、Firefox、读屏未测(等效视口不冒充真机,UX-001);本机模型不支持图像目检,截图以 DOM 几何断言+脚本覆盖代替人工目检,全部截图已附卡供人工复核。",
"ManagePanel.tsx:123 unused eslint-disable directive(本次引入,非阻塞)与 ChatPanel.tsx:156 ref cleanup warning(基线已有)留作后续小优化,不阻塞本轮。",
"生活、长期记忆、主动消息、语音口型、天气素材备份、视觉观察真实能力仍未接通(R1–R7 主卡承接);人物仍为参考静帧;本卡不宣称完整产品完成。",
"阶段工程审核通过不等于白栖知体验验收;小样与正式界面替换边界不变。"
],
"requirement_changes": [],
"verification": [
"独立复算:交付 zip SHA256、逐文件 before/after 哈希、清单外无差异、无删除;commit 0bc4a9e 逐字节等于作者交付(16 文件哈希复验全 OK)。",
"机械执行记录:npm ci 176 包、typecheck 0 错、lint 0/2、vitest 26/26、build 514ms 产物 263.64 kB js + 81.28 kB css、pytest 142 passed 6.75s、四浏览器脚本 exit=0、双 base-ref 需求检查通过、git diff --check 通过。",
"审核环境:uv 管理 Python 3.12.14 独立 venv(.venv-hel825,项目 requirements.lock + pytest/playwright),Chromium 156.0.8078.4,系统库复用既有 .browser-libs 用户态副本;未改全局环境、未动队员运行时/模型/认证。",
"部署验证见本卡成果评论:8300/8310 前后可用、8320 服务健康、?demo=1 与普通真实入口实测、epoch 历史保留、回滚方案(切回旧 release current 符号链接)。"
]
}
+27
View File
@@ -0,0 +1,27 @@
{
"task": "HEL-826 总工:核清 R2/R3 数据接缝与 R1 人格缺口,交可直接派施工的小范围接续说明(只读核对,不改产品源码)",
"baseline_version": "1.10",
"read_commit": "2d97050c7e86f909590ffdec3e8bc1aa5627cade",
"read_notes": "读取提交为 origin/hel-825-review 头 2d97050(59项 v1.10)。实际阅读根 AGENTS.md、docs/requirements/README.md、current.md、coverage.md、changes.md、task-handoff-template.md,及 sources/integration-plan-v1.md、design-acceptance-v1.md、visual-confirmation-v2.md、dynamic-sample-effect-acceptance-20261023.md、comment-evidence.json 中 CG-013/014/015 原话(01a15763-1fc5、01a15763-e729、01a15765-2fa8、01a15771-3a93、01a15772-3101、01a15774-ddc6)与 UX-004 来源(01a162eb-1eab);另读本卡附件 HEL-816-接续方案.md 第4–6节。源码核对 src/cybergril/memory/schema.sql、src/cybergril/api/app.py、src/cybergril/core/bazi.py、src/cybergril/core/birth_view.py、src/cybergril/think/scenes.py、config/{character,models}.yaml、web/src/{adapters/real.ts,app/RealApp.tsx,life/LifePanel.tsx,manage/ManagePanel.tsx,domain/privacy.ts}。服务核查仅 8310/8320 GET /api/health(两者 capabilities 如实仅 text=true;8310 epoch 3、8320 epoch 4),未读档案与聊天正文,未做任何变更。",
"requirement_ids": ["CG-007", "CG-008", "CG-012", "CG-013", "CG-014", "CG-015", "CG-016", "CG-018", "CG-021", "CG-023", "CG-031", "AM-001", "AM-002", "AM-003", "UX-004", "UX-006", "GOV-001", "GOV-002", "GOV-003", "GOV-004", "GOV-005", "DEL-001"],
"deliverable": "一份接续说明(本卡附件 HEL-826-接续说明.md):R2 最小生活接入的可审核批次设计(服务端循环、事件来源/时区/幂等键、重启不补造、故障预算停止条件、列表/详情/摘要/搜索/关联回忆/聊天引用的响应前裁剪、told 提交时机与可执行反例),R1 人格深度在 R2/R3 的落点(八字原始事实只读每轮独立、模型诠释/初始习惯/后天成长三层分离、已有档案诚实补建、失败幂等、关系变更不重建人格),含数据表/迁移草案、端点与事件契约、前端绑定点、测试与隔离部署建议、下一张施工卡草稿及 R3/R4 依赖;另加本 handoff。产品源码零改动。",
"acceptance": [
"接续说明标明实际读取版本 v1.10 / 提交 2d97050、关联要求原意与原话来源、已有与缺失的实证(逐条 file:line)、下一批可观察验收项、仍待用户决定的问题。",
"已交付事实与缺失事实分清:R1 真实档案/流式/近20轮在 8310(epoch 3)运行、A1/A2/A3 已过工程审核并部署 8320(epoch 4);生活循环零代码(life_event 表无生产者)、记忆仅测试路径、近20轮上下文不冒充 R3 长期记忆、六段固定模板即 chat 系统提示的底色来源(app.py:385-395、birth_view.py:41-80)、capabilities 前端未消费(real.ts 仅读 epoch/llm.ok)。",
"told 机制定义完整:生成即 told=0;仅在 chat.final 完整送达并经引用判定后才置 1,取消/失败/部分流不置;provenance 记录(telling_log UNIQUE message);方案附可执行反例清单。",
"施工卡草稿可独立执行:覆盖服务重启幂等、流式取消不误标、伪造ID/搜索/摘要/关联引用零泄漏、底色指纹不变、关系变更不重建人格、演示零API、真实聊天回归;压缩时钟测试与真实三天运行分开表述。",
"python3 scripts/check_requirements.py --base-ref origin/main 与 --base-ref origin/agent/agent/de8874a3803b(均带本 handoff)通过;git diff --check 干净。"
],
"deferred": [
"本卡不写产品代码、不部署、不生成真实生活事件、不调用模型生成人格、不做迁移;一切实现进下一张施工卡。",
"R3 长期记忆、R4 主动联系、R5 语音、R6 天气/素材/备份、R7 视觉观察按 DEL-001 与 integration-plan-v1 依赖顺序由主卡承接;真实视频首尾衔接、口型由 HEL-802/803 承接。",
"仍待用户决定(经总管):R2 真实三天运行的启用位置(推荐 8310,R2 已获批,带回滚);生活时区默认 Asia/Shanghai 至 R6 城市选择(工程默认,可后续随城市调整)。",
"需求变更:无。"
],
"requirement_changes": [],
"verification": [
"只读源码核对(file:line 证据见接续说明第一节);8310/8320 health 实测 2026-10-24(本机 curl,capabilities 全部如实 false 除 text)。",
"git 状态干净(本分支仅新增本 handoff 与接续说明不落仓库、以附件交付);未动 8300/8310/8320 任何数据与服务;未访问 4080;未合并任何 PR。",
"结构检查不能代替原话核对:CG-013/014/015 与 UX-004 原话已逐条对照 comment-evidence.json;本卡不声称任何产品功能已通过用户验收。"
]
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

+8 -8
View File
@@ -25,8 +25,8 @@
"reader": {
"top": 762,
"bottom": 792,
"left": 596.5,
"right": 843.5,
"left": 596.484375,
"right": 843.515625,
"height": 30
},
"composer": {
@@ -75,8 +75,8 @@
"reader": {
"top": 762,
"bottom": 792,
"left": 596.5,
"right": 843.5,
"left": 596.484375,
"right": 843.515625,
"height": 30
},
"composer": {
@@ -511,7 +511,7 @@
"reader": {
"top": 252,
"bottom": 282,
"left": 359.5,
"left": 359.484375,
"right": 484.5,
"height": 30
},
@@ -554,7 +554,7 @@
"reader": {
"top": 252,
"bottom": 282,
"left": 359.5,
"left": 359.484375,
"right": 484.5,
"height": 30
},
@@ -586,9 +586,9 @@
],
"motion": {
"inked_lines": {
"a7926846-51f6-4d1a-8057-565c2350c71d:1:0": 1
"6fc4f8ff-218a-4c0a-933c-7982fef596b6:1:0": 1
},
"slow_frames_new_turn_to_reply_s": 2.32
"slow_frames_new_turn_to_reply_s": 2.31
},
"console_errors": [],
"limits": [
Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 KiB

After

Width:  |  Height:  |  Size: 388 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 KiB

After

Width:  |  Height:  |  Size: 433 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 436 KiB

After

Width:  |  Height:  |  Size: 386 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 KiB

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 KiB

After

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 KiB

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 KiB

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 KiB

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 KiB

After

Width:  |  Height:  |  Size: 402 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 KiB

After

Width:  |  Height:  |  Size: 399 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 KiB

After

Width:  |  Height:  |  Size: 283 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 136 KiB

+1 -1
View File
@@ -28,7 +28,7 @@ export function parseState(text: string, sameIdentity?: Identity): DemoState {
if (!messages.every(m => object(m) && str(m.id, 100) && ['user', 'companion'].includes(String(m.role)) && str(m.text) && strings(m.lifeIds) && (!m.status || ['pending', 'failed', 'sent', 'cancelled'].includes(String(m.status)))))
throw new Error('聊天记录不完整。');
// Reconstruct the schema: do not preserve arbitrary imported object keys/prototypes.
return { version: 1, identity: { id: i.id, name: i.name, birth: i.birth, hour: i.hour, relation: i.relation as Identity['relation'], nickname: i.nickname, boundary: i.boundary }, settings: { city: s.city, appearance: s.appearance, reduced: s.reduced, services: Object.fromEntries(Object.keys(defaultSettings.services).map(k => [k, String((s.services as Record<string, unknown>)[k] || '')])) }, events: events.map(e => { const v = e as DemoState['events'][number]; return { id: v.id, title: v.title, text: v.text, time: v.time, place: v.place, kind: v.kind, shared: v.shared === true, memoryIds: [...v.memoryIds] }; }), memories: memories.map(m => { const v = m as DemoState['memories'][number]; return { id: v.id, title: v.title, text: v.text, group: v.group, source: v.source, lifeIds: [...v.lifeIds] }; }), messages: messages.map(m => { const v = m as DemoState['messages'][number]; return { id: v.id, role: v.role, text: v.text, lifeIds: [...v.lifeIds], status: v.status === 'pending' ? 'cancelled' : v.status, turnId: typeof v.turnId === 'string' ? v.turnId : undefined, proactive: v.proactive === true }; }), lastVisit: typeof x.lastVisit === 'number' ? x.lastVisit : Date.now() };
return { version: 1, identity: { id: i.id, name: i.name, birth: i.birth, hour: i.hour, relation: i.relation as Identity['relation'], nickname: i.nickname, boundary: i.boundary }, settings: { city: s.city, appearance: s.appearance, reduced: s.reduced, services: Object.fromEntries(Object.keys(defaultSettings.services).map(k => [k, String((s.services as Record<string, unknown>)[k] || '')])) }, events: events.map(e => { const v = e as DemoState['events'][number]; return { id: v.id, title: v.title, text: v.text, time: v.time, place: v.place, kind: v.kind, shared: v.shared === true, ...(v.shared === true && str(v.told, 100) ? { told: v.told } : {}), memoryIds: [...v.memoryIds] }; }), memories: memories.map(m => { const v = m as DemoState['memories'][number]; return { id: v.id, title: v.title, text: v.text, group: v.group, source: v.source, lifeIds: [...v.lifeIds] }; }), messages: messages.map(m => { const v = m as DemoState['messages'][number]; return { id: v.id, role: v.role, text: v.text, lifeIds: [...v.lifeIds], status: v.status === 'pending' ? 'cancelled' : v.status, turnId: typeof v.turnId === 'string' ? v.turnId : undefined, proactive: v.proactive === true }; }), lastVisit: typeof x.lastVisit === 'number' ? x.lastVisit : Date.now() };
}
export function loadState(): {
state: DemoState | null;
+3 -2
View File
@@ -20,6 +20,7 @@ export function App() {
catch {
return 'moon';
} }), [toast, setToast] = useState(''), [controls, setControls] = useState(false), [fail, setFail] = useState(false), [offline, setOffline] = useState(false), [reconnecting, setReconnecting] = useState(false), [welcome, setWelcome] = useState(!!initial.state && Date.now() - initial.state.lastVisit > 86400000), [reach, setReach] = useState(false), [unread, setUnread] = useState(false), [log, setLog] = useState(false), [focusLife, setFocusLife] = useState(''), [returnTo, setReturnTo] = useState('now'), [presence, setPresence] = useState('在你面前'), [voice, setVoice] = useState(false), [observation, setObservation] = useState(''), [record, setRecord] = useState(false), [instant, setInstant] = useState(0);
const [herFocus, setHerFocus] = useState(0);
const latest = useRef(state);
latest.current = state;
const toastTimer = useRef<ReturnType<typeof setTimeout> | null>(null), reconnectTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -107,14 +108,14 @@ export function App() {
// The reference still is not her new daily life (reading is no longer the default, 01a166aa): say only where she is.
const scene = { mode: area === 'talk' ? 'talk' as const : 'daily' as const, activity: view?.events.length ? '在窗边待着' : '刚搬进来,安静待着', time_band: 'evening', weather: 'demo', outfit: 'home' };
const talking = area === 'talk';
return <><Presenter scene={scene} space={space} theme={theme} instant={instant} observation={observation} onApproach={() => navigate('talk')}/>
return <><Presenter scene={scene} space={space} theme={theme} instant={instant} observation={observation} now={state && !creating ? scene.activity : ''} onApproach={() => navigate('talk')}/>
<header className="topbar"><div className="who"><i className="dot"/><span className="name" title={state?.identity.name}>{state?.identity.name || 'CyberGril'}</span>{state && !creating && <span className="presence">{talking ? presence : scene.activity}</span>}<span className="state">{demo ? '本机演示 · 无真实后台' : '服务尚未接通'}</span></div><div className="env"><span className="chip glass place"><Icon name="pin"/>{state?.settings.city || '杭州'}</span><span className="chip glass weather"><Icon name="cloud"/>雨后 · 模拟</span><span className="theme-switch glass">{(['moon', 'fog'] as Theme[]).map(t => <button key={t} data-t={t} aria-label={t === 'moon' ? '靛蓝月光' : '蓝紫雾光'} aria-pressed={theme === t} onClick={() => setTheme(t)}><i /><span>{t === 'moon' ? '月光' : '雾光'}</span></button>)}</span>{talking && state && <button className="end-talk" onClick={closeTalk}><Icon name="x"/><span>{returnTo === 'days' ? '结束交谈 · 回到日子' : '结束交谈'}</span></button>}</div></header>
{!demo ? <main className="entry"><div className="card glass"><h1>一扇亮着的窗。</h1><p>真实服务还在准备,当前没有连接对话、生活、记忆或备份后台。你可以先体验完整的本机演示。</p><a className="btn-primary" href="?demo=1">进入本机演示</a></div></main> : initial.error ? <main className="entry"><div className="card"><h1>资料暂时读不出来</h1><Status text={initial.error} error/><p>请先检查浏览器存储权限,或备份浏览器中的原始资料后再处理。不会自动清空或覆盖。</p></div></main> : <>
{creating && <CreationWizard fail={fail} onCreate={save} onEnter={() => setCreating(false)}/>}
{!creating && state && view && <>
{area === 'now' && !welcome && <main className="home"><div className="eyebrow">夜色里 · 一扇亮着的窗</div><h1 className="whisper">{state.events.length ? '夜深了,慢慢说。' : '刚住进来,一切都慢慢来。'}</h1><div className="meta"><span><Icon name="moon"/>心情平静 · 演示</span><span><Icon name="heart"/>{state.identity.relation} · 慢慢熟悉</span></div>{view.messages.filter(m => m.role === 'companion').length > 0 && <button className="letter glass" onClick={() => { navigate('talk'); setLog(true); }}><span className="lh"><b>她留给你的</b><span>演示留言</span></span><p>{[...view.messages].reverse().find(m => m.role === 'companion')?.text}</p></button>}<button className="away" onClick={() => navigate('days')}>你不在时 · 看她已经分享的日子 <Icon name="next"/></button><div className="cta"><Button primary small={false} onClick={() => navigate('talk')}><Icon name="chat"/>和她说话</Button><button className="btn-round glass" aria-label="进入模拟语音" onClick={() => { navigate('talk'); notify('点输入框右侧麦克风,可开启无收音的语音模拟。'); }}><Icon name="mic"/></button></div><p className="first-note">{state.identity.name}今晚刚住进来。这里还没有共同的日子。</p><p className="demo-label">本机演示 · 没有真实后台生活</p></main>}
{welcome && area === 'now' && <section className="welcome glass"><div className="eyebrow">回来坐一会儿</div><h2>你不在的这两天</h2><p className="sub">固定演示摘要 · 只展示已分享记录</p><ul>{view.events.filter(e => e.kind !== 'plan').slice(0, 3).map(e => <li key={e.id}><time>{e.time}</time><span>{e.title}</span></li>)}</ul><p className="note">演示中网页关闭不会产生新的生活,服务器后台尚未接通。</p><div className="acts"><Button primary onClick={() => { navigate('talk'); setLog(true); }}>看她留的话</Button><Button onClick={() => navigate('days')}>看她的日子</Button><button className="btn-text" onClick={() => setWelcome(false)}>先待一会儿</button></div></section>}
<LifePanel state={state} open={area === 'days'} onClose={() => navigate('now')} onChat={openEventChat}/><ManagePanel state={state} open={area === 'settings'} onClose={() => navigate('now')} onSave={save} fail={fail} theme={theme} setTheme={setTheme}/>
<LifePanel state={state} open={area === 'days'} now={scene.activity} fail={fail} onClose={() => navigate('now')} onChat={openEventChat} onSettings={() => { navigate('settings'); setHerFocus(n => n + 1); }}/><ManagePanel state={state} open={area === 'settings'} now={scene.activity} focus={herFocus} onClose={() => navigate('now')} onSave={save} fail={fail} theme={theme} setTheme={setTheme}/>
{talking && <ChatPanel state={state} onChange={changeMessages} onPresence={setPresence} onVoice={setVoice} onObservation={setObservation} onRecord={setRecord} offline={offline} fail={fail} log={log} setLog={setLog} focusLife={focusLife}/>}
{offline && <div className={`netbar show glass ${reconnecting ? '' : 'failed'}`} role="status"><span>{reconnecting ? '信号不太好,正在重新连上…' : '模拟断线,草稿还在'}</span><button className="btn-ghost" onClick={reconnect}>再试一次</button></div>}
{reach && <aside className="reach glass show"><div className="rh"><b>{state.identity.name}</b>主动说的 · 模拟</div><p>窗外的雨停了,想跟你说一声。</p><div className="basis">来自已分享的「听了一下午的雨」</div><div className="acts"><Button primary onClick={() => { setReach(false); setUnread(false); setReturnTo(area); setArea('talk'); setFocusLife('rain'); setLog(true); }}>回她</Button><Button onClick={() => setReach(false)}>稍后再看</Button></div></aside>}
+4 -3
View File
@@ -14,6 +14,7 @@ import { spaceFor, useSpace } from '../shared/space';
export function RealApp() {
const [state, setState] = useState<DemoState | null>(null), [ready, setReady] = useState(false), [creating, setCreating] = useState(false), [error, setError] = useState(''), [health, setHealth] = useState<Health>(), [area, setArea] = useState('now'), [log, setLog] = useState(false), [presence, setPresence] = useState('文字已接通'), [record, setRecord] = useState(false), [instant, setInstant] = useState(0);
const [theme, setTheme] = useState<Theme>(() => { try { return localStorage.getItem('cg.theme') === 'fog' ? 'fog' : 'moon'; } catch { return 'moon'; } });
const [herFocus, setHerFocus] = useState(0);
const latest = useRef(state); latest.current = state;
const initialize = useCallback(async () => {
setError(''); setReady(false);
@@ -33,15 +34,15 @@ export function RealApp() {
useEffect(() => { const key = (e: KeyboardEvent) => { if (e.key !== 'Escape' || creating) return; if (log) { setLog(false); return; } if (area === 'talk') { snap(); setInstant(i => i + 1); setArea('now'); return; } if (area !== 'now') navigate('now'); }; window.addEventListener('keydown', key); return () => window.removeEventListener('keydown', key); }, [creating, log, navigate, area]);
const lastReply = state ? [...state.messages].reverse().find(m => m.role === 'companion') : undefined;
const talking = area === 'talk' && !!state && !creating;
return <><Presenter real scene={{ mode: area === 'talk' ? 'talk' : 'daily', activity: '文字已接通', time_band: '', weather: '', outfit: '' }} space={space} theme={theme} instant={instant} observation="" onApproach={() => navigate('talk')}/>
return <><Presenter real scene={{ mode: area === 'talk' ? 'talk' : 'daily', activity: '文字已接通', time_band: '', weather: '', outfit: '' }} space={space} theme={theme} instant={instant} observation="" now={state && !creating ? '生活尚未接通' : ''} onApproach={() => navigate('talk')}/>
<header className="topbar"><div className="who"><i className="dot"/><span className="name" title={state?.identity.name}>{state?.identity.name || 'CyberGril'}</span>{talking && <span className="presence">{presence}</span>}<span className="state">{ready ? '真实档案 · 文字对话' : '连接真实服务'}</span></div><div className="env"><span className="chip glass weather">天气尚未接通</span><span className="theme-switch glass">{(['moon', 'fog'] as Theme[]).map(t => <button key={t} data-t={t} aria-label={t === 'moon' ? '靛蓝月光' : '蓝紫雾光'} aria-pressed={theme === t} onClick={() => setTheme(t)}><i/><span>{t === 'moon' ? '月光' : '雾光'}</span></button>)}</span>{talking && <button className="end-talk" onClick={() => navigate('now')}><Icon name="x"/><span>结束交谈</span></button>}</div></header>
{!ready ? <main className="entry"><div className="card glass"><h1>一扇亮着的窗。</h1><Status text={error || '正在读取服务器档案…'} error={!!error}/>{error && <><p>请检查真实服务是否可达。资料仍在服务器保存。</p><Button primary onClick={() => void initialize()}>重新连接</Button></>}</div></main> : <>
{creating && <CreationWizard real fail={false} onCreate={setState} onEnter={() => setCreating(false)}/>}
{!creating && state && <>
{area === 'now' && <main className="home"><div className="eyebrow">一扇亮着的窗</div><h1 className="whisper">慢慢说,我在这里。</h1><div className="meta"><span><Icon name="heart"/>{state.identity.relation} · 慢慢熟悉</span></div><button className="away" onClick={() => navigate('days')}>日子与回忆 · 后台待接入 <Icon name="next"/></button>{lastReply && <button className="letter glass" onClick={() => { navigate('talk'); setLog(true); }}><span className="lh"><b>最近说过的话</b><span>打开完整记录</span></span><p>{lastReply.text}</p></button>}<div className="cta"><Button primary small={false} onClick={() => navigate('talk')}><Icon name="chat"/>和她说话</Button></div><p className="first-note">资料与聊天已保存在服务器。生活、长期记忆与语音尚未接通。</p>{health && !health.llm.ok && <Status error text="模型暂时不可达,档案和历史仍可查看。"/>}</main>}
{area === 'talk' && <ChatPanel real state={state} onChange={changeMessages} onPresence={setPresence} onVoice={ignoreVoice} onObservation={ignoreVoice} onRecord={setRecord} offline={false} fail={false} log={log} setLog={setLog} focusLife=""/>}
<LifePanel real state={state} open={area === 'days'} onClose={() => navigate('now')} onChat={() => { navigate('talk'); setLog(true); }}/>
<ManagePanel real state={state} open={area === 'settings'} onClose={() => navigate('now')} onSave={setState} fail={false} theme={theme} setTheme={setTheme}/>
<LifePanel real state={state} open={area === 'days'} now="生活尚未接通" onClose={() => navigate('now')} onChat={() => { navigate('talk'); setLog(true); }} onSettings={() => { navigate('settings'); setHerFocus(n => n + 1); }}/>
<ManagePanel real state={state} open={area === 'settings'} now="生活尚未接通" focus={herFocus} onClose={() => navigate('now')} onSave={setState} fail={false} theme={theme} setTheme={setTheme}/>
<nav className="nav glass" aria-label="主导航">{[['now','moon','此刻'],['talk','chat','交谈'],['days','book','日子'],['settings','gear','设置']].map(([id, icon, label]) => <button key={id} className="nav-item" aria-current={area === id ? 'page' : undefined} onClick={() => navigate(id)}><Icon name={icon}/>{label}</button>)}</nav></>}
</>}</>;
}
+4 -4
View File
@@ -5,11 +5,11 @@ export function freshState(identity: Identity): DemoState {
// Loaded only through an explicit demo action; never a fabricated background life loop.
export function sampleDays(state: DemoState, long = false): DemoState {
const events: DemoState['events'] = [
{ id: 'book', title: '读到了书里的那片海', text: '翻到讲海的那一页,忽然想起你说过喜欢安静的地方。', time: '10月21日 19:40', place: '卧室 · 窗边', kind: 'now', shared: true, memoryIds: ['habit'] },
{ id: 'tea', title: '给自己泡了一杯热茶', text: '杯子捧在手里,夜晚就慢了下来。', time: '10月21日 16:20', place: '卧室', kind: 'done', shared: true, memoryIds: [] },
{ id: 'rain', title: '听了一下午的雨', text: '雨滴在玻璃上跑得一快一慢,很像一段没有歌词的曲子。', time: '10月20日 15:30', place: '卧室 · 窗边', kind: 'done', shared: true, memoryIds: ['rain-memory'] },
{ id: 'book', title: '读到了书里的那片海', text: '翻到讲海的那一页,忽然想起你说过喜欢安静的地方。', time: '10月21日 19:40', place: '卧室 · 窗边', kind: 'now', shared: true, told: '19:46 告诉你', memoryIds: ['habit'] },
{ id: 'tea', title: '给自己泡了一杯热茶', text: '杯子捧在手里,夜晚就慢了下来。', time: '10月21日 16:20', place: '卧室', kind: 'done', shared: true, told: '16:40 告诉你', memoryIds: [] },
{ id: 'rain', title: '听了一下午的雨', text: '雨滴在玻璃上跑得一快一慢,很像一段没有歌词的曲子。', time: '10月20日 15:30', place: '卧室 · 窗边', kind: 'done', shared: true, told: '17:05 留言给你', memoryIds: ['rain-memory'] },
{ id: 'secret', title: '未分享的秘密散步', text: '这段未分享的生活不能出现在任何视图里。', time: '10月21日 13:00', place: '私密地点', kind: 'done', shared: false, memoryIds: ['secret-memory'] },
{ id: 'plan', title: '明天想读完这一章', text: '如果精神好,就再读一会儿。计划也可能会变。', time: '10月22日 20:00', place: '卧室', kind: 'plan', shared: true, memoryIds: [] }
{ id: 'plan', title: '明天想读完这一章', text: '如果精神好,就再读一会儿。计划也可能会变。', time: '10月22日 20:00', place: '卧室', kind: 'plan', shared: true, told: '10月21日 21:10 告诉你', memoryIds: [] }
];
if (long)
for (let i = 0; i < 40; i++)
+2
View File
@@ -23,6 +23,8 @@ export interface LifeEvent {
place: string;
kind: 'done' | 'now' | 'plan';
shared: boolean;
// When and how she told you ("19:34 告诉你", "你们一起经历的"); only ever present on records she has shared.
told?: string;
memoryIds: string[];
}
export interface Memory {
+84 -9
View File
@@ -1,16 +1,27 @@
import { useEffect, useRef, useState } from 'react';
import type { DemoState } from '../domain/model';
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import type { DemoState, LifeEvent, Memory } from '../domain/model';
import { publicView } from '../domain/privacy';
import { Button, Icon } from '../shared/ui';
export function LifePanel({ state, open, onClose, onChat, real = false }: {
import { delay } from '../adapters/demo';
// HEL-815 page design: a page lying on your side of the table while the room steps back. Only what she has already
// told you is ever rendered (AM-001), so there is no "not told yet" label, filter or switch anywhere; any link the
// client cannot resolve opens one neutral "can't open" state that reveals nothing about whether the record exists.
const KIND = { plan: '打算', now: '正在', done: '已经发生' } as const;
const MEMORY_GROUPS = ['我们一起的', '你们的小习惯', '她知道的你', '她的成长'];
const phone = () => matchMedia('(max-width:720px)').matches;
type Load = 'ok' | 'loading' | 'error';
export function LifePanel({ state, open, onClose, onChat, onSettings, now = '', fail = false, real = false }: {
real?: boolean;
state: DemoState;
open: boolean;
now?: string;
fail?: boolean;
onClose: () => void;
onChat: (id: string) => void;
onSettings?: () => void;
}) {
const view = publicView(state), [tab, setTab] = useState('life'), [selection, setSelection] = useState(''), [limit, setLimit] = useState(18);
const list = useRef<HTMLDivElement>(null);
const view = publicView(state), [tab, setTab] = useState('life'), [selection, setSelection] = useState(''), [limit, setLimit] = useState(18), [load, setLoad] = useState<Load>('ok'), [more, setMore] = useState(false);
const list = useRef<HTMLDivElement>(null), detail = useRef<HTMLElement>(null), scroll = useRef<Record<string, number>>({}), wasOpen = useRef(false), request = useRef<AbortController | null>(null);
useEffect(() => { if (open) {
const params = new URLSearchParams(location.hash.slice(1));
const id = params.get('event');
@@ -19,9 +30,73 @@ export function LifePanel({ state, open, onClose, onChat, real = false }: {
setSelection(id);
}
} }, [open]);
// Demo only: the failure switch shows how a list that could not be read looks; nothing real is requested.
useEffect(() => { if (open && !wasOpen.current && !real) setLoad(fail ? 'error' : 'ok'); wasOpen.current = open; if (!open) { request.current?.abort(); setMore(false); } }, [open, fail, real]);
useEffect(() => () => request.current?.abort(), []);
async function retry() { request.current?.abort(); const c = new AbortController(); request.current = c; setLoad('loading'); try { await delay(600, c.signal); setLoad(fail ? 'error' : 'ok'); } catch { /* Closed or replaced. */ } }
async function earlier() { request.current?.abort(); const c = new AbortController(); request.current = c; setMore(true); try { await delay(real ? 0 : 450, c.signal); setLimit(x => x + 12); } catch { /* Closed. */ } finally { if (!c.signal.aborted) setMore(false); } }
// Each tab keeps its own reading position; switching back lands where you left it.
// A hidden panel is display:none, which drops its scroll offset; reopening (e.g. "结束交谈 · 回到日子") puts it back.
useLayoutEffect(() => { if (list.current && open) list.current.scrollTop = scroll.current[tab] || 0; }, [tab, open]);
useLayoutEffect(() => { if (detail.current) detail.current.scrollTop = 0; }, [selection, tab]);
const switchTab = (t: string) => { if (list.current) scroll.current[tab] = list.current.scrollTop; setTab(t); setSelection(''); };
const select = (id: string, t = tab) => { if (t !== tab) switchTab(t); setSelection(id); };
// Esc on a phone closes the pushed detail first; the app then closes the panel on the next press.
useEffect(() => { if (!open || !selection) return; const key = (e: KeyboardEvent) => { if (e.key !== 'Escape' || !phone() || document.querySelector('.modal.open')) return; e.stopImmediatePropagation(); setSelection(''); }; window.addEventListener('keydown', key, true); return () => window.removeEventListener('keydown', key, true); }, [open, selection]);
const ordered = [...view.events.filter(e => e.kind === 'plan'), ...view.events.filter(e => e.kind !== 'plan')], shown = ordered.slice(0, limit);
const day = (e: LifeEvent) => e.kind === 'plan' ? '她说过的打算' : e.time.split(' ')[0];
const event = tab === 'life' ? view.events.find(e => e.id === selection) : undefined, memory = tab === 'memory' ? view.memories.find(m => m.id === selection) : undefined;
const select = (id: string, t = tab) => { setTab(t); setSelection(id); };
return <section className={`pane glass read ${open ? 'open' : ''} ${selection ? 'has-detail' : ''}`} hidden={!open} aria-label="日子"><header><h2>日子</h2><div className="tabs" role="tablist">{[['life', '她的日子'], ['memory', '我们的回忆']].map(([t, l]) => <button role="tab" key={t} aria-selected={tab === t} onClick={() => { setTab(t); setSelection(''); }}>{l}</button>)}</div><span className="grow"/><span className="tag-demo">{real ? '后台待接入' : '演示数据'}</span><button className="btn-round sm" aria-label="关闭日子" onClick={onClose}><Icon name="x"/></button></header><div className="cols"><div className="list" ref={list}>
{tab === 'life' ? <><div className="away-card"><b>你不在时</b>{real ? '这里只会显示她已经讲给你听的事。生活循环尚未接通,当前没有可核实的生活记录。' : '这里只显示她已经讲给你听的事。演示没有真实后台生活。'}</div><div className="legend"><span><i className="k done"/>已发生</span><span><i className="k now"/>正在</span><span><i className="k plan"/>打算</span></div>{view.events.length === 0 ? <div className="empty">{real ? '还没有可展示的生活记录' : '她今晚刚住进来,还没有发生什么。'}<small>{real ? '后台待接入,不用示例经历填充。你们说过的话可在交谈的完整记录中查看。' : '演示资料可以从「演示场景」载入。'}</small></div> : view.events.slice(0, limit).map((e, i) => <div key={e.id}>{(i === 0 || view.events[i - 1].time.split(' ')[0] !== e.time.split(' ')[0]) && <div className="grp">{e.kind === 'plan' ? '之后的打算' : e.time.split(' ')[0]}</div>}<button className={`ev told ${e.kind}`} aria-current={selection === e.id} onClick={() => select(e.id)}><time>{e.time.split(' ')[1]}</time><i className={`k ${e.kind}`}/><span><span className="tt">{e.title}</span><span className="sub"><span className="tag">已经讲过</span>{e.memoryIds.length > 0 && <span className="tag accent">和你有关</span>}</span></span></button></div>)}{limit < view.events.length && <div className="more"><Button onClick={() => setLimit(x => x + 12)}>看更早的日子</Button></div>}</> : view.memories.length === 0 && !real ? <div className="empty">聊着聊着就会有了。</div> : ['我们一起的', '你们的小习惯', '她知道的你', '她的成长'].map(group => <div key={group}><div className="grp">{group}</div>{real && <div className="empty">暂无可核实的回忆<small>长期记忆尚未接通;文字聊天记录独立保留。</small></div>}{view.memories.filter(m => m.group === group).map(m => <button className="mem" key={m.id} aria-current={selection === m.id} onClick={() => select(m.id)}>{m.title}<small>{m.source}</small></button>)}</div>)}
</div><article className="detail"><button className="btn-text back" onClick={() => setSelection('')}><Icon name="back"/>返回{tab === 'life' ? '她的日子' : '我们的回忆'}</button>{event ? <><div className="d-kicker"><i className={`k ${event.kind}`}/>{event.kind === 'now' ? '正在' : event.kind === 'plan' ? '打算 · 计划可能会变' : '已经发生'}<span className="tag">已经讲给你听</span></div><h3 className="d-title">{event.title}</h3><div className="d-meta">{event.time} · {event.place}</div><blockquote className="quote">{event.text}<small>{view.identity.name}说过的话 · 演示</small></blockquote><div className="d-sec">和这件事有关的回忆</div><div className="links">{event.memoryIds.map(id => { const m = view.memories.find(x => x.id === id); return m && <button className="link-chip" key={id} onClick={() => select(id, 'memory')}><Icon name="link"/>{m.title}</button>; })}</div><div className="d-sec">那时候的聊天</div><Button onClick={() => onChat(event.id)}>看那段聊天</Button><div className="d-foot">这是模拟生活里的一条记录,不是真实发生的事。画面只按状态展示,不会反过来改写生活。</div></> : memory ? <><div className="d-kicker">{memory.group} · 演示回忆</div><h3 className="d-title">{memory.title}</h3><div className="d-meta">{memory.source}</div><blockquote className="quote">{memory.text}</blockquote>{memory.group === '她的成长' && <div className="growth"><div><h4>最初就有的</h4>细腻、慢热</div><div><h4>后来慢慢有的</h4>{memory.text}</div></div>}<div className="d-sec">来自这些日子</div><div className="links">{memory.lifeIds.map(id => { const e = view.events.find(x => x.id === id); return e && <button className="link-chip" key={id} onClick={() => select(id, 'life')}>{e.title}</button>; })}</div></> : selection ? <div className="empty">这条记录暂时不可见。<small>只会展示她已分享的事。</small></div> : <div className="d-empty"><div><Icon name="book"/>{real ? '这里会保留日子详情、回忆与聊天的关联。后台接通后,已分享的内容会出现在列表中。' : '选一件小事,慢慢读。'}</div></div>}</article></div></section>;
const name = view.identity.name, demoTag = !real && <span className="tag-demo">演示数据</span>;
const lines = (e: LifeEvent) => view.messages.filter(m => m.lifeIds.includes(e.id));
const said = (who: string, text: string) => <blockquote className="quote"><span className="who"><i/>{who}</span>{text}</blockquote>;
const linkCard = (key: string, title: string, sub: string, go: () => void) => <button className="link-card" key={key} aria-describedby={`lc-${key}`} onClick={go}><span><b>{title}</b><small id={`lc-${key}`}>{sub}</small></span><Icon name="next"/></button>;
function eventView(e: LifeEvent) {
const mems = e.memoryIds.map(id => view.memories.find(m => m.id === id)).filter((m): m is Memory => !!m), chat = lines(e);
return <>
<div className="d-kicker"><i className={`k ${e.kind}`}/>{KIND[e.kind]} · {e.time} · {e.place}</div>
<h3 className="d-title">{e.title}</h3>
<p className="d-told">{e.told ? `她在 ${e.told}` : '她讲给你听过的事'}{e.kind === 'plan' ? ' · 计划可能会变' : ''}</p>
{said(name, e.text)}
{mems.length > 0 && <><div className="d-sec">和这件事有关的回忆</div><div className="link-list">{mems.map(m => linkCard(m.id, m.title, m.source, () => select(m.id, 'memory')))}</div></>}
<div className="d-sec">那时候的聊天</div>
{chat.length ? <div className="said-then">{chat.map(m => <p key={m.id} data-role={m.role}><span className="who"><i/>{m.role === 'user' ? '你' : name}</span>{m.text}</p>)}</div> : <p className="d-dim">那时候没有留下聊天记录。</p>}
<Button onClick={() => onChat(e.id)}>在交谈里看这段<Icon name="next"/></Button>
<div className="d-foot">{demoTag}这是模拟生活里的一条记录,不是真实发生的事。画面只按记录选片,不会反过来改写她的生活。</div>
</>;
}
function memoryView(m: Memory) {
const from = m.lifeIds.map(id => view.events.find(e => e.id === id)).filter((e): e is LifeEvent => !!e);
return <>
<div className="d-kicker"><i className={`k ${m.group === '她的成长' ? 'grow' : 'mem'}`}/>{m.group} · {m.source}</div>
<h3 className="d-title">{m.title}</h3>
<p className="d-told">她是这样记得的</p>
{said(name, m.text)}
{m.group === '她的成长' && <p className="d-note">这是后来慢慢有的。成长单独记录,不改写她最初的底色。{onSettings && <button className="btn-text" onClick={onSettings}>在设置里看底色与成长<Icon name="next"/></button>}</p>}
<div className="d-sec">来自这些日子</div>
{from.length ? <div className="link-list">{from.map(e => linkCard(e.id, e.title, e.time, () => select(e.id, 'life')))}</div> : <p className="d-dim">这条回忆来自你们的日常聊天,没有对应的某一天。</p>}
<div className="d-foot">{demoTag}回忆由她在相处中整理,只引用她讲过的日子。</div>
</>;
}
const failed = <div className="state-card" role="alert"><i className="state-mark"><Icon name="warn"/></i><p className="state-t">这几天的事一时没翻出来。</p><p>不是你的问题,记录也没有丢。</p><Button onClick={() => void retry()}>再试一次</Button></div>;
const skeleton = (n: number) => <div className="skel" aria-hidden="true">{Array.from({ length: n }, (_, i) => <i key={i} style={{ width: `${[78, 62, 70, 54, 66][i % 5]}%` }}/>)}</div>;
function lifeList() {
if (load === 'loading') return <><p className="grp" role="status">正在翻她的日子…</p>{skeleton(6)}</>;
if (load === 'error') return failed;
if (!view.events.length) return <div className="empty">{real ? '还没有可展示的生活记录' : '她今晚刚住进来,还没有发生什么。'}<small>{real ? '生活后台尚未接通,不用示例经历填充。你们说过的话可在交谈的完整记录中查看。' : '等她跟你讲起,日子会一条条留在这里。演示资料可以从「演示场景」载入。'}</small></div>;
return <>{shown.map((e, i) => <div key={e.id}>{(i === 0 || day(shown[i - 1]) !== day(e)) && <div className="grp">{day(e)}</div>}<button className={`ev told ${e.kind}`} aria-current={selection === e.id} onClick={() => select(e.id)}><time>{e.kind === 'plan' ? e.time : e.time.split(' ')[1]}</time><i className={`k ${e.kind}`}/><span><span className="tt">{e.title}</span><span className="sn">{e.text}</span>{(e.kind !== 'done' || e.memoryIds.length > 0) && <span className="sub">{e.kind === 'plan' && <span className="tag">计划可能会变</span>}{e.kind === 'now' && <span className="tag accent">正在</span>}{e.memoryIds.length > 0 && <span className="tag">和你有关</span>}</span>}</span></button></div>)}
{more ? <p className="more-busy" role="status"><i className="spin"/>正在翻更早的日子…</p> : limit < ordered.length ? <div className="more"><Button onClick={() => void earlier()}>看更早的日子</Button></div> : <p className="list-end">再往前,就是她刚住进来的那天了。</p>}</>;
}
function memoryList() {
if (load === 'loading') return skeleton(5);
if (load === 'error') return failed;
if (!real && !view.memories.length) return <div className="empty">还没有共同的回忆。<small>聊着聊着就会有了。</small></div>;
return MEMORY_GROUPS.map(group => { const items = view.memories.filter(m => m.group === group); return <div key={group}><div className="grp">{group}{!real && <span>{items.length}</span>}</div>{real && <div className="empty">暂无可核实的回忆<small>长期记忆尚未接通;文字聊天记录独立保留。</small></div>}{items.map(m => <button className="mem" key={m.id} aria-current={selection === m.id} onClick={() => select(m.id)}><i className={`k ${group === '她的成长' ? 'grow' : 'mem'}`}/><span><small className="src">{m.source}</small><b>{m.title}</b><span className="sn">{m.text}</span></span></button>)}</div>; });
}
const blank = load !== 'ok' || (tab === 'life' ? !view.events.length : !view.memories.length);
return <section className={`pane glass read ${open ? 'open' : ''} ${selection ? 'has-detail' : ''}`} hidden={!open} aria-label="日子"><header><div className="ttl"><small className="kicker"><span className="k-wide">日子 · {real ? '后台待接入' : '演示数据'}</span><span className="k-near"><i/>她此刻 · {now || '安静待着'}</span></small><h2>{tab === 'life' ? '她的日子' : '我们的回忆'}</h2></div><span className="grow"/>{real ? <span className="tag-demo">后台待接入</span> : demoTag}<button className="btn-round sm" aria-label="关闭日子" onClick={onClose}><Icon name="x"/></button></header>
<div className="pane-tabs"><div className="tabs" role="tablist">{[['life', '她的日子'], ['memory', '我们的回忆']].map(([t, l]) => <button role="tab" key={t} aria-selected={tab === t} onClick={() => switchTab(t)}>{l}</button>)}</div><span className="tabnote">{tab === 'life' ? '只有她讲给你听过的事,才会出现在这里' : '她记得的你们,和她后来慢慢有的'}</span></div>
<div className="cols"><div className="list" ref={list} onScroll={e => { scroll.current[tab] = e.currentTarget.scrollTop; }}>{tab === 'life' ? lifeList() : memoryList()}</div>
<article className="detail" ref={detail}><button className="btn-text back" onClick={() => setSelection('')}><Icon name="back"/>返回{tab === 'life' ? '她的日子' : '我们的回忆'}</button>
{event ? <div className="d-in" key={`e-${event.id}`}>{eventView(event)}</div> : memory ? <div className="d-in" key={`m-${memory.id}`}>{memoryView(memory)}</div> : selection ? <div className="state-card"><i className="state-mark"><Icon name="warn"/></i><p className="state-t">这一条现在打不开。</p><p>可能是链接已经过期。</p><Button onClick={() => setSelection('')}>回到{tab === 'life' ? '她的日子' : '我们的回忆'}</Button></div> : load === 'loading' ? skeleton(5) : <div className="d-empty"><div><Icon name="book"/>{real ? '后台接通后,她讲给你听过的事会出现在左侧;这里保留日子详情、回忆与聊天的关联。' : blank ? (tab === 'life' ? '选一天,看她那天跟你讲过的事。' : '选一条,看她怎么记得。') : tab === 'life' ? '选一件小事,慢慢读。' : '选一条,看她怎么记得。'}</div></div>}
</article></div></section>;
}
+47 -15
View File
@@ -1,32 +1,55 @@
import { api, type Color, type RealIdentity } from '../adapters/real';
import { newId } from '../domain/id';
import { useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import { validateCreation, type Identity } from '../domain/model';
import { freshState } from '../demo/fixtures';
import { delay } from '../adapters/demo';
import { BaseColor, Button, Field, Status } from '../shared/ui';
import { BaseColor, Button, Field, Icon, Status } from '../shared/ui';
import type { DemoState } from '../domain/model';
const HOURS = ['子时', '丑时', '寅时', '卯时', '辰时', '巳时', '午时', '未时', '申时', '酉时', '戌时', '亥时'];
// A random birthday she could have: an adult of 19–35, any month, a day every month has, any hour.
function randomBirth(now = new Date()) {
const pick = (n: number) => Math.floor(Math.random() * n);
return { birth: `${now.getFullYear() - 19 - pick(17)}-${String(1 + pick(12)).padStart(2, '0')}-${String(1 + pick(28)).padStart(2, '0')}`, hour: HOURS[pick(12)] };
}
// What the left-hand story says at each moment of the first meeting (HEL-815).
const STORY: Record<string, [string, string]> = {
0: ['先给她一个名字,和一个属于她的生日。', '名字由你来起。生日可以随机,也可以由你指定。'],
1: ['这是她出生时带来的底色。', '底色只读。她以后的样子,由你们的相处慢慢长出来。'],
2: ['你们从什么关系开始?', '不替你选。以后也可以在设置里调整。'],
3: ['确认之后,她就住进来了。', '这件事只会发生一次。'],
run: ['她在收拾东西,马上就好。', '窗外的灯一直亮着。'],
fail: ['差一点就好了。', '你填的都还在。'],
4: ['她住进来了。', '去看看她吧。']
};
const RELATIONS: [string, string][] = [['朋友', '像朋友一样相处,慢慢熟起来。'], ['恋人', '从恋人开始,彼此更亲近一些。']];
export function CreationWizard({ onCreate, onEnter, fail, real = false }: {
real?: boolean;
onCreate: (s: DemoState) => void;
onEnter: () => void;
fail: boolean;
}) {
const [step, setStep] = useState(0), [name, setName] = useState(''), [birth, setBirth] = useState('2000-10-18'), [hour, setHour] = useState('亥时'), [relation, setRelation] = useState(''), [nickname, setNickname] = useState(''), [agreed, setAgreed] = useState(false), [error, setError] = useState(''), [phase, setPhase] = useState(-1), [busy, setBusy] = useState(false);
const [initial] = useState(randomBirth);
const [step, setStep] = useState(0), [name, setName] = useState(''), [birth, setBirth] = useState(initial.birth), [hour, setHour] = useState(initial.hour), [how, setHow] = useState<'random' | 'pick'>('random'), [relation, setRelation] = useState(''), [nickname, setNickname] = useState(''), [boundary, setBoundary] = useState(''), [agreed, setAgreed] = useState(false), [error, setError] = useState(''), [phase, setPhase] = useState(-1), [busy, setBusy] = useState(false), [back, setBack] = useState(false);
const [color, setColor] = useState<Color>();
const nameField = useRef<HTMLInputElement>(null), birthField = useRef<HTMLInputElement>(null), relationGroup = useRef<HTMLDivElement>(null);
const labels = ['出生资料', '她的底色', '你们的关系', '最终确认'];
const field = error.includes('名字') ? 'name' : error.includes('出生') ? 'birth' : error.includes('关系') ? 'relation' : '';
// A rejected step puts the cursor where the problem is, so the next key fixes it.
useEffect(() => { if (field === 'name') nameField.current?.focus(); else if (field === 'birth') birthField.current?.focus(); else if (field === 'relation') relationGroup.current?.querySelector('button')?.focus(); }, [field, error]);
const go = (to: number) => { setBack(to < step); setStep(to); };
async function next() { const err = validateCreation(name, birth, step === 2 ? relation : '朋友'); if (err) {
setError(err);
return;
} setError(''); if (real && step === 0) { setBusy(true); try { setColor(await api<Color>('companion/preview', { method: 'POST', body: JSON.stringify({ name, birth, hour }) })); } catch (e) { setError((e as Error).message); return; } finally { setBusy(false); } } setStep(s => s + 1); }
} setError(''); if (real && step === 0) { setBusy(true); try { setColor(await api<Color>('companion/preview', { method: 'POST', body: JSON.stringify({ name, birth, hour }) })); } catch (e) { setError((e as Error).message); return; } finally { setBusy(false); } } go(step + 1); }
async function create() { const err = validateCreation(name, birth, relation); if (err || !agreed) {
setError(err || '请先确认你已了解。');
return;
} setBusy(true); setError(''); try {
if (real) {
setPhase(0);
const identity = await api<RealIdentity>('companion', { method: 'POST', body: JSON.stringify({ name, birth, hour, relation, nickname }) });
setPhase(2); onCreate({ ...freshState(identity), messages: [], events: [], memories: [] }); setStep(4); return;
const identity = await api<RealIdentity>('companion', { method: 'POST', body: JSON.stringify({ name, birth, hour, relation, nickname, ...(boundary.trim() ? { boundary: boundary.trim() } : {}) }) });
setPhase(2); onCreate({ ...freshState(identity), messages: [], events: [], memories: [] }); go(4); return;
}
const c = new AbortController();
for (let p = 0; p < 3; p++) {
@@ -35,9 +58,9 @@ export function CreationWizard({ onCreate, onEnter, fail, real = false }: {
if (fail && p === 1)
throw new Error('这一步没完成,资料都还在。可以重试,或返回修改。');
}
const identity: Identity = { id: newId(), name: name.trim(), birth, hour, relation: relation as Identity['relation'], nickname: nickname.trim(), boundary: '尊重彼此的节奏' };
const identity: Identity = { id: newId(), name: name.trim(), birth, hour, relation: relation as Identity['relation'], nickname: nickname.trim(), boundary: boundary.trim() || '尊重彼此的节奏' };
onCreate(freshState(identity));
setStep(4);
go(4);
}
catch (e) {
setError((e as Error).message);
@@ -45,11 +68,20 @@ export function CreationWizard({ onCreate, onEnter, fail, real = false }: {
finally {
setBusy(false);
} }
return <main className="create"><div className="story"><div className="eyebrow">一扇窗 · 一个开始</div><h1>{step === 4 ? '她住进来了。' : step === 2 ? '你想和她,怎样相处?' : '在夜色里,留一盏灯。'}</h1><p>{real ? '资料与对话保存在服务器,重开或换设备都能恢复同一位她。最终确认前不会建档。' : '这是本机演示。你的选择只保存在这个浏览器,没有创建服务器上的真实伴侣。'}</p><div className="single">首版只有一位。创建后不提供切换或清空重建。</div></div><section className="wiz glass read"><div className="steps">{labels.map((l, i) => <span className={i <= step ? 'on' : ''} key={l}/>)}</div><div className="steplabel">{step < 4 ? `${step + 1} / 4 · ${labels[step]}` : '创建完成'}</div><div className="wbody"><div className="wstep on" key={step}>
{step === 0 && <><h2>先认识她的开始</h2><p className="lead">名字由你起,生辰也可以在确认前修改。</p><Field label="她的名字"><input className="input" value={name} maxLength={20} onChange={e => setName(e.target.value)} autoComplete="off"/></Field><Field label="出生日期(公历)" hint="下一步会换算真实农历,并显示四柱与说明。"><input className="input" type="date" value={birth} onChange={e => setBirth(e.target.value)}/></Field><Field label="出生时辰" hint="北京时间;子时23:00–00:59,丑时01:00–02:59,之后每两小时一段。排盘取时辰内偶数整点,子时取本日00:00。"><select className="select" value={hour} onChange={e => setHour(e.target.value)}>{['子时', '丑时', '寅时', '卯时', '辰时', '巳时', '午时', '未时', '申时', '酉时', '戌时', '亥时'].map(h => <option key={h}>{h}</option>)}</select></Field><Button onClick={() => { setBirth(`${1990 + Math.floor(Math.random() * 13)}-${String(1 + Math.floor(Math.random() * 12)).padStart(2, '0')}-18`); }}>自动生成一组生辰</Button></>}
{step === 1 && <><h2>{name.trim()}的底色</h2><p className="lead">底色是倾向,会留下诠释和成长的空间。</p><BaseColor color={real ? color : undefined}/></>}
{step === 2 && <><h2>由你选择关系</h2><p className="lead">没有预选答案。以后可以在设置中确认修改,记忆会保留。</p><div className="seg">{['朋友', '恋人'].map(r => <button aria-pressed={relation === r} key={r} onClick={() => setRelation(r)}>{r}</button>)}</div><Field label="她怎么称呼你(可选)"><input className="input" maxLength={40} value={nickname} onChange={e => setNickname(e.target.value)}/></Field></>}
{step === 3 && <><h2>让这次相识,有一个开始</h2><div className="sum">{[['名字', name], ['生辰', `${birth} · ${hour}`], ['关系', relation], ['称呼', nickname || '暂时不设']].map(([k, v]) => <div className="r" key={k}><span>{k}</span><b>{v}</b></div>)}</div><BaseColor color={real ? color : undefined}/><label className="check"><input type="checkbox" checked={agreed} onChange={e => setAgreed(e.target.checked)}/>{real ? '我明白:这将创建服务器上的真实档案;创建后底色只读,只保留一位伴侣。' : '我明白:这是本机演示;创建后底色只读,只保留一位伴侣。'}</label>{phase >= 0 && <ul className="phases">{(real ? ['核对真实排盘', '保存唯一档案', '档案已保存'] : ['排好底色(示例)', '形成最初的小习惯(示例)', '布置房间(示例)']).map((p, i) => <li key={p} className={i < phase ? 'ok' : i === phase ? (error ? 'fail' : 'run') : ''}><i>{i < phase ? '✓' : ''}</i>{p}</li>)}</ul>}</>}
{step === 4 && <div className="born"><div className="halo"/><h2>{name.trim()}住进来了</h2><p className="lead">刚开始,还没有共同的日子。聊着聊着就会有了。</p></div>}
<Status text={error} error/></div></div><footer className="wfoot">{step > 0 && step < 4 && <Button disabled={busy} onClick={() => { setError(''); setStep(error ? 0 : step - 1); }}>{error ? '返回修改' : '上一步'}</Button>}<span className="grow"/>{step < 3 ? <Button primary disabled={busy} onClick={() => void next()}>下一步</Button> : step === 3 ? <Button primary disabled={!agreed || busy} onClick={() => void create()}>{busy ? '正在创建…' : error ? '再试一次' : '确认创建'}</Button> : <Button primary onClick={onEnter}>去看看她</Button>}</footer></section></main>;
const reroll = () => { const r = randomBirth(); setBirth(r.birth); setHour(r.hour); setHow('random'); setError(''); };
const [y, m, d] = birth.split('-');
const story = STORY[step === 4 ? 4 : step === 3 && phase >= 0 ? (error ? 'fail' : busy ? 'run' : 3) : step];
// One companion only: the server refuses a second (409). Reopening restores the one that exists; nothing is overwritten.
const exists = real && error.includes('已经有一位她');
return <main className="create"><div className="story"><div className="eyebrow">初次见面{step < 4 ? ` · 第 ${step + 1} 步,共 4 步` : ' · 第一晚'}</div><h1>{story[0]}</h1><p className="quiet">{story[1]}</p><p>{real ? '资料与对话保存在服务器,重开或换设备都能恢复同一位她。最终确认前不会建档。' : '这是本机演示。你的选择只保存在这个浏览器,没有创建服务器上的真实伴侣。'}</p><div className="single"><Icon name="lock"/>首版只有一位。创建后不提供切换或清空重建。</div></div><section className="wiz glass read"><div className="steps">{labels.map((l, i) => <span className={i <= step ? 'on' : ''} key={l}/>)}</div><div className="steplabel">{step < 4 ? `${step + 1} / 4 · ${labels[step]}` : '创建完成'}</div><div className="wbody"><div className={`wstep on ${back ? 'back-in' : ''}`} key={step}>
{step === 0 && <><h2>先认识她的开始</h2><p className="lead">名字由你起,生辰也可以在确认前修改。</p><Field label="她的名字"><input className="input" ref={nameField} value={name} maxLength={20} placeholder="由你来起 · 1–20 个字" aria-invalid={field === 'name'} onChange={e => setName(e.target.value)} autoComplete="off"/></Field>
<div className="field"><span>她的生日</span><div className="seg" role="group" aria-label="她的生日怎么来">{([['random', '随机生成'], ['pick', '我来指定']] as const).map(([k, l]) => <button key={k} aria-pressed={how === k} onClick={() => k === 'random' ? reroll() : setHow('pick')}>{l}</button>)}</div></div>
<div className="birth-pick"><Field label="出生日期(公历)" hint="需已满 18 岁。"><input className="input" ref={birthField} type="date" value={birth} aria-invalid={field === 'birth'} onChange={e => { setBirth(e.target.value); setHow('pick'); }}/></Field><Field label="出生时辰" hint="北京时间;子时23:00–00:59,丑时01:00–02:59,之后每两小时一段。排盘取时辰内偶数整点,子时取本日00:00。"><select className="select" value={hour} onChange={e => { setHour(e.target.value); setHow('pick'); }}>{HOURS.map(h => <option key={h}>{h}</option>)}</select></Field></div>
<div className="derived"><p><small>公历</small>{y || '—'} 年 {Number(m) || '—'} 月 {Number(d) || '—'} 日 · {hour}</p><p><small>农历与四柱</small>{real ? '下一步由排盘计算' : '演示不排盘'}</p></div>
<p className="d-dim">{how === 'random' ? '已随机生成。可以再随机一次,或换成「我来指定」。' : '确认前都可以改。'}</p></>}
{step === 1 && <><h2>{name.trim()}的底色</h2><p className="lead">这是倾向,不是台词。她会怎样理解自己、长成什么样,由她在相处和生活里慢慢形成,不按固定模板。</p><BaseColor color={real ? color : undefined}/></>}
{step === 2 && <><h2>由你选择关系</h2><p className="lead">没有预选答案。以后可以在设置中确认修改,记忆会保留。</p><div className="rel-cards" role="group" aria-label="你们的关系" ref={relationGroup}>{RELATIONS.map(([r, text]) => <button aria-pressed={relation === r} aria-label={r} aria-describedby={`rel-${r}`} key={r} onClick={() => { setRelation(r); if (field === 'relation') setError(''); }}><b>{r}</b><small id={`rel-${r}`}>{text}</small></button>)}</div><Field label="她怎么称呼你(可选)"><input className="input" maxLength={40} value={nickname} placeholder="比如:你的名字或昵称" onChange={e => setNickname(e.target.value)}/></Field><Field label="相处边界(可选)"><textarea className="textarea" maxLength={2000} value={boundary} placeholder="比如:彼此保留自己的时间" onChange={e => setBoundary(e.target.value)}/></Field></>}
{step === 3 && <><h2>让这次相识,有一个开始</h2><div className="sum">{[['名字', name], ['生辰', `${birth} · ${hour}`], ['关系', relation], ['称呼', nickname || '暂时不设'], ...(boundary.trim() ? [['相处边界', boundary.trim()]] : [])].map(([k, v]) => <div className="r" key={k}><span>{k}</span><b>{v}</b></div>)}</div><BaseColor color={real ? color : undefined}/><label className="check"><input type="checkbox" checked={agreed} disabled={busy || phase === 2} onChange={e => setAgreed(e.target.checked)}/>{real ? '我明白:这将创建服务器上的真实档案;创建后底色只读,只保留一位伴侣。关系以后可以调整。' : '我明白:这是本机演示;创建后底色只读,只保留一位伴侣。关系以后可以调整。'}</label>{phase >= 0 && <ul className="phases">{(real ? ['核对真实排盘', '保存唯一档案', '档案已保存'] : ['排好底色(示例)', '形成最初的小习惯(示例)', '布置房间(示例)']).map((p, i) => <li key={p} className={i < phase ? 'ok' : i === phase ? (error ? 'fail' : 'run') : ''}><i>{i < phase ? '✓' : ''}</i>{p}</li>)}</ul>}{busy && <p className="d-dim">通常不到一分钟。可以先看看窗外。</p>}</>}
{step === 4 && <div className="born"><div className="halo"><i/></div><div className="eyebrow">第一晚</div><h2>{name.trim()}住进来了</h2><p className="lead">刚开始,还没有共同的日子。日子和回忆会从今晚开始,慢慢留下。</p></div>}
<Status text={error} error/>{exists && <Button onClick={() => location.reload()}>重新打开,恢复已有的她</Button>}</div></div><footer className="wfoot">{step > 0 && step < 4 && <Button disabled={busy} onClick={() => { const fix = error && phase >= 0; setError(''); setPhase(-1); go(fix ? 0 : step - 1); }}>{error && phase >= 0 ? '返回修改' : '上一步'}</Button>}<span className="grow"/>{step < 3 ? <Button primary disabled={busy} onClick={() => void next()}>{busy ? '正在排盘…' : '下一步'}</Button> : step === 3 ? <Button primary disabled={!agreed || busy || exists} onClick={() => void create()}>{busy ? '正在创建…' : error && phase >= 0 ? '再试一次' : '确认创建'}</Button> : <Button primary onClick={onEnter}>去看看她</Button>}</footer></section></main>;
}
+31 -11
View File
@@ -5,7 +5,15 @@ import { delay } from '../adapters/demo';
import { exportDemo, parseState } from '../adapters/storage';
import { BaseColor, Button, Field, Icon, Modal, Status } from '../shared/ui';
const sections = [['her', 'user', '她'], ['relation', 'heart', '关系'], ['city', 'pin', '城市'], ['appearance', 'image', '外观素材'], ['backup', 'box', '本地演示导出'], ['services', 'plug', '外接服务'], ['display', 'moon', '显示']];
export function ManagePanel({ state, open, onClose, onSave, fail, theme, setTheme, real = false }: {
// What each section can actually do here (HEL-815 capability tags): read-only, adjustable, demo only, not connected, this device.
type Cap = 'ro' | 'edit' | 'demo' | 'off' | 'live' | 'local';
const CAP: Record<Cap, [string, string]> = { ro: ['只读', ''], edit: ['可以调整', 'accent'], demo: ['演示数据', 'demo'], off: ['未接入', 'off'], live: ['文字已接通', 'ok'], local: ['本机生效', 'ok'] };
const capOf = (id: string, real: boolean): Cap => id === 'her' ? 'ro' : id === 'relation' ? 'edit' : id === 'display' ? 'local' : id === 'services' && real ? 'live' : real ? 'off' : 'demo';
const NOTE: Record<string, string> = { her: '只读资料', relation: '可以调整', display: '本机生效' };
function CapTag({ cap }: { cap: Cap }) { const [text, tone] = CAP[cap]; return <span className={`tag cap ${tone}`}>{text}</span>; }
// Honest placeholder for a capability that is not connected: what it will do once connected, and that nothing happens now.
function Off({ title, will, now }: { title: string; will: string; now: string }) { return <div className="off-card"><p className="off-t">{title}</p><p>{will}</p><p className="d-dim">{now}</p></div>; }
export function ManagePanel({ state, open, onClose, onSave, fail, theme, setTheme, real = false, now = '', focus = 0 }: {
real?: boolean;
state: DemoState;
open: boolean;
@@ -14,6 +22,9 @@ export function ManagePanel({ state, open, onClose, onSave, fail, theme, setThem
fail: boolean;
theme: Theme;
setTheme: (t: Theme) => void;
now?: string;
// Bumped when another page asks to show her base colour and growth ("在设置里看底色与成长").
focus?: number;
}) {
const [section, setSection] = useState('her'), [detail, setDetail] = useState(false), [draft, setDraft] = useState(() => ({ settings: structuredClone(state.settings), identity: structuredClone(state.identity) })), [message, setMessage] = useState(''), [error, setError] = useState(false), [busy, setBusy] = useState(false), [confirm, setConfirm] = useState(''), [confirmText, setConfirmText] = useState(''), [search, setSearch] = useState(''), [restore, setRestore] = useState<DemoState | null>(null), [material, setMaterial] = useState(''), [check, setCheck] = useState('');
const approvedNavigation = useRef(false);
@@ -108,20 +119,29 @@ export function ManagePanel({ state, open, onClose, onSave, fail, theme, setThem
setCheck('检查没通过:' + (e instanceof SyntaxError?'清单不是有效的 JSON,请重新选择。':(e as Error).message));
} }
const switchSection = (s: string) => { request.current?.abort(); generation.current++; setBusy(false); setSection(s); setDetail(true); setMessage(''); };
return <section hidden={!open} className={`pane pane-manage glass read ${open ? 'open' : ''} ${detail ? 'has-detail' : ''}`} aria-label="设置"><header><h2>设置</h2><span className="grow"/><span className="tag-demo">{real ? '服务器档案' : '仅本机演示'}</span><button className="btn-round sm" aria-label="关闭设置" onClick={() => requestLeave(onClose)}><Icon name="x"/></button></header><div className="cols"><nav className="snav" aria-label="设置分区">{sections.map(([id, icon, label]) => <button key={id} className={dirtySections[id] ? 'is-dirty' : ''} aria-current={section === id} onClick={() => switchSection(id)}><Icon name={icon}/>{real && id === 'backup' ? '备份' : label}<i className="dirty"/></button>)}</nav><div className="detail"><button className="btn-text back" onClick={() => setDetail(false)}><Icon name="back"/>设置</button><div className="sec-body on"><h3>{section === 'her' ? state.identity.name : real && section === 'backup' ? '备份' : sections.find(s => s[0] === section)?.[2]}</h3><p className="lead">{section === 'her' ? '她还是她。外观和关系的变化,都不会改写最初的底色。' : real ? '资料保存在服务器。尚未接通的功能暂不可用。' : '所有修改仅用于本机演示。未接通的服务会明确说明。'}</p>
{section === 'her' && <><dl className="kv"><dt>名字</dt><dd>{state.identity.name}</dd><dt>生辰</dt><dd>{state.identity.birth} · {state.identity.hour}</dd></dl><BaseColor color={real ? (state.identity as RealIdentity).color : undefined}/><div className="growth"><div><h4>最初就有的</h4>{real ? '以上六层底色说明。生辰和原始人格参数保持只读。' : '细腻、慢热(示例)'}</div><div><h4>后来慢慢有的</h4>{state.memories.length ? '共同经历另存于回忆。' : real ? '长期记忆尚未接通。聊天记录已独立保存。' : '还在慢慢认识彼此。'}</div></div><p className="d-foot">首版只有一位,不提供新建、切换或清空。底色只读。</p></>}
{section === 'relation' && <><Field label="你们的关系"><select className="select" value={draft.identity.relation} onChange={e => setDraft(d => ({ ...d, identity: { ...d.identity, relation: e.target.value as '朋友' | '恋人' } }))}><option>朋友</option><option>恋人</option></select></Field><Field label="她怎么称呼你"><input className="input" value={draft.identity.nickname} maxLength={40} onChange={e => setDraft(d => ({ ...d, identity: { ...d.identity, nickname: e.target.value } }))}/></Field><Field label="相处边界"><textarea className="textarea" maxLength={2000} value={draft.identity.boundary} onChange={e => setDraft(d => ({ ...d, identity: { ...d.identity, boundary: e.target.value } }))}/></Field><p className="d-foot">改关系需要再次确认,已有记忆与信任都保留,底色不变。</p></>}
const lastFocus = useRef(focus);
useEffect(() => { if (focus === lastFocus.current) return; lastFocus.current = focus; switchSection('her'); }, [focus]); // eslint-disable-line react-hooks/exhaustive-deps
// Esc on a phone steps back from a section to the section list first; confirmations handle their own Esc.
useEffect(() => { if (!open || !detail) return; const key = (e: KeyboardEvent) => { if (e.key !== 'Escape' || confirm || !matchMedia('(max-width:720px)').matches) return; e.stopImmediatePropagation(); setDetail(false); }; window.addEventListener('keydown', key, true); return () => window.removeEventListener('keydown', key, true); }, [open, detail, confirm]);
const growth = state.memories.filter(m => m.group === '她的成长' && m.lifeIds.every(id => state.events.some(e => e.id === id && e.shared === true)));
const sectionLabel = (id: string) => real && id === 'backup' ? '备份' : sections.find(s => s[0] === id)?.[2] || '';
return <section hidden={!open} className={`pane pane-manage glass read ${open ? 'open' : ''} ${detail ? 'has-detail' : ''}`} aria-label="设置"><header><div className="ttl"><small className="kicker"><span className="k-wide">慢慢安排你们的世界 · {real ? '服务器档案' : '仅本机演示'}</span><span className="k-near"><i/>她此刻 · {now || '安静待着'}</span></small><h2>设置</h2></div><span className="grow"/><span className="tag-demo">{real ? '服务器档案' : '仅本机演示'}</span><button className="btn-round sm" aria-label="关闭设置" onClick={() => requestLeave(onClose)}><Icon name="x"/></button></header><div className="cols"><nav className="snav" aria-label="设置分区">{sections.map(([id, icon]) => { const cap = capOf(id, real); return <button key={id} className={dirtySections[id] ? 'is-dirty' : ''} aria-current={section === id} onClick={() => switchSection(id)}><Icon name={icon}/><span className="sl">{sectionLabel(id)}<small aria-hidden="true">{NOTE[id] || CAP[cap][0]}</small></span><i className="dirty"/><span className="chev" aria-hidden="true"><Icon name="next"/></span></button>; })}<p className="snav-foot">首版只有一位她 · 没有重建或清空</p></nav><div className="detail"><button className="btn-text back" onClick={() => setDetail(false)}><Icon name="back"/>设置</button><div className="sec-body on"><div className="sec-h"><h3>{section === 'her' ? state.identity.name : sectionLabel(section)}</h3><CapTag cap={capOf(section, real)}/></div><p className="lead">{section === 'her' ? '她还是她。外观和关系的变化,都不会改写最初的底色。' : real ? '资料保存在服务器。尚未接通的功能写明接上以后能做什么,现在不会发生任何事。' : '所有修改仅用于本机演示。未接通的服务会明确说明。'}</p>
{section === 'her' && <><dl className="kv"><dt>名字</dt><dd>{state.identity.name}<small>由你在初次创建时起的名字;首版不另设改名流程。</small></dd><dt>生辰</dt><dd>{state.identity.birth} · {state.identity.hour}<small><Icon name="lock"/>只读</small></dd></dl>
<h4 className="sub-h">她的底色<small>系统资料 · 每轮对话都会重新带上 · 关系设定不能改写</small></h4><BaseColor color={real ? (state.identity as RealIdentity).color : undefined}/>
<h4 className="sub-h">她怎么理解自己<small>模型诠释 · 会延续,也会变化</small></h4><Off title={real ? '她对自己的诠释还没有接上。' : '演示不生成她对自己的诠释。'} will="接上以后,这里是她在相处和生活里慢慢形成的自我理解,带版本和时间;不是固定模板,也不能直接改写。" now="现在这里不显示任何固定段落,避免把模板当成她的个性。"/>
<div className="growth"><div><h4>最初就有的<small>创建时形成</small></h4><p className="d-dim">{real ? '最初的小习惯尚未接通,不用示例填充。' : '演示没有生成最初的小习惯。'}</p></div><div><h4>后来慢慢有的<small>成长 · 单独记录</small></h4>{growth.length ? <ul>{growth.map(m => <li key={m.id}>{m.title}<small>{m.source}</small></li>)}</ul> : <p className="d-dim">{real ? '长期记忆尚未接通。聊天记录已独立保存。' : '还在慢慢认识彼此。'}</p>}</div></div><p className="d-foot">首版只有一位她。这里没有新建、切换、清空或重建。底色只读。</p></>}
{section === 'relation' && <><div className="field"><span id="rel-label">你们的关系</span><div className="seg" role="group" aria-labelledby="rel-label">{(['朋友', '恋人'] as const).map(r => <button key={r} aria-pressed={draft.identity.relation === r} onClick={() => setDraft(d => ({ ...d, identity: { ...d.identity, relation: r } }))}>{r}</button>)}</div></div><Field label="她怎么称呼你"><input className="input" value={draft.identity.nickname} maxLength={40} onChange={e => setDraft(d => ({ ...d, identity: { ...d.identity, nickname: e.target.value } }))}/></Field><Field label="相处边界"><textarea className="textarea" maxLength={2000} value={draft.identity.boundary} onChange={e => setDraft(d => ({ ...d, identity: { ...d.identity, boundary: e.target.value } }))}/></Field><p className="d-foot">改关系需要再次确认,已有记忆与信任都保留,底色不变。</p></>}
{!real && section === 'city' && <><Field label="搜索城市"><input className="input" value={search} placeholder="输入城市名称" onChange={e => setSearch(e.target.value)}/></Field><ul className="city-list">{['杭州', '上海', '北京', '成都', '广州', '深圳'].filter(c => c.includes(search.trim())).map(c => <li key={c}><button aria-pressed={draft.settings.city === c} onClick={() => settings({ city: c })}>{c}<small>中国 · 演示城市</small></button></li>)}</ul>{!['杭州', '上海', '北京', '成都', '广州', '深圳'].some(c => c.includes(search.trim())) && <p>暂时没找到这个城市,演示清单只包含上面的六座。</p>}<p className="d-foot">城市保存后顶栏同步;天气与作息为固定演示,不请求天气服务。</p></>}
{!real && section === 'appearance' && <><div className="card">当前素材:{state.settings.appearance}<small className="d-foot">参考静帧,不代表最终人物素材。</small></div><Field label="选择本地素材清单(演示 JSON)" hint="真实素材包格式尚待定稿。只读 JSON,不加载清单中的 URL 或脚本。"><input type="file" accept=".json,application/json" onChange={e => void importMaterial(e.target.files?.[0])}/></Field>{check && <Status text={check} error={!material}/>} {material && <><div className="compare"><figure><img src="/assets/her-room.jpg" alt="当前参考"/><figcaption>当前参考</figcaption></figure><figure className="new"><img src="/assets/her-room.jpg" alt="新外观模拟效果"/><figcaption>模拟效果 · 未加载素材</figcaption></figure></div><Button primary onClick={() => setConfirm('appearance')}>应用演示外观标识</Button></>}<p className="d-foot">只演示检查、预览与确认。媒体真实性未校验,不声称完成素材导入。</p></>}
{!real && section === 'backup' && <><div className="card"><h4>真实后台备份 · 未接通</h4><p>服务器每日备份、数据库和素材完整备份均未提供。本地文件不包含真实后台资料。</p></div><div className="card"><h4>你自己的演示资料</h4><p>包括本机档案、设置、文字、演示日子和回忆;不包含素材文件。</p><Button onClick={() => { exportDemo(state); setMessage('已生成本地演示 JSON 下载。'); setError(false); }}>导出本地演示 JSON</Button></div><Field label="恢复同一位她的本地演示 JSON"><input type="file" accept=".json,application/json" onChange={e => void importBackup(e.target.files?.[0])}/></Field>{restore && <Button onClick={() => { setConfirmText(''); setConfirm('restore'); }}>检查通过,继续恢复</Button>}</>}
{!real && section === 'services' && <>{Object.entries(draft.settings.services).map(([key, value]) => <div className="svc" key={key}><div className="nm">{key}<small>未接通 · 测试仅演示,不发网络请求</small></div><Button onClick={() => { setMessage(`${key}:界面演示,未真实检测。相关功能暂不可用,文字演示仍可使用。`); setError(false); }}>测试连接</Button><input className="input" aria-label={`${key}地址`} value={value} placeholder="服务地址(只保存,不连接)" onChange={e => settings({ services: { ...draft.settings.services, [key]: e.target.value } })}/></div>)}<p className="d-foot">真实麦克风和摄像头未启用。视觉窗只允许模拟状态,观察过期不当作眼前。</p></>}
{section === 'display' && <><div className="opt-row">{(['moon', 'fog'] as Theme[]).map(t => <button className="opt" data-t={t} key={t} aria-pressed={theme === t} onClick={() => setTheme(t)}><div className="sw"/><b>{t === 'moon' ? '靛蓝月光' : '蓝紫雾光'}</b><span>立即切换,保留你的选择</span></button>)}</div><label className="switch-row">减少动效<input type="checkbox" checked={draft.settings.reduced} onChange={e => settings({ reduced: e.target.checked })}/></label><p className="d-foot">也会自动尊重系统的减少动效设置。切到其他网页时暂停背景动画。</p></>}
{real && section === 'city' && <><div className="card"><h4>城市与天气</h4><p>尚未设置可核实的城市。城市保存、天气查询与作息联动将在后续接入。</p></div><Field label="搜索城市" hint="可浏览候选目录;当前无法保存,不会更改她的城市。"><input className="input" value={search} placeholder="输入城市名称" onChange={e => setSearch(e.target.value)}/></Field><ul className="city-list">{['杭州', '上海', '北京', '成都', '广州', '深圳'].filter(c => c.includes(search.trim())).map(c => <li key={c}><button disabled>{c}<small>候选城市 · 保存待接入</small></button></li>)}</ul>{!['杭州', '上海', '北京', '成都', '广州', '深圳'].some(c => c.includes(search.trim())) && <div className="empty">当前目录没有匹配的城市。</div>}<div className="actions"><Button disabled>保存城市 · 待接入</Button></div></>}
{real && section === 'appearance' && <><div className="card"><h4>当前画面</h4><p>内置参考静帧;真实素材包导入尚未接通,外观变化不会改变她的身份和底色。</p></div><Field label="选择外观素材包" hint="素材包格式与媒体检查将在后续接入。当前不上传、不读取文件。"><input type="file" disabled/></Field><ul className="phases">{['清单结构与版本', '媒体格式与时长', '人物一致性', '必要场景覆盖', '可用性与兼容性'].map(label => <li key={label}>待检查 · {label}</li>)}</ul><div className="compare"><figure><img src="/assets/her-room.jpg" alt="当前内置参考静帧"/><figcaption>当前参考</figcaption></figure><figure><div className="empty">导入并通过检查后显示新外观</div><figcaption>新旧对比 · 待接入</figcaption></figure></div><Button disabled>确认应用外观 · 待接入</Button></>}
{real && section === 'backup' && <><div className="card"><h4>每日自动备份</h4><p>暂无可核实的备份记录。自动备份、保留份数与运行结果将在接入后显示。</p><div className="empty">尚未接通备份服务</div></div><div className="card"><h4>完整导出</h4><p>将包含服务器档案、聊天及届时接通的记录与素材。当前不生成伪备份文件。</p><Button disabled>导出完整备份 · 待接入</Button></div><Field label="恢复同一位她的备份" hint="恢复前会检查完整性、版本和同一档案,要求输入“恢复”,并先备份当前资料。当前不接收文件或执行覆盖。"><input type="file" disabled/></Field><ul className="phases">{['检查完整性与版本', '核对是否同一位她', '先备份当前资料', '输入确认并恢复'].map(label => <li key={label}>待接入 · {label}</li>)}</ul><button className="btn-danger" disabled>检查备份并继续 · 待接入</button></>}
{real && section === 'services' && <>{[['文字对话', serviceHealth ? serviceHealth.llm.ok ? '连接可达' : '暂时不可达' : '已接通 · 可重新检查'], ['语音识别', '尚未接通'], ['语音合成', '尚未接通'], ['视觉观察', '尚未接通']].map(([label, status], index) => <div className="svc" key={label}><div className="nm">{label}<small>{status}</small></div><Button disabled={index !== 0 || busy} onClick={() => void checkService()}>{index === 0 ? busy ? '检查中…' : '重新检查连接' : '测试连接 · 待接入'}</Button><input className="input" aria-label={`${label}配置`} value={index === 0 ? '由服务器管理' : '服务尚未配置'} readOnly/></div>)}<div className="card"><h4>其余能力</h4><p>生活、长期记忆、主动消息和天气尚未接通。文字模型暂时不可达时,已保存的档案和聊天记录仍可查看。</p></div></>}
{section === 'display' && <><div className="opt-row">{(['moon', 'fog'] as Theme[]).map(t => <button className="opt" data-t={t} key={t} aria-pressed={theme === t} onClick={() => setTheme(t)}><div className="sw"/><b>{t === 'moon' ? '靛蓝月光' : '蓝紫雾光'}</b><span>立即切换,保留你的选择</span></button>)}</div><label className="switch-row"><span>减少动效<small>镜头不推近,只做淡入淡出;循环动画停下</small></span><input type="checkbox" className="switch" checked={draft.settings.reduced} onChange={e => settings({ reduced: e.target.checked })}/></label><p className="d-foot">也会自动尊重系统的减少动效设置。切到其他网页时暂停背景动画。</p></>}
{real && section === 'city' && <><Off title="城市与天气还没有接上。" will="接上以后,你选一个真实城市,她房间里的天气、白天黑夜和作息都跟着那里走;换城市不需要每次重新定位。" now="现在窗外的雨是界面氛围,不是真实天气。尚未设置可核实的城市,天气来源尚未确定。"/><Field label="搜索城市" hint="可浏览候选目录;当前无法保存,不会更改她的城市。"><input className="input" value={search} placeholder="输入城市名称" onChange={e => setSearch(e.target.value)}/></Field><ul className="city-list">{['杭州', '上海', '北京', '成都', '广州', '深圳'].filter(c => c.includes(search.trim())).map(c => <li key={c}><button disabled>{c}<small>候选城市 · 保存待接入</small></button></li>)}</ul>{!['杭州', '上海', '北京', '成都', '广州', '深圳'].some(c => c.includes(search.trim())) && <div className="empty">当前目录没有匹配的城市。</div>}<div className="actions"><Button disabled>保存城市 · 待接入</Button></div></>}
{real && section === 'appearance' && <><dl className="kv"><dt>现在的样子</dt><dd>工程外观 v2<small>参考静帧 · 尚无成套日常与交谈视频</small></dd></dl><Off title="换外观还没有接上。" will="接上以后:选择素材包 → 检查素材 → 看新旧对比 → 确认「她还是她」。只换样子,名字、底色、记忆和关系都不变。" now="素材包规范与导入检查尚未定稿。这里不会导入、预览或替换任何素材。"/><Field label="选择外观素材包" hint="素材包格式与媒体检查将在后续接入。当前不上传、不读取文件。"><input type="file" disabled/></Field><ul className="phases">{['清单结构与版本', '媒体格式与时长', '人物一致性', '必要场景覆盖', '可用性与兼容性'].map(label => <li key={label}>待检查 · {label}</li>)}</ul><div className="compare"><figure><img src="/assets/her-room.jpg" alt="当前内置参考静帧"/><figcaption>当前参考</figcaption></figure><figure><div className="empty">导入并通过检查后显示新外观</div><figcaption>新旧对比 · 待接入</figcaption></figure></div><Button disabled>确认应用外观 · 待接入</Button></>}
{real && section === 'backup' && <><Off title="备份还没有接上。" will="接上以后:服务器每天自动备份;你可以随时把她完整导出到自己的电脑(含底色、性格资料、对话、记忆、关系、生活进度和所用素材),也能从备份恢复同一个她。" now="现在没有任何备份在运行,这里也不会假装导出或恢复。"/><div className="card"><h4>每日自动备份</h4><p>暂无可核实的备份记录。自动备份、保留份数与运行结果将在接入后显示。</p><div className="empty">尚未接通备份服务</div></div><div className="card"><h4>完整导出</h4><p>将包含服务器档案、聊天及届时接通的记录与素材。当前不生成伪备份文件。</p><Button disabled>导出完整备份 · 待接入</Button></div><Field label="恢复同一位她的备份" hint="恢复前会检查完整性、版本和同一档案,要求输入“恢复”,并先备份当前资料。当前不接收文件或执行覆盖。"><input type="file" disabled/></Field><ul className="phases">{['检查完整性与版本', '核对是否同一位她', '先备份当前资料', '输入确认并恢复'].map(label => <li key={label}>待接入 · {label}</li>)}</ul><button className="btn-danger" disabled>检查备份并继续 · 待接入</button></>}
{real && section === 'services' && <>{[['文字对话', serviceHealth ? serviceHealth.llm.ok ? '连接可达' : '暂时不可达' : '已接通 · 可重新检查'], ['语音识别', '尚未接通'], ['语音合成', '尚未接通'], ['视觉观察', '尚未接通']].map(([label, status], index) => <div className="svc" key={label}><div className="nm">{label}<small>{status}</small></div><Button disabled={index !== 0 || busy} onClick={() => void checkService()}>{index === 0 ? busy ? '检查中…' : '重新检查连接' : '测试连接 · 待接入'}</Button><input className="input" aria-label={`${label}配置`} value={index === 0 ? '由服务器管理' : '服务尚未配置'} readOnly/></div>)}<Off title="语音与视觉观察还没有接上。" will="接上以后:语音由你主动开启,结束后停止收音,文字聊天一直保留;视觉观察只看人在不在、明显物品和房间变化,过期的画面不再当作眼前。" now="这里不申请麦克风或摄像头,不采集声音与影像。"/><div className="card"><h4>其余能力</h4><p>生活、长期记忆、主动消息和天气尚未接通。文字模型暂时不可达时,已保存的档案和聊天记录仍可查看。</p></div></>}
<div ref={feedback}><Status text={message} error={error}/></div>{(real ? ['relation', 'display'] : ['relation', 'city', 'services', 'display']).includes(section) && <div className="actions"><span className={`grow ${dirty ? 'dirty' : ''}`}>{dirty ? '有未保存的修改' : '尚未修改'}</span><Button disabled={!dirty || busy} onClick={reset}>取消修改</Button><Button primary disabled={!dirty || busy} onClick={() => void save()}>{busy ? '正在保存…' : error ? '重试保存' : '保存'}</Button></div>}</div></div></div>
{confirm && <Modal title={confirm === 'leave' ? '有未保存的修改' : confirm === 'relation' ? '改变你们的关系?' : confirm === 'restore' ? '恢复本地演示资料?' : '她还是她'} danger={confirm === 'restore'} onClose={() => setConfirm('')} disabled={confirm === 'restore' && confirmText !== '恢复'} onConfirm={() => { const which = confirm; setConfirm(''); if (which === 'leave') { request.current?.abort(); setBusy(false); setDraft({ identity: structuredClone(state.identity), settings: structuredClone(state.settings) }); const action = pendingNavigation.current; pendingNavigation.current = null; approvedNavigation.current = true; try { action?.(); } finally { approvedNavigation.current = false; } } if (which === 'relation')
{confirm && <Modal title={confirm === 'leave' ? '有未保存的修改' : confirm === 'relation' ? `把关系从「${state.identity.relation}」改成「${draft.identity.relation}」?` : confirm === 'restore' ? '恢复本地演示资料?' : '她还是她'} danger={confirm === 'restore'} onClose={() => setConfirm('')} disabled={confirm === 'restore' && confirmText !== '恢复'} onConfirm={() => { const which = confirm; setConfirm(''); if (which === 'leave') { request.current?.abort(); setBusy(false); setDraft({ identity: structuredClone(state.identity), settings: structuredClone(state.settings) }); const action = pendingNavigation.current; pendingNavigation.current = null; approvedNavigation.current = true; try { action?.(); } finally { approvedNavigation.current = false; } } if (which === 'relation')
void save(true); if (which === 'appearance') {
try {
if (fail)
@@ -151,6 +171,6 @@ export function ManagePanel({ state, open, onClose, onSave, fail, theme, setThem
setMessage((e as Error).message);
setError(true);
}
} }} confirm={confirm === 'leave' ? '放弃修改并离开' : '确认'}>{confirm === 'leave' ? <>离开会放弃尚未保存的修改。选择取消可继续编辑,已经保存的资料不会改变。</> : confirm === 'restore' ? <>恢复会覆盖当前本机演示资料。操作前会先下载当前资料,档案身份和底色须相同。<Field label="输入“恢复”以继续"><input className="input" value={confirmText} onChange={e => setConfirmText(e.target.value)}/></Field></> : <>记忆与信任都保留,八字底色不变。{confirm === 'appearance' ? '本次只更新演示标识,不接入未经校验的外部素材。' : ''}</>}</Modal>}
} }} confirm={confirm === 'leave' ? '放弃修改并离开' : '确认'}>{confirm === 'leave' ? <>离开会放弃尚未保存的修改。选择取消可继续编辑,已经保存的资料不会改变。</> : confirm === 'restore' ? <>恢复会覆盖当前本机演示资料。操作前会先下载当前资料,档案身份和底色须相同。<Field label="输入“恢复”以继续"><input className="input" value={confirmText} onChange={e => setConfirmText(e.target.value)}/></Field></> : <>记忆与信任都保留,八字底色不变。{confirm === 'relation' ? '从下一次交谈开始,她会按新的关系和你相处。' : ''}{confirm === 'appearance' ? '本次只更新演示标识,不接入未经校验的外部素材。' : ''}</>}</Modal>}
</section>;
}
+16 -1
View File
@@ -11,14 +11,28 @@ export interface PresenterProps {
instant: number;
real?: boolean;
observation: string;
// "她此刻": what she is doing, read from the same life state as the home page (never from the playing clip).
now?: string;
onApproach: () => void;
}
// One shared room (HEL-799, approved 01a16810): far = her room and the rainy city, middle = her, near = your table.
// Only consumes scene. No life writes, no synthesis, no microphone/camera APIs. The two stills are reference frames,
// not her real daily video; the camera move is the approved push-in, not body motion.
export function Presenter({ scene, space, theme, instant, real = false, observation, onApproach }: PresenterProps) {
export function Presenter({ scene, space, theme, instant, real = false, observation, now = '', onApproach }: PresenterProps) {
const [failed, setFailed] = useState(false);
const cam = useRef<HTMLDivElement>(null), room = useRef<HTMLDivElement>(null), talk = useRef<HTMLDivElement>(null), moon = useRef<HTMLElement>(null), near = useRef<HTMLDivElement>(null), hit = useRef<HTMLButtonElement>(null), rainRoom = useRef<HTMLCanvasElement>(null), rainTalk = useRef<HTMLCanvasElement>(null);
const chip = useRef<HTMLDivElement>(null);
// While a page is open on your side of the table, "她此刻" sits just under her in the room. It follows the hit area
// (which tracks the camera every frame) until the room has settled, and again after a resize.
useEffect(() => {
if (space !== 'pane' || !now) return;
let raf = 0, until = 0;
const place = () => { const h = hit.current?.getBoundingClientRect(), c = chip.current; if (!h || !c) return; c.style.transform = `translate3d(${Math.max(12, h.left - 6).toFixed(0)}px,${Math.min(innerHeight - 140, h.bottom + 10).toFixed(0)}px,0)`; };
const loop = () => { place(); if (performance.now() < until) raf = requestAnimationFrame(loop); };
const start = () => { until = performance.now() + 1400; cancelAnimationFrame(raf); loop(); };
start(); addEventListener('resize', start);
return () => { cancelAnimationFrame(raf); removeEventListener('resize', start); };
}, [space, now]);
const controller = useRef<RoomScene | null>(null), first = useRef(true), lastInstant = useRef(instant);
useLayoutEffect(() => {
if (!cam.current || !room.current || !talk.current || !moon.current || !near.current || !hit.current || !rainRoom.current || !rainTalk.current) return;
@@ -70,6 +84,7 @@ export function Presenter({ scene, space, theme, instant, real = false, observat
<div className="r-vignette"/><div className="r-veil"/>
</div>
<button className="her-hit" ref={hit} aria-label="走近她,开始交谈" tabIndex={space === 'home' ? 0 : -1} disabled={space !== 'home'} onClick={onApproach}><span>和她说话</span></button>
{now && <div className="now-chip glass" ref={chip} aria-hidden={space !== 'pane'}><i/><span><b>她此刻 · {now}</b><small>{real ? '生活尚未接通 · 画面为参考静帧' : '来自演示生活状态 · 画面为参考静帧'}</small></span></div>}
<div className="room-labels">
{failed && <span className="chip glass">画面暂时没打开,文字仍可使用。</span>}
{observation && <span className="chip glass observe show">{observation}</span>}
+149
View File
@@ -818,3 +818,152 @@ body:has(textarea:focus) .space *{animation-play-state:paused!important}
.birth-help, .color-sections details{font-size:13px;color:var(--text-2);margin-top:10px}
.birth-help summary, .color-sections summary{cursor:pointer;color:var(--accent)}
@media(max-height:480px){.create .story p,.create .story .single{display:none}.create .story{padding-bottom:4px}.create .story h1{font-size:18px}}
/* ============================================================
HEL-823 · A3 日子 / 回忆 / 首建 / 设置(按 HEL-815 页面稿接入正式界面)
Tokens and curves are the approved ones; state colours stay on dots, hairlines and short text only.
============================================================ */
.pane > header{align-items:center}
.pane > header .ttl{display:flex;flex-direction:column;gap:2px;min-width:0}
.pane > header .kicker{font-size:12px;color:var(--text-3);letter-spacing:.06em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pane > header .kicker i{display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--accent);box-shadow:0 0 8px var(--accent-glow);margin-right:7px;vertical-align:1px}
.pane > header .k-near{display:none}
.pane > header h2{font-size:22px;font-weight:300;letter-spacing:.08em}
.pane-tabs{display:flex;align-items:center;gap:14px;padding:12px 28px 12px;border-bottom:1px solid rgba(255,255,255,.06);flex:none}
.pane-tabs .tabnote{margin-left:auto;font-size:12px;color:var(--text-3);text-align:right}
/* 列表行:时间 · 状态点 · 标题与一句摘要 */
.ev{grid-template-columns:58px 14px minmax(0,1fr)}
.ev.plan time{font-size:11.5px;line-height:1.5}
.ev .tt{font-size:15px}
.ev .sn,.mem .sn{display:block;font-size:13px;color:var(--text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
.k.mem{background:transparent;border:1.5px solid var(--accent)}
.k.grow{background:var(--ok);box-shadow:0 0 8px color-mix(in srgb,var(--ok) 60%,transparent)}
.grp span{font-family:var(--font-num);letter-spacing:0}
.mem{display:grid;grid-template-columns:14px minmax(0,1fr);gap:8px;align-items:start;background:transparent;border-color:transparent;margin:2px 0;padding:10px}
.mem .k{margin-top:7px}
.mem .src{display:block;margin:0;font-size:12px;color:var(--text-3)}
.mem b{display:block;font-weight:400;font-size:15px}
.mem[aria-current="true"]{border-color:transparent;box-shadow:inset 2px 0 0 var(--accent)}
.ev[aria-current="true"]{box-shadow:inset 2px 0 0 var(--accent)}
.more-busy{display:flex;align-items:center;justify-content:center;gap:10px;margin:18px 0 6px;font-size:13px;color:var(--text-3)}
.more-busy .spin{width:14px;height:14px}
.list-end{margin:22px 0 4px;text-align:center;font-size:12.5px;color:var(--text-3)}
/* 加载 / 失败 / 打不开:同一种安静的状态卡 */
.skel{display:grid;gap:14px;padding:10px 6px}
.skel i{display:block;height:13px;border-radius:7px;background:linear-gradient(90deg,rgba(255,255,255,.04),rgba(255,255,255,.09),rgba(255,255,255,.04));background-size:200% 100%;animation:skel 1.6s var(--ease-drift) infinite}
@keyframes skel{from{background-position:100% 0}to{background-position:-100% 0}}
.state-card{display:flex;flex-direction:column;align-items:center;gap:6px;padding:48px 14px;text-align:center;font-size:13.5px;color:var(--text-3);line-height:1.7}
.state-card .state-mark{width:46px;height:46px;border-radius:50%;display:grid;place-items:center;color:var(--warn);background:radial-gradient(circle,color-mix(in srgb,var(--warn) 14%,transparent),transparent 72%);margin-bottom:6px}
.state-card .state-mark svg{width:20px;height:20px}
.state-card .state-t{font-size:15px;color:var(--text-1)}
.state-card .btn-ghost{margin-top:12px}
/* 详情:何时告诉你、她的原话、关联与那时候的聊天 */
.d-in{animation:detail-in 380ms var(--ease-out)}
@keyframes detail-in{from{opacity:0;transform:translateY(8px);filter:blur(3px)}}
.d-kicker .k{margin:0}
.d-told{font-size:13px;color:var(--text-3)}
.quote .who,.said-then .who{display:flex;align-items:center;gap:7px;font-size:12px;color:var(--text-3);letter-spacing:.06em;margin-bottom:6px}
.quote .who i,.said-then .who i{width:6px;height:6px;border-radius:50%;background:var(--accent);box-shadow:0 0 8px var(--accent-glow)}
.quote{font-size:18px;font-weight:350;line-height:1.8}
.link-list{display:grid;gap:8px}
.link-card{display:flex;align-items:center;gap:12px;width:100%;text-align:left;padding:12px 16px;border-radius:16px;background:rgba(255,255,255,.035);border:1px solid rgba(255,255,255,.07);transition:background-color var(--dur-ui),border-color var(--dur-ui)}
.link-card:hover{background:var(--accent-soft);border-color:var(--glass-line)}
.link-card > span{flex:1;min-width:0}
.link-card b{display:block;font-weight:400;font-size:14.5px}
.link-card small{display:block;font-size:12px;color:var(--text-3);margin-top:2px}
.link-card svg{width:16px;height:16px;color:var(--text-3);flex:none}
.said-then{display:grid;gap:12px;padding:14px 18px;border-radius:16px;background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.06);margin-bottom:14px;font-size:14.5px;line-height:1.75}
.said-then p[data-role="user"]{color:var(--user)}
.said-then p[data-role="user"] .who i{background:transparent;border:1.5px solid var(--text-2);box-shadow:none}
.d-note{margin:16px 0 0;padding:12px 16px;border-radius:14px;border:1px solid var(--glass-line);font-size:13px;color:var(--text-2);line-height:1.7;display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px}
.d-note .btn-text{color:var(--accent)}
.d-dim{font-size:12.5px;color:var(--text-3);line-height:1.7;margin:4px 0 14px}
.d-foot .tag-demo{margin-right:8px}
.detail .btn-ghost svg{width:14px;height:14px}
/* 设置:分区列表带能力标签,分区标题旁标明真实 / 演示 / 未接入 */
.snav button{height:auto;min-height:48px;padding:7px 14px}
.snav .sl{display:flex;flex-direction:column;min-width:0;flex:1}
.snav .sl small{font-size:11.5px;color:var(--text-3);margin-top:1px}
.snav .chev{display:none;margin-left:6px;color:var(--text-3)}
.snav .chev svg{width:14px;height:14px}
.snav-foot{margin:14px 10px 0;padding-top:12px;border-top:1px solid rgba(255,255,255,.06);font-size:11.5px;color:var(--text-3);line-height:1.6}
.sec-h{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.sec-h h3{margin:0}
.tag.cap{height:20px;font-size:11px}
.tag.cap.demo{color:var(--text-3);background:transparent;border:1px dashed var(--glass-line)}
.tag.cap.off{color:var(--warn);background:transparent;border:1px solid color-mix(in srgb,var(--warn) 45%,transparent)}
.off-card{border-radius:18px;padding:16px 20px;margin:0 0 16px;border:1px dashed var(--glass-line);background:rgba(255,255,255,.02);font-size:13.5px;line-height:1.75;color:var(--text-2)}
.off-card .off-t{color:var(--text-1);font-size:15px;margin-bottom:4px}
.off-card .d-dim{margin:6px 0 0}
.kv dd small{display:flex;align-items:center;gap:5px;font-size:12px;color:var(--text-3);margin-top:2px}
.kv dd small svg{width:12px;height:12px}
.kv{margin-bottom:22px}
.sub-h{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;font-size:15px;font-weight:400;color:var(--text-1);margin:26px 0 12px}
.sub-h small{font-size:11.5px;color:var(--text-3);letter-spacing:.04em}
.growth{margin-top:22px}
.growth h4 small{display:block;letter-spacing:.04em;font-size:11px;margin-top:2px}
.growth li small{display:block;margin:0 0 6px}
.growth .d-dim{margin:0}
.switch-row > span small{margin-top:2px}
input.switch{appearance:none;flex:none;width:44px;height:26px;border-radius:13px;background:var(--field);border:1px solid var(--field-line);position:relative;cursor:pointer;transition:background-color var(--dur-ui),border-color var(--dur-ui)}
input.switch::after{content:"";position:absolute;left:3px;top:3px;width:18px;height:18px;border-radius:50%;background:var(--text-2);transition:transform var(--dur-ui) var(--ease-out),background-color var(--dur-ui)}
input.switch:checked{background:var(--accent-soft);border-color:var(--accent)}
input.switch:checked::after{transform:translateX(18px);background:var(--accent)}
input.switch:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.field .seg{display:inline-flex}
/* 首建:左边一句叙事,右边一张卡;名字为空、关系不预选 */
.create .story .quiet{color:var(--text-1);font-size:15.5px;margin-top:12px}
.create .story p:not(.quiet){font-size:13px;color:var(--text-3)}
.input[aria-invalid="true"]{border-color:var(--danger);box-shadow:0 0 0 4px color-mix(in srgb,var(--danger) 14%,transparent)}
.birth-pick{display:grid;grid-template-columns:1fr 1fr;gap:0 12px;margin-top:4px}
.derived{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:12px 16px;border-radius:14px;background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.06);font-size:13.5px;margin-bottom:8px}
.derived small{display:block;font-size:11.5px;color:var(--text-3)}
.rel-cards{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:0 0 20px}
.rel-cards button{text-align:left;padding:16px 18px;border-radius:18px;border:1px solid var(--glass-line);background:rgba(255,255,255,.03);transition:border-color var(--dur-ui),background-color var(--dur-ui),box-shadow var(--dur-ui)}
.rel-cards button:hover{background:rgba(255,255,255,.06)}
.rel-cards b{display:block;font-weight:400;font-size:17px;letter-spacing:.1em}
.rel-cards small{display:block;font-size:12.5px;color:var(--text-3);margin-top:6px;line-height:1.6}
.rel-cards button[aria-pressed="true"]{border-color:var(--accent);background:var(--accent-soft);box-shadow:0 0 22px -8px var(--accent-glow)}
.born .eyebrow{font-size:12px;color:var(--text-3);letter-spacing:.2em;margin-bottom:4px}
/* 她此刻:面板打开时贴在她下方;只在宽屏出现,其余宽度写在面板标题上方 */
.now-chip{position:fixed;left:0;top:0;z-index:15;display:flex;align-items:flex-start;gap:9px;padding:9px 14px 9px 12px;border-radius:14px;max-width:260px;opacity:0;pointer-events:none;transition:opacity var(--dur-panel) var(--ease-out)}
.now-chip i{width:6px;height:6px;margin-top:7px;border-radius:50%;background:var(--accent);box-shadow:0 0 8px var(--accent-glow);flex:none}
.now-chip b{display:block;font-weight:400;font-size:13px}
.now-chip small{display:block;font-size:11px;color:var(--text-3);margin-top:1px}
html[data-mode="pane"] body.paned .now-chip{opacity:1}
body.creating .now-chip{display:none}
@media (max-width:1100px){
.now-chip{display:none}
.pane > header .k-wide{display:none}
.pane > header .k-near{display:inline}
}
@media (max-width:1100px) and (min-width:721px){
.pane-tabs .tabnote{display:none}
}
@media (max-width:720px){
.pane > header h2{font-size:18px}
.pane-tabs{padding:10px 12px}
.pane-tabs .tabs{display:flex;flex:1}
.pane-tabs .tabs button{flex:1}
.pane-tabs .tabnote{display:none}
.ev[aria-current="true"],.mem[aria-current="true"]{background:transparent;box-shadow:none}
.quote{font-size:16px}
.snav .chev{display:inline-flex}
.snav button[aria-current="true"]{background:transparent;color:var(--text-2)}
.birth-pick{grid-template-columns:1fr}
.create .story p:not(.quiet){display:none}
.create .story .quiet{font-size:14px;margin-top:6px}
}
@media (max-width:720px) and (max-height:620px){.create .story .quiet{display:none}}
@media (max-width:360px){
.rel-cards{grid-template-columns:1fr}
.seg button{padding:0 12px;font-size:13px}
.derived{grid-template-columns:1fr}
}
+6 -6
View File
@@ -97,10 +97,10 @@ try:
click(page, '读到了书里的那片海', exact=False)
expect(page.get_by_role('heading', name='读到了书里的那片海')).to_be_visible()
shot(page, f'{width}-days-{theme}')
click(page, '留一盏小灯')
click(page, '留一盏小灯', exact=False)
expect(page.get_by_role('heading', name='留一盏小灯')).to_be_visible()
click(page, '读到了书里的那片海', exact=False)
click(page, '看那段聊天')
click(page, '在交谈里看这段')
expect(page.locator('.log-panel')).to_be_visible()
shot(page, f'{width}-talk-{theme}')
click(page, '结束交谈 · 回到日子')
@@ -110,15 +110,15 @@ try:
page.get_by_label('她怎么称呼你', exact=True).fill('小伙伴')
click(page, '取消修改')
expect(page.get_by_label('她怎么称呼你', exact=True)).to_have_value('')
page.get_by_label('你们的关系', exact=True).select_option('恋人')
page.get_by_role('group', name='你们的关系').get_by_role('button', name='恋人', exact=True).click()
click(page, '保存')
expect(page.get_by_role('dialog')).to_contain_text('记忆与信任都保留')
click(page, '取消')
expect(page.get_by_label('你们的关系', exact=True)).to_have_value('恋人')
expect(page.get_by_role('group', name='你们的关系').get_by_role('button', name='恋人', exact=True)).to_have_attribute('aria-pressed', 'true')
click(page, '保存'); page.get_by_role('dialog').get_by_role('button', name='确认', exact=True).click()
expect(page.get_by_role('status').filter(has_text='已保存在本机演示')).to_be_visible()
shot(page, f'{width}-manage-{theme}')
page.get_by_label('你们的关系', exact=True).select_option('朋友')
page.get_by_role('group', name='你们的关系').get_by_role('button', name='朋友', exact=True).click()
click(page, '保存'); page.get_by_role('dialog').get_by_role('button', name='确认', exact=True).click()
expect(page.get_by_role('status').filter(has_text='已保存在本机演示')).to_be_visible()
nav(page, '此刻')
@@ -127,7 +127,7 @@ try:
passed(f'{width}: both themes, home/talk/days/memory return, relation confirm/cancel/save')
# Direct private event deep link must not reveal anything, including its linked memory.
page.goto(url + '/?demo=1#event=secret'); nav(page, '日子')
expect(page.locator('article.detail')).to_contain_text('这条记录暂时不可见')
expect(page.locator('article.detail')).to_contain_text('这一条现在打不开')
expect(page.locator('body')).not_to_contain_text('秘密散步')
nav(page, '交谈')
composer=page.get_by_role('textbox', name='想和她说的话')
+1
View File
@@ -19,6 +19,7 @@ describe('local persistence and restore boundary', () => {
it('corrupt storage produces a visible boundary instead of new creation', () => { vi.stubGlobal('localStorage', { getItem: () => '{invalid' }); expect(loadState().state).toBeNull(); expect(loadState().error).not.toBe(''); });
it('rejects another companion, malformed records and oversized files', () => { const s = seed(); expect(() => parseState(JSON.stringify({ ...s, identity: { ...identity, id: 'other' } }), identity)).toThrow('另一位'); expect(() => parseState(JSON.stringify({ ...s, messages: [{ text: 'invalid' }] }), identity)).toThrow(); expect(() => parseState(' '.repeat(5000001))).toThrow('太大'); });
it('untrusted text stays text, arbitrary keys are dropped, pending turns cancelled on restore', () => { const s = seed(); s.messages.push({ id: 'script', role: 'companion', text: '<img src=x onerror=alert(1)>', lifeIds: [], status: 'pending' }); const parsed = parseState(JSON.stringify({ ...s, script: 'evil' }), identity); expect(parsed.messages.at(-1)?.text).toContain('<img'); expect(parsed.messages.at(-1)?.status).toBe('cancelled'); expect(parsed).not.toHaveProperty('script'); });
it('keeps when she told you only on shared records', () => { const s = seed(); s.events[3] = { ...s.events[3], told: '13:20 告诉你' }; const parsed = parseState(JSON.stringify(s), identity); expect(parsed.events.find(e => e.id === 'book')?.told).toBe('19:46 告诉你'); expect(parsed.events.find(e => e.id === 'secret')).not.toHaveProperty('told'); });
});
describe('turn/epoch cancellation', () => {
it('rejects old results after new turn, cancel, exit, and resync', () => { const g = new TurnGate(); const a = g.begin('a'); const e = { t: 'chat.delta' as const, epoch: 1, turn_id: 'a', delta: '旧' }; expect(g.accepts(e)).toBe(true); g.begin('b'); expect(a.aborted).toBe(true); expect(g.accepts(e)).toBe(false); g.cancel(); expect(g.accepts({ ...e, turn_id: 'b' })).toBe(false); g.begin('b'); g.resync(); g.begin('c'); expect(g.accepts({ ...e, turn_id: 'c' })).toBe(false); });
+235
View File
@@ -0,0 +1,235 @@
"""HEL-825 review evidence: named viewports x both themes, confirm dialogs,
error states, floating tag, plus two short screen recordings."""
import functools
import http.server
import threading
from pathlib import Path
from playwright.sync_api import sync_playwright, expect
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT.parents[0] / 'docs' / 'frontend' / 'screenshots' / 'hel825'
OUT.mkdir(parents=True, exist_ok=True)
VID = ROOT.parents[0] / 'docs' / 'frontend' / 'recordings'
VID.mkdir(parents=True, exist_ok=True)
class Quiet(http.server.SimpleHTTPRequestHandler):
def log_message(self, *_):
pass
server = http.server.ThreadingHTTPServer(('127.0.0.1', 0), functools.partial(Quiet, directory=str(ROOT / 'dist')))
threading.Thread(target=server.serve_forever, daemon=True).start()
url = f'http://127.0.0.1:{server.server_port}'
passed = []
errors = []
def log_pass(text):
passed.append(text)
print('PASS', text, flush=True)
with sync_playwright() as pw:
browser = pw.chromium.launch()
def fresh(width, height, record=None):
ctx = browser.new_context(viewport={'width': width, 'height': height}, record_video_dir=(str(VID) if record else None),
record_video_size={'width': min(width, 1280), 'height': min(height, 800)} if record else None)
page = ctx.new_page()
page.set_default_timeout(9000)
page.on('pageerror', lambda e: errors.append(str(e)))
return ctx, page
def setup_demo(page, width):
page.goto(url + '/?demo=1')
page.get_by_role('button', name='下一步').click()
page.get_by_label('她的名字', exact=True).fill('小满')
page.get_by_label('出生日期(公历)', exact=True).fill('2000-10-18')
page.get_by_role('button', name='下一步').click()
page.get_by_role('button', name='下一步').click()
page.get_by_role('button', name='朋友', exact=True).click()
page.get_by_role('button', name='下一步').click()
page.get_by_role('checkbox').check()
page.get_by_role('button', name='确认创建', exact=True).click()
page.get_by_role('button', name='去看看她').click()
page.locator('.demo > button').click()
page.get_by_role('button', name='载入三天记录').click()
page.locator('.demo > button').click()
def nav(page, name):
page.get_by_role('navigation', name='主导航').get_by_role('button', name=name, exact=True).click()
page.wait_for_timeout(450)
if name == '设置' and page.viewport_size['width'] <= 720 and page.locator('.pane.open.has-detail').count():
page.locator('.pane.open .back').click()
def shot(page, name):
page.screenshot(path=str(OUT / f'{name}.png'), full_page=False)
# --- 1600x1000 and 1024 wide: full sweep both themes ---
for width, height in [(1600, 1000), (1024, 1000)]:
ctx, page = fresh(width, height)
setup_demo(page, width)
for theme, label in [('moon', '靛蓝月光'), ('fog', '蓝紫雾光')]:
page.locator('.demo > button').click()
page.get_by_role('button', name=label, exact=True).click()
page.wait_for_timeout(400)
shot(page, f'{width}x{height}-home-{theme}')
# her-now floating tag under role on wide, above panel title <=1100
nav(page, '日子')
if page.get_by_role('tab', name='她的日子').get_attribute('aria-selected') != 'true':
page.get_by_role('tab', name='她的日子').click()
page.wait_for_timeout(300)
shot(page, f'{width}x{height}-days-{theme}')
page.get_by_role('button', name='读到了书里的那片海').click()
expect(page.get_by_role('heading', name='读到了书里的那片海')).to_be_visible()
shot(page, f'{width}x{height}-days-detail-{theme}')
page.get_by_role('tab', name='我们的回忆').click()
page.wait_for_timeout(300)
shot(page, f'{width}x{height}-memory-{theme}')
page.get_by_role('button', name='留一盏小灯', exact=False).first.click()
expect(page.get_by_role('heading', name='留一盏小灯')).to_be_visible()
shot(page, f'{width}x{height}-memory-detail-{theme}')
# settings + relation confirm dialog
nav(page, '设置')
page.get_by_role('navigation', name='设置分区').get_by_role('button', name='关系', exact=True).click()
page.get_by_label('她怎么称呼你', exact=True).fill('小伙伴')
page.get_by_role('group', name='你们的关系').get_by_role('button', name='恋人', exact=True).click()
page.get_by_role('button', name='保存').click()
expect(page.get_by_role('dialog')).to_contain_text('记忆与信任都保留')
shot(page, f'{width}x{height}-relation-confirm-{theme}')
page.get_by_role('dialog').get_by_role('button', name='确认', exact=True).click()
expect(page.get_by_role('status').filter(has_text='已保存在本机演示')).to_be_visible()
# reset relation back to friend so the next theme loop has a changeable draft
page.get_by_role('group', name='你们的关系').get_by_role('button', name='朋友', exact=True).click()
page.get_by_role('button', name='保存').click()
page.get_by_role('dialog').get_by_role('button', name='确认', exact=True).click()
expect(page.get_by_role('status').filter(has_text='已保存在本机演示')).to_be_visible()
page.wait_for_timeout(400)
shot(page, f'{width}x{height}-settings-{theme}')
# read-fail retry card via demo failure switch
nav(page, '日子')
if page.get_by_role('tab', name='她的日子').get_attribute('aria-selected') != 'true':
page.get_by_role('tab', name='她的日子').click()
page.wait_for_timeout(300)
page.locator('.demo > button').click()
page.get_by_role('button', name='下次操作模拟失败').click()
page.locator('.demo > button').click()
page.reload()
nav(page, '日子')
page.wait_for_timeout(600)
if page.get_by_role('button', name='再试一次').count():
shot(page, f'{width}x{height}-read-fail-{theme}')
log_pass(f'{width}x{height} {theme}: read-failure card with retry captured')
else:
page.locator('.demo > button').click()
page.get_by_role('button', name='载入三天记录').click()
page.locator('.demo > button').click()
# restore data for next theme loop
page.locator('.demo > button').click()
page.get_by_role('button', name='载入三天记录').click()
page.locator('.demo > button').click()
ctx.close()
log_pass(f'{width}x{height}: home/days/detail/memory/settings/confirm both themes')
# --- phone viewports ---
for width, height in [(390, 844), (320, 568)]:
ctx, page = fresh(width, height)
setup_demo(page, width)
for theme, label in [('moon', '靛蓝月光'), ('fog', '蓝紫雾光')]:
page.locator('.demo > button').click()
page.get_by_role('button', name=label, exact=True).click()
page.wait_for_timeout(400)
shot(page, f'{width}x{height}-home-{theme}')
nav(page, '日子')
if page.locator('.pane.open.has-detail').count():
page.locator('.pane.open .back').click()
shot(page, f'{width}x{height}-days-{theme}')
page.get_by_role('button', name='读到了书里的那片海').click()
expect(page.get_by_role('heading', name='读到了书里的那片海')).to_be_visible()
shot(page, f'{width}x{height}-days-detail-{theme}')
nav(page, '设置')
page.get_by_role('navigation', name='设置分区').get_by_role('button', name='她', exact=True).click()
page.wait_for_timeout(300)
shot(page, f'{width}x{height}-settings-her-{theme}')
ctx.close()
log_pass(f'{width}x{height}: home/days/detail/settings both themes')
# --- 390x430 keyboard-equivalent: composer focused geometry ---
ctx, page = fresh(390, 430)
setup_demo(page, 390)
for theme, label in [('moon', '靛蓝月光'), ('fog', '蓝紫雾光')]:
page.locator('.demo > button').click()
page.get_by_role('button', name=label, exact=True).click()
page.wait_for_timeout(400)
nav(page, '交谈')
composer = page.get_by_role('textbox', name='想和她说的话')
composer.click()
page.wait_for_timeout(500)
shot(page, f'390x430-keyboard-{theme}')
expect(composer).to_be_in_viewport()
ctx.close()
log_pass('390x430 keyboard-equivalent: composer focused, in viewport, both themes')
# --- recordings: wide nav/dialog/esc, phone nav/back ---
ctx, page = fresh(1600, 1000, record=True)
setup_demo(page, 1600)
page.wait_for_timeout(600)
nav(page, '日子')
page.get_by_role('button', name='读到了书里的那片海').click()
page.wait_for_timeout(700)
page.get_by_role('button', name='在交谈里看这段').click()
page.wait_for_timeout(900)
page.keyboard.press('Escape')
page.wait_for_timeout(600)
page.get_by_role('button', name='结束交谈 · 回到日子').click()
page.wait_for_timeout(600)
nav(page, '设置')
page.get_by_role('navigation', name='设置分区').get_by_role('button', name='关系', exact=True).click()
page.get_by_label('她怎么称呼你', exact=True).fill('小伙伴')
page.get_by_role('group', name='你们的关系').get_by_role('button', name='恋人', exact=True).click()
page.get_by_role('button', name='保存').click()
page.wait_for_timeout(500)
page.get_by_role('dialog').get_by_role('button', name='确认', exact=True).click()
page.wait_for_timeout(700)
nav(page, '此刻')
page.wait_for_timeout(800)
video = page.video.path()
ctx.close()
Path(VID / 'hel825-wide-nav-dialog-esc.webm')
if video:
import shutil
shutil.move(video, VID / 'hel825-wide-nav-dialog-esc.webm')
log_pass('wide recording: days->chat jump, Esc, back, relation confirm, nav')
ctx, page = fresh(390, 844, record=True)
setup_demo(page, 390)
page.wait_for_timeout(600)
nav(page, '日子')
page.get_by_role('button', name='读到了书里的那片海').click()
page.wait_for_timeout(700)
page.keyboard.press('Escape')
page.wait_for_timeout(600)
nav(page, '交谈')
composer = page.get_by_role('textbox', name='想和她说的话')
composer.click()
page.wait_for_timeout(800)
composer.fill('你好呀')
page.get_by_role('button', name='发送', exact=True).click()
page.wait_for_timeout(1200)
nav(page, '此刻')
page.wait_for_timeout(700)
video = page.video.path()
ctx.close()
if video:
import shutil
shutil.move(video, VID / 'hel825-phone-nav-esc.webm')
log_pass('phone recording: days detail, Esc back, talk send, nav')
browser.close()
server.shutdown()
print('ERRORS:', errors if errors else 'none')
if errors:
raise SystemExit(1)
+69
View File
@@ -0,0 +1,69 @@
"""HEL-825: geometry probe for the 她此刻 floating tag (no image reading needed).
Rule: with the days panel open, >1100px wide the tag sits under the role stage;
<=1100px it sits above the panel title."""
import functools
import http.server
import threading
from pathlib import Path
from playwright.sync_api import sync_playwright
ROOT = Path(__file__).resolve().parents[1]
class Quiet(http.server.SimpleHTTPRequestHandler):
def log_message(self, *_):
pass
server = http.server.ThreadingHTTPServer(('127.0.0.1', 0), functools.partial(Quiet, directory=str(ROOT / 'dist')))
threading.Thread(target=server.serve_forever, daemon=True).start()
url = f'http://127.0.0.1:{server.server_port}'
with sync_playwright() as pw:
browser = pw.chromium.launch()
for width, expect_mode in [(1600, 'under-role'), (1440, 'under-role'), (1101, 'under-role'), (1100, 'above-title'), (1024, 'above-title'), (390, 'above-title')]:
ctx = browser.new_context(viewport={'width': width, 'height': 1000 if width > 800 else 844})
page = ctx.new_page()
page.set_default_timeout(9000)
page.goto(url + '/?demo=1')
page.get_by_role('button', name='下一步').click()
page.get_by_label('她的名字', exact=True).fill('小满')
page.get_by_label('出生日期(公历)', exact=True).fill('2000-10-18')
page.get_by_role('button', name='下一步').click()
page.get_by_role('button', name='下一步').click()
page.get_by_role('button', name='朋友', exact=True).click()
page.get_by_role('button', name='下一步').click()
page.get_by_role('checkbox').check()
page.get_by_role('button', name='确认创建', exact=True).click()
page.get_by_role('button', name='去看看她').click()
page.locator('.demo > button').click()
page.get_by_role('button', name='载入三天记录').click()
page.locator('.demo > button').click()
page.get_by_role('navigation', name='主导航').get_by_role('button', name='日子', exact=True).click()
page.wait_for_timeout(900)
info = page.evaluate("""() => {
const chip = document.querySelector('.now-chip');
const pane = document.querySelector('.pane.read');
const stage = document.querySelector('.stage') || document.querySelector('.who');
const title = pane ? pane.querySelector('h2') : null;
const near = pane ? pane.querySelector('.k-near') : null;
const r = el => { if (!el) return null; const b = el.getBoundingClientRect(); return {top: b.top, bottom: b.bottom, left: b.left, right: b.right, text: (el.textContent||'').trim().slice(0,40), display: el ? getComputedStyle(el).display : null}; };
return {chip: r(chip), pane: r(pane), stage: r(stage), title: r(title), near: r(near)};
}""")
chip, stage, title, near = info['chip'], info['stage'], info['title'], info['near']
ok = False
detail = ''
if expect_mode == 'under-role' and chip and stage:
ok = chip['display'] != 'none' and chip['top'] >= stage['bottom'] - 6
detail = f"chip_top={chip['top']:.0f} chip_display={chip['display']} stage_bottom={stage['bottom']:.0f}"
elif expect_mode == 'above-title' and title and near:
ok = near['display'] != 'none' and near['bottom'] <= title['top'] + 6 and near['text'].startswith('她此刻')
detail = f"near_bottom={near['bottom']:.0f} title_top={title['top']:.0f} near={near['text'][:24]}"
print(('PASS' if ok else 'FAIL'), width, expect_mode, detail, flush=True)
if not ok:
raise SystemExit(1)
ctx.close()
browser.close()
server.shutdown()
print('ALL GEOMETRY OK')
+1 -1
View File
@@ -78,7 +78,7 @@ try:
click(page,'看更早的日子');expect(page.locator('.ev')).to_have_count(30)
page.locator('.ev').nth(10).click()
scroll=page.locator('.list').evaluate('el=>el.scrollTop')
click(page,'看那段聊天');click(page,'结束交谈 · 回到日子')
click(page,'在交谈里看这段');click(page,'结束交谈 · 回到日子')
assert page.locator('.list').evaluate('el=>el.scrollTop')==scroll
checks.append('Long timeline paginates 18 then 12 and retains exact scroll position after chat return')
ctx.close()
+3 -3
View File
@@ -144,9 +144,9 @@ try:
passed('controlled blocked upstream: immediate cancellation/new question isolation')
nav(mp,'设置')
mp.get_by_role('navigation',name='设置分区').get_by_role('button',name='关系',exact=True).click()
mp.get_by_label('你们的关系',exact=True).select_option('恋人'); click(mp,'取消修改')
expect(mp.get_by_label('你们的关系',exact=True)).to_have_value('朋友')
mp.get_by_label('你们的关系',exact=True).select_option('恋人'); click(mp,'保存'); click(mp,'取消')
mp.get_by_role('group',name='你们的关系').get_by_role('button',name='恋人',exact=True).click(); click(mp,'取消修改')
expect(mp.get_by_role('group',name='你们的关系').get_by_role('button',name='朋友',exact=True)).to_have_attribute('aria-pressed','true')
mp.get_by_role('group',name='你们的关系').get_by_role('button',name='恋人',exact=True).click(); click(mp,'保存'); click(mp,'取消')
assert app.state.store.query_one('SELECT identity_json FROM companion')['identity_json'].find('恋人')<0
click(mp,'保存'); mp.get_by_role('dialog').get_by_role('button',name='确认',exact=True).click()
expect(mp.get_by_role('status')).to_contain_text('已保存在服务器')
+1 -1
View File
@@ -343,7 +343,7 @@ try:
shot(dp, 'demo-voice-390')
click(dp, '结束语音')
dp.locator('.demo > button').click(); click(dp, '载入三天记录')
nav(dp, '日子'); dp.locator('.ev').first.click(); click(dp, '看那段聊天')
nav(dp, '日子'); dp.locator('.ev').first.click(); click(dp, '在交谈里看这段')
expect(dp.locator('.log-panel')).to_be_visible(); click(dp, '关闭记录'); click(dp, '结束交谈 · 回到日子')
expect(dp.locator('.pane[aria-label="日子"]')).to_have_class('pane glass read open has-detail')
assert not requests