Commit 49558f4
committed
fix(dashboard): guard ModelSelect against non-string value mid-render
`ModelSelect`'s `value` prop is typed `string | undefined`, but it comes
from `getNestedValue(formData(), path)` which returns `unknown` — the
`as string | undefined` cast at call sites was a typed lie. When the
ConfigForm prop `content` switched between Pi and OpenCode tabs and
formData updated asynchronously via `createEffect`, JSX's fine-grained
reactivity could observe `props.value` as truthy on the outer ternary
(line 80) while the inner `.substring()` calls (lines 82-83) re-read it
as undefined within the same render, crashing with `undefined is not an
object (evaluating 'e.value.substring')`. Triggered by clicking Pi
config → OpenCode config in the ConfigEditor's tab strip.
Memoizes a normalized string view of `props.value` via `createMemo`,
falling back to "" for non-string or undefined values, and routes every
read of the value through that memo so the ternary and the inner
`.substring()` calls share one consistent snapshot per render.
Dashboard typecheck/build clean.1 parent 6c85921 commit 49558f4
1 file changed
Lines changed: 16 additions & 8 deletions
Lines changed: 16 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
63 | 72 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| |||
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
79 | | - | |
80 | | - | |
| 87 | + | |
| 88 | + | |
81 | 89 | | |
82 | | - | |
83 | | - | |
| 90 | + | |
| 91 | + | |
84 | 92 | | |
85 | 93 | | |
86 | 94 | | |
| |||
0 commit comments