Repository navigation
修复家属问询会话 ID 丢失并字段化基础信息录入 - #129
Conversation
|
Warning Review limit reached
Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughChanges家属问询流程新增姓名、性别、年龄、身高和外观特征的结构化基础信息表单,并将其持久化到当前标签页草稿。提交答案响应现在通过 Intake 问询流程
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant FamilyIntakeForm
participant submitIntakeAnswer
participant sessionFromAnswerResponse
FamilyIntakeForm->>submitIntakeAnswer: 提交结构化基础信息答案
submitIntakeAnswer-->>FamilyIntakeForm: 返回 session_id 和下一问询状态
FamilyIntakeForm->>sessionFromAnswerResponse: 转换提交响应
sessionFromAnswerResponse-->>FamilyIntakeForm: 更新页面会话并加载下一阶段
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Preview readyThe preview for this build is available at https://pr-129-39901bf1f4c9.angui.cg8.site. Temporary demo accounts (all use the password
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
frontend/src/pages/FamilyIntakeForm.tsx (3)
520-524: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win手动"重新获取草稿"按钮未传入当前
basicInformation,会导致画像草稿初始化为空白姓名/性别/年龄。
loadDraft的第三个参数默认值是blankBasicInformation;其余调用点(Line 167、242)都显式传入了当前/恢复的basicInformation,唯独这里的手动重试按钮遗漏了该参数,与函数签名新增的语义不一致。🐛 建议修复
- <Button className="mt-3" size="sm" variant="ghost" onPress={() => void loadDraft(session.id, true)} isDisabled={isBusy}>重新获取草稿</Button> + <Button className="mt-3" size="sm" variant="ghost" onPress={() => void loadDraft(session.id, true, basicInformation)} isDisabled={isBusy}>重新获取草稿</Button>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/pages/FamilyIntakeForm.tsx` around lines 520 - 524, Update the manual retry handler in the draft-loading UI to pass the current basicInformation as loadDraft’s third argument, matching the existing calls at the other loadDraft call sites while preserving the current session.id and retry flag.
187-195: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win离开前的未保存提示未覆盖结构化的
basicInformation草稿。
beforeunload监听器(187-195)与requestCancel(312-318)仍只检查answer.trim()。当当前问题是basic_information时,家属填写的内容存放在basicInformation而非answer,即便已填写但未点击"保存并继续",关闭标签页或点击"暂时离开"都不会触发提示,与"其余答案未提交会提醒"的既有行为不一致。🛡️ 建议修复
useEffect(() => { - if (!answer.trim() || typeof window === 'undefined') return + if ((!answer.trim() && !basicInformationAnswer(basicInformation)) || typeof window === 'undefined') return const warnBeforeLeave = (event: BeforeUnloadEvent) => { event.preventDefault() event.returnValue = '' } window.addEventListener('beforeunload', warnBeforeLeave) return () => window.removeEventListener('beforeunload', warnBeforeLeave) - }, [answer]) + }, [answer, basicInformation])function requestCancel() { - if (answer.trim() && typeof window !== 'undefined') { + if ((answer.trim() || basicInformationAnswer(basicInformation)) && typeof window !== 'undefined') { const proceed = window.confirm('当前答案尚未提交。它会仅保留在此标签页草稿中;确定暂时离开吗?') if (!proceed) return } onCancel() }Also applies to: 312-318
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/pages/FamilyIntakeForm.tsx` around lines 187 - 195, 扩展 FamilyIntakeForm 中 useEffect 的 beforeunload 条件和 requestCancel 的未保存判断,使当前问题为 basic_information 时也检查 basicInformation 是否包含已填写内容,而不是仅检查 answer.trim()。保留现有普通答案的提醒行为,并确保未点击“保存并继续”的结构化草稿在关闭页面或暂时离开时触发提示。
304-310: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift"返回修改"流程未适配结构化的
basic_information,修订会覆盖并丢失姓名/性别/年龄等字段。
openSourceEditor与其对应的编辑区块始终使用通用的editAnswer+TextArea,且editAnswer只回填draft.profile[source.field](例如physical_description的文本,如"佩戴眼镜,穿蓝色外套。")。但当source.source_field === 'basic_information'时(测试 mock 中确有此映射),点击"保存修订并刷新草稿"会以replace: true把field: 'basic_information'的答案整体替换为这段自由文本——先前通过结构化表单提交的姓名、性别、年龄、身高会被静默丢弃,仅留下体貌描述片段。建议:当
editSource.source_field === 'basic_information'时,改用BasicInformationForm(以当前basicInformation状态或从既有草稿反解出的值作为初始值)进行编辑,并在保存时调用basicInformationAnswer(...)生成完整的带标签答案后再提交,而不是复用通用自由文本编辑框。As per path instructions, frontend changes should be reviewed for "validation, data exposure, and user-visible failure paths" — this correction flow can silently discard previously confirmed structured data, which is a user-visible data-loss failure path.
Also applies to: 380-400
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/pages/FamilyIntakeForm.tsx` around lines 304 - 310, Update the correction flow around openSourceEditor and its save handler to special-case editSource.source_field === 'basic_information': render BasicInformationForm with the current structured basicInformation values (or values reconstructed from the draft), and on save generate the complete labeled answer via basicInformationAnswer before submitting. Keep the generic editAnswer/TextArea path for other source fields, and validate the structured form before allowing submission so existing name, gender, age, height, and description data cannot be silently replaced.Source: Path instructions
🧹 Nitpick comments (1)
frontend/src/pages/FamilyIntakeForm.test.tsx (1)
168-193: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value测试覆盖了结构化基础信息提交的主路径,契约断言到位。
建议后续在
FamilyIntakeForm.tsx中的validInteger缺陷修复后,补充一条"年龄留空"用例(断言拼接文本中不出现"年龄:0 岁"),以防回归。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/pages/FamilyIntakeForm.test.tsx` around lines 168 - 193, Extend the FamilyIntakeForm tests with an “年龄” left blank scenario after fixing validInteger in FamilyIntakeForm.tsx, and assert the submitted basic_information answer omits the “年龄:0 岁” entry while preserving the other populated fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/pages/FamilyIntakeForm.tsx`:
- Around line 671-722: Update validInteger to treat a blank or whitespace-only
value as invalid and return null before applying numeric conversion and range
validation. Preserve valid zero when explicitly entered, so
basicInformationAnswer omits only empty ages and profileFromDraft initializes
them as null while existing height validation remains unchanged.
---
Outside diff comments:
In `@frontend/src/pages/FamilyIntakeForm.tsx`:
- Around line 520-524: Update the manual retry handler in the draft-loading UI
to pass the current basicInformation as loadDraft’s third argument, matching the
existing calls at the other loadDraft call sites while preserving the current
session.id and retry flag.
- Around line 187-195: 扩展 FamilyIntakeForm 中 useEffect 的 beforeunload 条件和
requestCancel 的未保存判断,使当前问题为 basic_information 时也检查 basicInformation
是否包含已填写内容,而不是仅检查 answer.trim()。保留现有普通答案的提醒行为,并确保未点击“保存并继续”的结构化草稿在关闭页面或暂时离开时触发提示。
- Around line 304-310: Update the correction flow around openSourceEditor and
its save handler to special-case editSource.source_field ===
'basic_information': render BasicInformationForm with the current structured
basicInformation values (or values reconstructed from the draft), and on save
generate the complete labeled answer via basicInformationAnswer before
submitting. Keep the generic editAnswer/TextArea path for other source fields,
and validate the structured form before allowing submission so existing name,
gender, age, height, and description data cannot be silently replaced.
---
Nitpick comments:
In `@frontend/src/pages/FamilyIntakeForm.test.tsx`:
- Around line 168-193: Extend the FamilyIntakeForm tests with an “年龄” left blank
scenario after fixing validInteger in FamilyIntakeForm.tsx, and assert the
submitted basic_information answer omits the “年龄:0 岁” entry while preserving the
other populated fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 973fe6a2-25cb-4751-80bd-e3095c027339
📒 Files selected for processing (3)
frontend/src/api/intake.tsfrontend/src/pages/FamilyIntakeForm.test.tsxfrontend/src/pages/FamilyIntakeForm.tsx
Preview readyThe preview for this build is available at https://pr-129-e7dab5cda278.angui.cg8.site. Temporary demo accounts (all use the password
|
Summary
Closes #128.
session_id) into the page'sIntakeSessionstate shape (id) before storing it, preventing follow-up requests from targeting/intake-sessions/undefined/answers.session_idresponse and structured basic-information submission.Validation
npm test— 8 files, 40 tests passednpm run lintnpm run buildgit diff --checkSummary by CodeRabbit
新功能
问题修复