[P1] Removing Oxygen and then enabling the rebreather crashes the app #55

Open
opened 2026-10-31 14:14:36 -05:00 by pedro · 0 comments
Owner

Priority: P1
Type: bug
Source: full codebase review requested 2026-10-31 (reproduced against the production build of 2cac7cf)

Location: src/App.tsx Remove gas button and the circuit effect that creates ccr-oxygen; src/planner/ProfilePlanner.tsx [gases] effect (gases.find(g => g.name === "Oxygen")!)

Problem and evidence

Advanced Mode lets you remove "Oxygen" whenever nothing live uses it, which is the default in open circuit. Enabling the rebreather afterwards does two things:

  • The App circuit effect creates a live ccr-oxygen cylinder for the missing gas.
  • ProfilePlanner pushes a planner cylinder whose gas is undefined. The next render reads c.gas.name and throws.

There is no error boundary, so the whole page goes blank.

Reproduction (Playwright, HEAD build):

  • Advanced → Remove Oxygen → tick Rebreather → Close → Planner Mode. Result: pageerror "Cannot read properties of undefined (reading 'name')" and an empty #root.
  • If the planner was opened earlier in the session, the crash happens as soon as Rebreather is ticked.
  • Variant: untick Rebreather and choose "Cylinder 2 · Oxygen" in Active cylinder. Result: "Invalid breathing gas composition." and a blank app.

This is related to #20 (CCR oxygen accounting tied to a user-editable gas name), but here the result is a whole-app crash.

Suggested correction

Give the CCR oxygen supply a dedicated pure-O2 gas that does not depend on the editable list, or re-add Oxygen whenever the CCR oxygen cylinder is created. Remove the non-null lookups. Guard the Active cylinder handler against missing gases. (The error boundary is shared with the plan-restore issue.)

Acceptance criteria

Regression for both reproduction paths: no crash, the CCR oxygen supply stays valid, and the planner renders. pnpm verify passes.

Scope: maintenance of the educational simulator. Preserve historical R1 acceptance and operational-validation limits.

Priority: P1 Type: bug Source: full codebase review requested 2026-10-31 (reproduced against the production build of `2cac7cf`) Location: `src/App.tsx` Remove gas button and the circuit effect that creates `ccr-oxygen`; `src/planner/ProfilePlanner.tsx` `[gases]` effect (`gases.find(g => g.name === "Oxygen")!`) Problem and evidence Advanced Mode lets you remove "Oxygen" whenever nothing live uses it, which is the default in open circuit. Enabling the rebreather afterwards does two things: - The App circuit effect creates a live `ccr-oxygen` cylinder for the missing gas. - ProfilePlanner pushes a planner cylinder whose `gas` is `undefined`. The next render reads `c.gas.name` and throws. There is no error boundary, so the whole page goes blank. Reproduction (Playwright, HEAD build): - Advanced → Remove Oxygen → tick Rebreather → Close → Planner Mode. Result: pageerror "Cannot read properties of undefined (reading 'name')" and an empty `#root`. - If the planner was opened earlier in the session, the crash happens as soon as Rebreather is ticked. - Variant: untick Rebreather and choose "Cylinder 2 · Oxygen" in Active cylinder. Result: "Invalid breathing gas composition." and a blank app. This is related to #20 (CCR oxygen accounting tied to a user-editable gas name), but here the result is a whole-app crash. Suggested correction Give the CCR oxygen supply a dedicated pure-O2 gas that does not depend on the editable list, or re-add Oxygen whenever the CCR oxygen cylinder is created. Remove the non-null lookups. Guard the Active cylinder handler against missing gases. (The error boundary is shared with the plan-restore issue.) Acceptance criteria Regression for both reproduction paths: no crash, the CCR oxygen supply stays valid, and the planner renders. pnpm verify passes. Scope: maintenance of the educational simulator. Preserve historical R1 acceptance and operational-validation limits.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: pedro/DiveSim#55
No description provided.