Commit 93d2670
authored
🤖 Add forward compatibility for workspace path access (#273)
## Problem
When switching between branches with different config formats, the app
crashes with:
```
Cannot read properties of undefined (reading 'split')
at AppInner (App.tsx:684:100)
```
This occurs because newer branches may add fields to the workspace
config that older code doesn't expect (e.g., `namedWorkspacePath`, `id`,
`name`).
## Solution
Add optional chaining (`?.`) to all `workspacePath.split()` calls and
provide sensible fallbacks:
```typescript
// Before
selectedWorkspace.workspacePath.split("/").pop()
// After
selectedWorkspace.workspacePath?.split("/").pop() ?? selectedWorkspace.workspaceId
```
## Changes
- **App.tsx**: Made `workspacePath` access defensive in ErrorBoundary
and AIView
- **utils/commands/sources.ts**: Made `workspacePath` access defensive
in all command sources
## Testing
- `make typecheck` passes ✅
- Allows switching between branches without config-related crashes
- Handles both old format (only `path`) and new format (`id`, `name`,
`path`)
## Impact
This is a **defensive improvement** that makes the app more robust. No
behavior changes for normal operation - only prevents crashes when
config format mismatches occur.1 parent 03ec5f3 commit 93d2670
2 files changed
+15
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
682 | | - | |
| 682 | + | |
683 | 683 | | |
684 | | - | |
| 684 | + | |
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
690 | | - | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
691 | 695 | | |
692 | 696 | | |
693 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
197 | | - | |
| 196 | + | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
| 297 | + | |
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
| 312 | + | |
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| |||
0 commit comments