Commit 647a8ce
Improve runtime state views in Positron API (#14825)
Closes #14181
### Summary
Extends the runtime session API on `LanguageRuntimeSession` handles with
three capabilities discussed in #14181.
- **`evaluateCode(..., whenBusy?)`** -- a new optional
`RuntimeBusyBehavior` parameter (`Queue` | `Reject`). `Queue` (default)
preserves today's behavior; `Reject` rejects the evaluation with an
error when the target session is busy instead of queueing it.
- **`getRuntimeState()`** -- a synchronous accessor on
`BaseLanguageRuntimeSession` returning the session's current
`RuntimeState`. Unlike `onDidChangeRuntimeState` (change-only, no
initial value), it can be read at any time to gate work on idleness.
- **`onDidDisconnect` / `onDidReconnect`** -- events on
`BaseLanguageRuntimeSession` that fire when the session's connection to
the underlying runtime drops and is re-established, closing the "silent
reconnect" blind window described in the issue.
The new members are optional on `BaseLanguageRuntimeSession`. They're
implemented on the cross-extension-host session proxy (state and events
forwarded from the main thread via new subscribe/notify RPCs) and on the
real R/Python sessions (`KallichoreSession` is the connection source;
`RSession`/`PythonRuntimeSession` delegate to it).
### Release Notes
#### New Features
- Added a `whenBusy` option to `positron.runtime.evaluateCode`, a
synchronous `getRuntimeState()` accessor, and
`onDidDisconnect`/`onDidReconnect` events on language runtime session
handles (#14181)
#### Bug Fixes
- N/A
### Validation Steps
@:console @:sessions @:reticulate
These are API-surface changes with no UI. Automated coverage:
- **Ext-host API tests** --
`extensions/vscode-api-tests/src/singlefolder-tests/positron/runtime.test.ts`:
`whenBusy=Reject`/`Queue`, `getRuntimeState`, and
`onDidDisconnect`/`onDidReconnect` exposure + firing (fake session).
Run: `./scripts/test-positron-api.sh`
- **Real R (ark) session tests** --
`extensions/positron-r/src/test/runtime-state.test.ts`: live
`getRuntimeState()` Busy->Idle transitions, event exposure, and
`evaluateCode` `whenBusy` Reject/Queue against a real kernel. Run: `npm
run test-extension -- -l positron-r --grep "Runtime state API"`
- **Proxy unit tests** --
`src/vs/workbench/api/test/common/positron/extHostLanguageRuntime.vitest.ts`:
cross-host proxy state seeding, state/disconnect/reconnect forwarding,
and subscribe/unsubscribe lifecycle. Run: `npx vitest run
src/vs/workbench/api/test/common/positron/extHostLanguageRuntime.vitest.ts`
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent e6f7af5 commit 647a8ce
13 files changed
Lines changed: 984 additions & 30 deletions
File tree
- extensions
- positron-python/src/client/positron
- positron-r/src
- test
- positron-supervisor/src
- vscode-api-tests/src/singlefolder-tests/positron
- src
- positron-dts
- vs/workbench
- api
- browser/positron
- common/positron
- test/common/positron
- services/languageRuntime/common
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
| |||
138 | 147 | | |
139 | 148 | | |
140 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
141 | 154 | | |
142 | 155 | | |
143 | 156 | | |
| |||
170 | 183 | | |
171 | 184 | | |
172 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
173 | 190 | | |
174 | 191 | | |
175 | 192 | | |
| |||
180 | 197 | | |
181 | 198 | | |
182 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
183 | 209 | | |
184 | 210 | | |
185 | 211 | | |
| |||
819 | 845 | | |
820 | 846 | | |
821 | 847 | | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
822 | 852 | | |
823 | 853 | | |
824 | 854 | | |
| |||
904 | 934 | | |
905 | 935 | | |
906 | 936 | | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
907 | 952 | | |
908 | 953 | | |
909 | 954 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
115 | 121 | | |
116 | 122 | | |
117 | 123 | | |
| |||
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
165 | 177 | | |
166 | 178 | | |
167 | 179 | | |
| |||
178 | 190 | | |
179 | 191 | | |
180 | 192 | | |
| 193 | + | |
| 194 | + | |
181 | 195 | | |
182 | 196 | | |
183 | 197 | | |
| |||
186 | 200 | | |
187 | 201 | | |
188 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
189 | 212 | | |
190 | 213 | | |
191 | 214 | | |
| |||
836 | 859 | | |
837 | 860 | | |
838 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
839 | 876 | | |
840 | 877 | | |
841 | 878 | | |
| |||
| 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 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
0 commit comments