Loading...
Loading...
Compare original and translation side by side
setComposeMode(true)selectThread(null)selectThreadcomposeMode: falsesetComposeMode(true)selectThread(null)selectThreadcomposeMode: false1. IDENTIFY the handler (onClick, onSubmit, onChange, etc.)
2. TRACE every function call in the handler, IN ORDER
3. For EACH function call:
a. What state does it READ?
b. What state does it WRITE?
c. Does it have SIDE EFFECTS on shared state?
d. Does it reset/clear any state as a side effect?
4. CHECK: Does any later call UNDO a state change from an earlier call?
5. CHECK: Is the FINAL state what the user expects from the button label?
6. CHECK: Are there race conditions (async calls that resolve in wrong order)?1. 识别处理函数(onClick、onSubmit、onChange等)
2. 按顺序追踪处理函数中的每一次函数调用
3. 针对每一次函数调用:
a. 它读取了哪些状态?
b. 它修改了哪些状态?
c. 它是否对共享状态产生副作用?
d. 它是否会作为副作用重置/清除任何状态?
4. 检查:后续调用是否抵消了之前调用的状态变更?
5. 检查:最终状态是否符合用户对按钮标签的预期?
6. 检查:是否存在竞态条件(异步调用以错误顺序完成)?For each Zustand store / React context in scope:
For each action/setter:
- What fields does it set?
- Does it RESET other fields as a side effect?
- Document: actionName → {sets: [...], resets: [...]}selectThreadcomposeModeSTORE: emailStore
setComposeMode(bool) → sets: {composeMode}
selectThread(thread|null) → sets: {selectedThread, selectedThreadId, messages, drafts, selectedDraft, summary} RESETS: {composeMode: false, composeData: null, redraftOpen: false}
setDraftGenerating(bool) → sets: {draftGenerating}
...
DANGEROUS RESETS (actions that clear state they don't own):
selectThread → resets composeMode (owned by setComposeMode)
reset → resets everything针对作用域内的每个Zustand存储/React context:
针对每个操作/设置函数:
- 它设置了哪些字段?
- 它是否会作为副作用重置其他字段?
- 记录:actionName → {sets: [...], resets: [...]}selectThreadcomposeModeSTORE: emailStore
setComposeMode(bool) → sets: {composeMode}
selectThread(thread|null) → sets: {selectedThread, selectedThreadId, messages, drafts, selectedDraft, summary} RESETS: {composeMode: false, composeData: null, redraftOpen: false}
setDraftGenerating(bool) → sets: {draftGenerating}
...
危险重置(会清除非自身所属状态的操作):
selectThread → 重置composeMode(属于setComposeMode的管辖范围)
reset → 重置所有状态TOUCHPOINT: [Button label] in [Component:line]
HANDLER: onClick → {
call 1: functionA() → sets {X: true}
call 2: functionB() → sets {Y: null} RESETS {X: false} ← CONFLICT
}
EXPECTED: User sees [description of what button label promises]
ACTUAL: X is false because functionB reset it
VERDICT: BUG — [description]交互点:[按钮标签] 在 [组件:行号]
处理函数: onClick → {
调用1: functionA() → 设置 {X: true}
调用2: functionB() → 设置 {Y: null} 重置 {X: false} ← 冲突
}
预期:用户看到[按钮标签承诺的效果描述]
实际:X为false,因为functionB重置了它
结论:BUG — [问题描述]handler() {
setState_A(true) // sets X = true
setState_B(null) // side effect: resets X = false
}
// Result: X is false. First call was pointless.handler() {
setState_A(true) // 设置X = true
setState_B(null) // 副作用:重置X = false
}
// 结果:X为false,第一次调用毫无意义handler() {
fetchA().then(() => setState({ loading: false }))
fetchB().then(() => setState({ loading: true }))
}
// Result: final loading state depends on which resolves firsthandler() {
fetchA().then(() => setState({ loading: false }))
fetchB().then(() => setState({ loading: true }))
}
// 结果:最终loading状态取决于哪个请求先完成const [count, setCount] = useState(0)
const handler = useCallback(() => {
setCount(count + 1) // captures stale count
setCount(count + 1) // same stale count — increments by 1, not 2
}, [count])const [count, setCount] = useState(0)
const handler = useCallback(() => {
setCount(count + 1) // 捕获了过期的count值
setCount(count + 1) // 同样使用过期值 — 最终只增加了1,而非2
}, [count])// Button says "Save" but handler only validates, never actually saves
// Button says "Delete" but handler sets a flag without calling the API
// Button says "Send" but the API endpoint is removed/broken// 按钮显示“保存”,但处理函数仅做验证,从未实际执行保存操作
// 按钮显示“删除”,但处理函数仅设置了一个标记,未调用API
// 按钮显示“发送”,但对应的API端点已被移除/损坏handler() {
if (someState) { // someState is ALWAYS false at this point
doTheActualThing() // never reached
}
}handler() {
if (someState) { // 此处someState始终为false
doTheActualThing() // 永远不会执行到
}
}// Button sets stateX = true
// A useEffect watches stateX and resets it to false
// User sees nothing happen// 按钮设置stateX = true
// 某个useEffect监听stateX并将其重置为false
// 用户看不到任何变化CLICK-PATH-NNN: [severity: CRITICAL/HIGH/MEDIUM/LOW]
Touchpoint: [Button label] in [file:line]
Pattern: [Sequential Undo / Async Race / Stale Closure / Missing Transition / Dead Path / useEffect Interference]
Handler: [function name or inline]
Trace:
1. [call] → sets {field: value}
2. [call] → RESETS {field: value} ← CONFLICT
Expected: [what user expects]
Actual: [what actually happens]
Fix: [specific fix]CLICK-PATH-NNN: [严重程度: CRITICAL/HIGH/MEDIUM/LOW]
交互点: [按钮标签] 在 [文件:行号]
模式: [顺序抵消 / 异步竞态 / 闭包过期 / 缺失状态转换 / 死路径 / useEffect干扰]
处理函数: [函数名或内联代码]
追踪:
1. [调用] → 设置 {字段: 值}
2. [调用] → 重置 {字段: 值} ← 冲突
预期: [用户预期的效果]
实际: [实际发生的情况]
修复方案: [具体修复建议]Agent 1: Map ALL state stores (Step 1) — this is shared context for all other agents
Agent 2: Dashboard (Tasks, Notes, Journal, Ideas)
Agent 3: Chat (DanteChatColumn, JustChatPage)
Agent 4: Emails (ThreadList, DraftArea, EmailsPage)
Agent 5: Projects (ProjectsPage, ProjectOverviewTab, NewProjectWizard)
Agent 6: CRM (all sub-tabs)
Agent 7: Profile, Settings, Vault, Notifications
Agent 8: Management Suite (all pages)代理1:映射所有状态存储(步骤1)— 作为其他所有代理的共享上下文
代理2:仪表板(任务、笔记、日志、想法)
代理3:聊天(DanteChatColumn、JustChatPage)
代理4:邮件(ThreadList、DraftArea、EmailsPage)
代理5:项目(ProjectsPage、ProjectOverviewTab、NewProjectWizard)
代理6:CRM(所有子标签页)
代理7:个人资料、设置、保险箱、通知
代理8:管理套件(所有页面)/superpowers:systematic-debugging/superpowers:verification-before-completion/superpowers:test-driven-development/superpowers:systematic-debugging/superpowers:verification-before-completion/superpowers:test-driven-developmentonClick={() => {
useEmailStore.getState().setComposeMode(true) // ✓ sets composeMode = true
useEmailStore.getState().selectThread(null) // ✗ RESETS composeMode = false
}}selectThread: (thread) => set({
selectedThread: thread,
selectedThreadId: thread?.id ?? null,
messages: [],
drafts: [],
selectedDraft: null,
summary: null,
composeMode: false, // ← THIS silent reset killed the button
composeData: null,
redraftOpen: false,
})selectThreadcomposeModeonClick={() => {
useEmailStore.getState().setComposeMode(true) // ✓ 设置composeMode = true
useEmailStore.getState().selectThread(null) // ✗ 重置composeMode = false
}}selectThread: (thread) => set({
selectedThread: thread,
selectedThreadId: thread?.id ?? null,
messages: [],
drafts: [],
selectedDraft: null,
summary: null,
composeMode: false, // ← 这个静默重置导致按钮失效
composeData: null,
redraftOpen: false,
})selectThreadcomposeMode