Commit 5bd1a52
authored
fix(playground): saved-replay sidebar + chat resilience (v0.2.3) (#43)
## Summary
Five interlocking playground bugs surfaced during a single user session
— each was masking the next. Fixes them all in one PR; cuts v0.2.3.
- **Saved-replay sidebar ignored manual deletes.**
`vscode.workspace.createFileSystemWatcher` is unreliable for
dot-prefixed paths (notably `.copilotkit/`) on Windows. Replaced with a
Node `fs.watch`-based `FixturesDirWatcher` that retries until the dir
exists. Output channel now logs `[fixtures-watcher] attached`, `fs.watch
<event>`, and `[playground] fixtures dir changed — refreshing sidebar`
so the chain is self-diagnosing.
- **Clicking ▶ on a saved replay produced an empty chat.** The extension
posted `bundle-ready` then `play-fixture` back-to-back; the webview's
`executePlaygroundBundle` is async, so the `play-fixture` `CustomEvent`
fired before the new bundle's `PlaygroundChat` had registered its replay
listener. App shell now unmounts the stale bundle synchronously on
`bundle-ready`, queues the messages in state, and dispatches in a parent
`useEffect` keyed on `[bundle, pendingReplay]` (React runs child effects
before parent effects on the same commit → listener is attached before
dispatch).
- **Clicking ▶ on a deleted fixture permanently bricked the panel.**
`load-fixture` set `replayFixturePath` first, then tried to read. The
read failed but the path stayed, so every subsequent `runBundle` re-read
the missing file and crashed. Refresh did nothing. Now:
read-then-commit; on read failure clear state, refresh the sidebar,
warn. `runBundle` also wraps its fixture read in try/catch and falls
back to record mode when the file vanishes mid-session.
- **Refresh wasn't a recovery path.** `runBundle` now posts a fresh
`fixtures-list` at the *start* of every bundle pass, so Refresh is a
guaranteed manual reconciliation with disk.
- **Chat returned silently with too many `vscode.lm` tools.** Claude
through Copilot Chat returns 200 OK + empty stream when ~80+ tools are
forwarded. `vscode-lm-factory` now auto-retries once without `vscode.lm`
tools, so the user gets a real response on the same query without
changing their settings. If both attempts return empty, an actionable
in-chat message explains the cause and points at
`copilotkit.playground.enableVscodeLmTools`.
- **`LanguageModelDataPart` text/json mimes are now surfaced.** Newer
Claude builds routed through Copilot Chat stream text content as
`DataPart` with `text/plain` or `application/json` mimes — previously
dropped on the floor, producing the same empty-chat symptom. Unknown
part types are logged with their constructor name + mime.
Plus user-driven removal of a stale frontend tool from
`test-workspace/playground/v2/Tools.tsx`.
## Test plan
- [x] `pnpm run check-types` clean
- [x] `pnpm run test` — 312 pass, 1 skipped (added 8 new tests across
`view-provider`, `vscode-lm-factory`, `fixtures-dir-watcher`,
`App.replay-race`)
- [x] Manual: deleted a fixture from disk → sidebar updates within ~1s
- [x] Manual: clicked ▶ on a deleted fixture → toast, sidebar refreshes,
panel does not hang
- [x] Manual: asked "what's the weather in sarajevo" with
`enableVscodeLmTools=true` and 87 vscode.lm tools forwarded → auto-retry
path fires, chat responds normally12 files changed
Lines changed: 925 additions & 36 deletions
File tree
- src
- extension
- playground
- __tests__
- webview/playground
- __tests__
- test-workspace/playground/v2
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
5 | 20 | | |
6 | 21 | | |
7 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
346 | 367 | | |
347 | 368 | | |
348 | 369 | | |
| |||
Lines changed: 92 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
0 commit comments