@midscene/visualizer 0.30.9 → 0.30.11-beta-20251218071621.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/es/component/blackboard/index.css +8 -0
  2. package/dist/es/component/blackboard/index.mjs +137 -68
  3. package/dist/es/component/config-selector/index.mjs +102 -4
  4. package/dist/es/component/context-preview/index.mjs +1 -2
  5. package/dist/es/component/env-config/index.mjs +1 -2
  6. package/dist/es/component/env-config-reminder/index.css +8 -0
  7. package/dist/es/component/env-config-reminder/index.mjs +1 -2
  8. package/dist/es/component/form-field/index.mjs +5 -10
  9. package/dist/es/component/history-selector/index.css +38 -1
  10. package/dist/es/component/history-selector/index.mjs +1 -2
  11. package/dist/es/component/logo/index.mjs +7 -3
  12. package/dist/es/component/misc/index.mjs +1 -4
  13. package/dist/es/component/nav-actions/index.mjs +1 -2
  14. package/dist/es/component/nav-actions/style.css +1 -1
  15. package/dist/es/component/player/index.css +26 -0
  16. package/dist/es/component/player/index.mjs +376 -364
  17. package/dist/es/component/playground/index.css +291 -31
  18. package/dist/es/component/playground-result/index.css +10 -0
  19. package/dist/es/component/playground-result/index.mjs +129 -10
  20. package/dist/es/component/prompt-input/index.css +281 -31
  21. package/dist/es/component/prompt-input/index.mjs +83 -25
  22. package/dist/es/component/screenshot-viewer/index.css +214 -0
  23. package/dist/es/component/screenshot-viewer/index.mjs +282 -0
  24. package/dist/es/component/service-mode-control/index.mjs +1 -2
  25. package/dist/es/component/shiny-text/index.css +35 -3
  26. package/dist/es/component/shiny-text/index.mjs +3 -3
  27. package/dist/es/component/universal-playground/index.css +61 -1
  28. package/dist/es/component/universal-playground/index.mjs +106 -83
  29. package/dist/es/component/universal-playground/providers/context-provider.mjs +56 -18
  30. package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +213 -139
  31. package/dist/es/component/universal-playground/providers/storage-provider.mjs +199 -121
  32. package/dist/es/hooks/usePlaygroundExecution.mjs +297 -146
  33. package/dist/es/hooks/usePlaygroundState.mjs +141 -75
  34. package/dist/es/hooks/useSafeOverrideAIConfig.mjs +2 -6
  35. package/dist/es/hooks/useServerValid.mjs +37 -12
  36. package/dist/es/hooks/useTheme.mjs +25 -0
  37. package/dist/es/icons/avatar.mjs +46 -4
  38. package/dist/es/icons/close.mjs +46 -4
  39. package/dist/es/icons/global-perspective.mjs +47 -5
  40. package/dist/es/icons/history.mjs +48 -6
  41. package/dist/es/icons/magnifying-glass.mjs +47 -5
  42. package/dist/es/icons/player-setting.mjs +48 -6
  43. package/dist/es/icons/setting.mjs +47 -5
  44. package/dist/es/icons/show-marker.mjs +47 -5
  45. package/dist/es/index.mjs +4 -4
  46. package/dist/es/store/history.mjs +46 -7
  47. package/dist/es/store/store.mjs +68 -2
  48. package/dist/es/types.mjs +1 -1
  49. package/dist/es/utils/constants.mjs +7 -3
  50. package/dist/es/utils/index.mjs +4 -1
  51. package/dist/es/utils/pixi-loader.mjs +37 -11
  52. package/dist/es/utils/replay-scripts.mjs +160 -111
  53. package/dist/lib/component/blackboard/index.css +8 -0
  54. package/dist/lib/component/blackboard/index.js +139 -70
  55. package/dist/lib/component/config-selector/index.js +103 -5
  56. package/dist/lib/component/context-preview/index.js +3 -4
  57. package/dist/lib/component/env-config/index.js +3 -4
  58. package/dist/lib/component/env-config-reminder/index.css +8 -0
  59. package/dist/lib/component/env-config-reminder/index.js +3 -4
  60. package/dist/lib/component/form-field/index.js +10 -15
  61. package/dist/lib/component/history-selector/index.css +38 -1
  62. package/dist/lib/component/history-selector/index.js +3 -4
  63. package/dist/lib/component/index.js +6 -8
  64. package/dist/lib/component/logo/index.js +9 -5
  65. package/dist/lib/component/misc/index.js +6 -9
  66. package/dist/lib/component/nav-actions/index.js +3 -4
  67. package/dist/lib/component/nav-actions/style.css +1 -1
  68. package/dist/lib/component/player/index.css +26 -0
  69. package/dist/lib/component/player/index.js +376 -365
  70. package/dist/lib/component/playground/index.css +291 -31
  71. package/dist/lib/component/playground/index.js +31 -33
  72. package/dist/lib/component/playground-result/index.css +10 -0
  73. package/dist/lib/component/playground-result/index.js +131 -12
  74. package/dist/lib/component/prompt-input/index.css +281 -31
  75. package/dist/lib/component/prompt-input/index.js +84 -26
  76. package/dist/lib/component/screenshot-viewer/index.css +214 -0
  77. package/dist/lib/component/screenshot-viewer/index.js +316 -0
  78. package/dist/lib/component/service-mode-control/index.js +3 -4
  79. package/dist/lib/component/shiny-text/index.css +35 -3
  80. package/dist/lib/component/shiny-text/index.js +5 -5
  81. package/dist/lib/component/universal-playground/index.css +61 -1
  82. package/dist/lib/component/universal-playground/index.js +108 -84
  83. package/dist/lib/component/universal-playground/providers/context-provider.js +58 -20
  84. package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +217 -143
  85. package/dist/lib/component/universal-playground/providers/storage-provider.js +207 -129
  86. package/dist/lib/hooks/usePlaygroundExecution.js +299 -148
  87. package/dist/lib/hooks/usePlaygroundState.js +143 -77
  88. package/dist/lib/hooks/useSafeOverrideAIConfig.js +4 -8
  89. package/dist/lib/hooks/useServerValid.js +39 -14
  90. package/dist/lib/hooks/useTheme.js +59 -0
  91. package/dist/lib/icons/avatar.js +48 -6
  92. package/dist/lib/icons/close.js +48 -6
  93. package/dist/lib/icons/global-perspective.js +49 -7
  94. package/dist/lib/icons/history.js +50 -8
  95. package/dist/lib/icons/magnifying-glass.js +49 -7
  96. package/dist/lib/icons/player-setting.js +50 -8
  97. package/dist/lib/icons/setting.js +49 -7
  98. package/dist/lib/icons/show-marker.js +49 -7
  99. package/dist/lib/index.js +44 -34
  100. package/dist/lib/store/history.js +48 -9
  101. package/dist/lib/store/store.js +74 -8
  102. package/dist/lib/types.js +3 -3
  103. package/dist/lib/utils/color.js +2 -2
  104. package/dist/lib/utils/constants.js +20 -4
  105. package/dist/lib/utils/index.js +10 -4
  106. package/dist/lib/utils/pixi-loader.js +41 -15
  107. package/dist/lib/utils/playground-utils.js +4 -4
  108. package/dist/lib/utils/replay-scripts.js +164 -115
  109. package/dist/types/component/config-selector/index.d.ts +2 -0
  110. package/dist/types/component/player/index.d.ts +0 -1
  111. package/dist/types/component/playground-result/index.d.ts +1 -0
  112. package/dist/types/component/prompt-input/index.d.ts +2 -1
  113. package/dist/types/component/screenshot-viewer/index.d.ts +15 -0
  114. package/dist/types/hooks/usePlaygroundExecution.d.ts +1 -1
  115. package/dist/types/hooks/usePlaygroundState.d.ts +3 -3
  116. package/dist/types/hooks/useTheme.d.ts +7 -0
  117. package/dist/types/index.d.ts +3 -3
  118. package/dist/types/store/store.d.ts +18 -1
  119. package/dist/types/types.d.ts +14 -4
  120. package/dist/types/utils/constants.d.ts +5 -1
  121. package/dist/types/utils/index.d.ts +1 -0
  122. package/dist/types/utils/replay-scripts.d.ts +1 -1
  123. package/package.json +12 -22
@@ -26,131 +26,240 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  usePlaygroundExecution: ()=>usePlaygroundExecution
28
28
  });
29
+ const agent_namespaceObject = require("@midscene/core/agent");
29
30
  const external_react_namespaceObject = require("react");
30
31
  const store_js_namespaceObject = require("../store/store.js");
31
- const playground_namespaceObject = require("@midscene/playground");
32
32
  const constants_js_namespaceObject = require("../utils/constants.js");
33
33
  const replay_scripts_js_namespaceObject = require("../utils/replay-scripts.js");
34
- function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, setLoading, infoList, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef) {
35
- const { deepThink, screenshotIncluded, domIncluded } = (0, store_js_namespaceObject.useEnvConfig)();
36
- const handleRun = (0, external_react_namespaceObject.useCallback)(async (value)=>{
37
- if (!playgroundSDK) return void console.warn('PlaygroundSDK is not available');
38
- const thisRunningId = Date.now();
39
- const actionType = value.type;
40
- const displayContent = `${value.type}: ${value.prompt || JSON.stringify(value.params)}`;
41
- const userItem = {
42
- id: `user-${Date.now()}`,
43
- type: 'user',
44
- content: displayContent,
45
- timestamp: new Date()
46
- };
47
- setInfoList((prev)=>[
48
- ...prev,
49
- userItem
50
- ]);
51
- setLoading(true);
52
- const result = {
53
- ...constants_js_namespaceObject.BLANK_RESULT
54
- };
55
- const systemItem = {
56
- id: `system-${thisRunningId}`,
57
- type: 'system',
58
- content: '',
59
- timestamp: new Date(),
60
- loading: true,
61
- loadingProgressText: ''
62
- };
63
- setInfoList((prev)=>[
64
- ...prev,
65
- systemItem
66
- ]);
67
- try {
68
- currentRunningIdRef.current = thisRunningId;
69
- interruptedFlagRef.current[thisRunningId] = false;
70
- if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
71
- if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate((tip)=>{
72
- if (interruptedFlagRef.current[thisRunningId]) return;
73
- setInfoList((prev)=>{
74
- const lastItem = prev[prev.length - 1];
75
- if (lastItem && 'progress' === lastItem.type && lastItem.content === tip) return prev;
76
- const progressItem = {
77
- id: `progress-${thisRunningId}-${Date.now()}`,
78
- type: 'progress',
79
- content: tip,
80
- timestamp: new Date()
81
- };
82
- return [
83
- ...prev,
84
- progressItem
85
- ];
86
- });
87
- });
88
- result.result = await playgroundSDK.executeAction(actionType, value, {
89
- requestId: thisRunningId.toString(),
90
- deepThink,
91
- screenshotIncluded,
92
- domIncluded
93
- });
94
- if ('object' == typeof result.result && null !== result.result) {
95
- const resultObj = result.result;
96
- if (resultObj.dump) result.dump = resultObj.dump;
97
- if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
98
- if (resultObj.error) result.error = resultObj.error;
99
- if (void 0 !== resultObj.result) result.result = resultObj.result;
34
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
35
+ try {
36
+ var info = gen[key](arg);
37
+ var value = info.value;
38
+ } catch (error) {
39
+ reject(error);
40
+ return;
41
+ }
42
+ if (info.done) resolve(value);
43
+ else Promise.resolve(value).then(_next, _throw);
44
+ }
45
+ function _async_to_generator(fn) {
46
+ return function() {
47
+ var self = this, args = arguments;
48
+ return new Promise(function(resolve, reject) {
49
+ var gen = fn.apply(self, args);
50
+ function _next(value) {
51
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
100
52
  }
101
- } catch (e) {
102
- result.error = (null == e ? void 0 : e.message) || String(e);
103
- console.error('Playground execution error:', e);
104
- }
105
- if (interruptedFlagRef.current[thisRunningId]) return;
106
- setLoading(false);
107
- currentRunningIdRef.current = null;
108
- let replayInfo = null;
109
- let counter = replayCounter;
110
- if ((null == result ? void 0 : result.dump) && !playground_namespaceObject.noReplayAPIs.includes(actionType)) {
111
- const info = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(result.dump);
112
- setReplayCounter((c)=>c + 1);
113
- replayInfo = info;
114
- counter = replayCounter + 1;
115
- }
116
- setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? {
117
- ...item,
118
- content: '',
119
- loading: false,
120
- loadingProgressText: ''
121
- } : item));
122
- const resultItem = {
123
- id: `result-${thisRunningId}`,
124
- type: 'result',
125
- content: 'Execution result',
126
- timestamp: new Date(),
127
- result: result,
128
- loading: false,
129
- replayScriptsInfo: replayInfo,
130
- replayCounter: counter,
131
- loadingProgressText: '',
132
- verticalMode: verticalMode
133
- };
134
- setInfoList((prev)=>[
135
- ...prev,
136
- resultItem
137
- ]);
138
- if (null == storage ? void 0 : storage.saveResult) try {
139
- await storage.saveResult(resultItem.id, resultItem);
140
- } catch (error) {
141
- console.error('Failed to save result:', error);
53
+ function _throw(err) {
54
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
55
+ }
56
+ _next(void 0);
57
+ });
58
+ };
59
+ }
60
+ function _define_property(obj, key, value) {
61
+ if (key in obj) Object.defineProperty(obj, key, {
62
+ value: value,
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true
66
+ });
67
+ else obj[key] = value;
68
+ return obj;
69
+ }
70
+ function _object_spread(target) {
71
+ for(var i = 1; i < arguments.length; i++){
72
+ var source = null != arguments[i] ? arguments[i] : {};
73
+ var ownKeys = Object.keys(source);
74
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
75
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
76
+ }));
77
+ ownKeys.forEach(function(key) {
78
+ _define_property(target, key, source[key]);
79
+ });
80
+ }
81
+ return target;
82
+ }
83
+ function usePlaygroundExecution_ownKeys(object, enumerableOnly) {
84
+ var keys = Object.keys(object);
85
+ if (Object.getOwnPropertySymbols) {
86
+ var symbols = Object.getOwnPropertySymbols(object);
87
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
88
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
89
+ });
90
+ keys.push.apply(keys, symbols);
91
+ }
92
+ return keys;
93
+ }
94
+ function _object_spread_props(target, source) {
95
+ source = null != source ? source : {};
96
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
97
+ else usePlaygroundExecution_ownKeys(Object(source)).forEach(function(key) {
98
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
99
+ });
100
+ return target;
101
+ }
102
+ function buildProgressContent(task) {
103
+ const action = (0, agent_namespaceObject.typeStr)(task);
104
+ const description = (0, agent_namespaceObject.paramStr)(task);
105
+ return description ? `${action} - ${description}` : action;
106
+ }
107
+ function wrapExecutionDumpForReplay(dump) {
108
+ const modelBriefsSet = new Set();
109
+ if ((null == dump ? void 0 : dump.tasks) && Array.isArray(dump.tasks)) dump.tasks.forEach((task)=>{
110
+ if (task.usage) {
111
+ const { model_name, model_description, intent } = task.usage;
112
+ if (intent && model_name) modelBriefsSet.add(model_description ? `${intent}/${model_name}(${model_description})` : `${intent}/${model_name}`);
142
113
  }
143
- const separatorItem = {
144
- id: `separator-${thisRunningId}`,
145
- type: 'separator',
146
- content: 'New Session',
147
- timestamp: new Date()
148
- };
149
- setInfoList((prev)=>[
150
- ...prev,
151
- separatorItem
152
- ]);
153
- }, [
114
+ });
115
+ else console.warn('[wrapExecutionDumpForReplay] Invalid dump structure:', dump);
116
+ const modelBriefs = [
117
+ ...modelBriefsSet
118
+ ];
119
+ return {
120
+ sdkVersion: '',
121
+ groupName: 'Playground Execution',
122
+ modelBriefs,
123
+ executions: [
124
+ dump
125
+ ]
126
+ };
127
+ }
128
+ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, setLoading, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef) {
129
+ const { deepThink, screenshotIncluded, domIncluded, planningStrategy } = (0, store_js_namespaceObject.useEnvConfig)();
130
+ const handleRun = (0, external_react_namespaceObject.useCallback)((value)=>_async_to_generator(function*() {
131
+ if (!playgroundSDK) return void console.warn('PlaygroundSDK is not available');
132
+ const thisRunningId = Date.now();
133
+ const actionType = value.type;
134
+ const displayContent = `${value.type}: ${value.prompt || JSON.stringify(value.params)}`;
135
+ const userItem = {
136
+ id: `user-${Date.now()}`,
137
+ type: 'user',
138
+ content: displayContent,
139
+ timestamp: new Date()
140
+ };
141
+ setInfoList((prev)=>[
142
+ ...prev,
143
+ userItem
144
+ ]);
145
+ setLoading(true);
146
+ const result = _object_spread({}, constants_js_namespaceObject.BLANK_RESULT);
147
+ const systemItem = {
148
+ id: `system-${thisRunningId}`,
149
+ type: 'system',
150
+ content: '',
151
+ timestamp: new Date(),
152
+ loading: true,
153
+ loadingProgressText: ''
154
+ };
155
+ setInfoList((prev)=>[
156
+ ...prev,
157
+ systemItem
158
+ ]);
159
+ try {
160
+ currentRunningIdRef.current = thisRunningId;
161
+ interruptedFlagRef.current[thisRunningId] = false;
162
+ if (playgroundSDK.onDumpUpdate) playgroundSDK.onDumpUpdate((_, executionDump)=>{
163
+ var _executionDump_tasks;
164
+ if (interruptedFlagRef.current[thisRunningId] || !(null == executionDump ? void 0 : null == (_executionDump_tasks = executionDump.tasks) ? void 0 : _executionDump_tasks.length)) return;
165
+ const progressItems = executionDump.tasks.map((task, index)=>{
166
+ var _task_timing;
167
+ return {
168
+ id: `progress-${thisRunningId}-task-${index}`,
169
+ type: 'progress',
170
+ content: buildProgressContent(task),
171
+ timestamp: new Date((null == (_task_timing = task.timing) ? void 0 : _task_timing.start) || Date.now()),
172
+ result: task.error ? {
173
+ error: String(task.error),
174
+ result: null
175
+ } : void 0
176
+ };
177
+ });
178
+ setInfoList((prev)=>{
179
+ const systemItemIndex = prev.findIndex((item)=>item.id === `system-${thisRunningId}`);
180
+ if (-1 === systemItemIndex) return prev;
181
+ const listWithoutCurrentProgress = prev.filter((item)=>!('progress' === item.type && item.id.startsWith(`progress-${thisRunningId}-`)));
182
+ return [
183
+ ...listWithoutCurrentProgress.slice(0, systemItemIndex + 1),
184
+ ...progressItems,
185
+ ...listWithoutCurrentProgress.slice(systemItemIndex + 1)
186
+ ];
187
+ });
188
+ });
189
+ result.result = yield playgroundSDK.executeAction(actionType, value, {
190
+ requestId: thisRunningId.toString(),
191
+ deepThink,
192
+ planningStrategy,
193
+ screenshotIncluded,
194
+ domIncluded
195
+ });
196
+ if ('object' == typeof result.result && null !== result.result) {
197
+ const resultObj = result.result;
198
+ if (resultObj.dump) result.dump = resultObj.dump;
199
+ if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
200
+ if (resultObj.error) result.error = resultObj.error;
201
+ if (void 0 !== resultObj.result) result.result = resultObj.result;
202
+ }
203
+ } catch (e) {
204
+ result.error = (null == e ? void 0 : e.message) || String(e);
205
+ console.error('Playground execution error:', e);
206
+ if ('object' == typeof e && null !== e) {
207
+ if (e.dump) result.dump = e.dump;
208
+ if (e.reportHTML) result.reportHTML = e.reportHTML;
209
+ }
210
+ }
211
+ if (interruptedFlagRef.current[thisRunningId]) return;
212
+ setLoading(false);
213
+ currentRunningIdRef.current = null;
214
+ let replayInfo = null;
215
+ let counter = replayCounter;
216
+ if (null == result ? void 0 : result.dump) {
217
+ if (result.dump.tasks && Array.isArray(result.dump.tasks)) {
218
+ const groupedDump = wrapExecutionDumpForReplay(result.dump);
219
+ const info = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(groupedDump);
220
+ setReplayCounter((c)=>c + 1);
221
+ replayInfo = info;
222
+ counter = replayCounter + 1;
223
+ }
224
+ }
225
+ setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
226
+ content: '',
227
+ loading: false,
228
+ loadingProgressText: ''
229
+ }) : item));
230
+ const resultItem = {
231
+ id: `result-${thisRunningId}`,
232
+ type: 'result',
233
+ content: 'Execution result',
234
+ timestamp: new Date(),
235
+ result: result,
236
+ loading: false,
237
+ replayScriptsInfo: replayInfo,
238
+ replayCounter: counter,
239
+ loadingProgressText: '',
240
+ verticalMode: verticalMode,
241
+ actionType: actionType
242
+ };
243
+ setInfoList((prev)=>[
244
+ ...prev,
245
+ resultItem
246
+ ]);
247
+ if (null == storage ? void 0 : storage.saveResult) try {
248
+ yield storage.saveResult(resultItem.id, resultItem);
249
+ } catch (error) {
250
+ console.error('Failed to save result:', error);
251
+ }
252
+ const separatorItem = {
253
+ id: `separator-${thisRunningId}`,
254
+ type: 'separator',
255
+ content: 'New Session',
256
+ timestamp: new Date()
257
+ };
258
+ setInfoList((prev)=>[
259
+ ...prev,
260
+ separatorItem
261
+ ]);
262
+ })(), [
154
263
  playgroundSDK,
155
264
  storage,
156
265
  actionSpace,
@@ -162,41 +271,83 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
162
271
  currentRunningIdRef,
163
272
  interruptedFlagRef,
164
273
  deepThink,
274
+ planningStrategy,
165
275
  screenshotIncluded,
166
276
  domIncluded
167
277
  ]);
168
- const handleStop = (0, external_react_namespaceObject.useCallback)(async ()=>{
169
- const thisRunningId = currentRunningIdRef.current;
170
- if (thisRunningId && playgroundSDK && playgroundSDK.cancelExecution) try {
171
- await playgroundSDK.cancelExecution(thisRunningId.toString());
172
- interruptedFlagRef.current[thisRunningId] = true;
173
- setLoading(false);
174
- if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
175
- setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` && item.loading ? {
176
- ...item,
177
- content: 'Operation stopped',
278
+ const handleStop = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
279
+ const thisRunningId = currentRunningIdRef.current;
280
+ if (thisRunningId && playgroundSDK && playgroundSDK.cancelExecution) try {
281
+ let executionData = null;
282
+ if (playgroundSDK.getCurrentExecutionData) try {
283
+ executionData = yield playgroundSDK.getCurrentExecutionData();
284
+ } catch (error) {
285
+ console.error('Failed to get execution data before stop:', error);
286
+ }
287
+ yield playgroundSDK.cancelExecution(thisRunningId.toString());
288
+ interruptedFlagRef.current[thisRunningId] = true;
289
+ setLoading(false);
290
+ if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
291
+ if (playgroundSDK.onDumpUpdate) playgroundSDK.onDumpUpdate(()=>{});
292
+ setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
293
+ content: '',
294
+ loading: false,
295
+ loadingProgressText: ''
296
+ }) : item));
297
+ if (executionData && (executionData.dump || executionData.reportHTML)) {
298
+ const resultItem = {
299
+ id: `stop-result-${thisRunningId}`,
300
+ type: 'result',
301
+ content: 'Execution stopped by user',
302
+ timestamp: new Date(),
303
+ result: {
304
+ result: null,
305
+ dump: executionData.dump,
306
+ reportHTML: executionData.reportHTML,
307
+ error: null
308
+ },
178
309
  loading: false,
179
- loadingProgressText: ''
180
- } : item));
181
- const separatorItem = {
182
- id: `separator-${thisRunningId}`,
183
- type: 'separator',
184
- content: 'New Session',
185
- timestamp: new Date()
186
- };
187
- setInfoList((prev)=>[
188
- ...prev,
189
- separatorItem
190
- ]);
191
- } catch (error) {
192
- console.error('Failed to stop execution:', error);
193
- }
194
- }, [
310
+ verticalMode,
311
+ replayCounter
312
+ };
313
+ setInfoList((prev)=>[
314
+ ...prev,
315
+ resultItem
316
+ ]);
317
+ } else {
318
+ const stopItem = {
319
+ id: `stop-${thisRunningId}`,
320
+ type: 'system',
321
+ content: 'Operation stopped',
322
+ timestamp: new Date(),
323
+ loading: false
324
+ };
325
+ setInfoList((prev)=>[
326
+ ...prev,
327
+ stopItem
328
+ ]);
329
+ }
330
+ const separatorItem = {
331
+ id: `separator-${thisRunningId}`,
332
+ type: 'separator',
333
+ content: 'New Session',
334
+ timestamp: new Date()
335
+ };
336
+ setInfoList((prev)=>[
337
+ ...prev,
338
+ separatorItem
339
+ ]);
340
+ } catch (error) {
341
+ console.error('Failed to stop execution:', error);
342
+ }
343
+ })(), [
195
344
  playgroundSDK,
196
345
  currentRunningIdRef,
197
346
  interruptedFlagRef,
198
347
  setLoading,
199
- setInfoList
348
+ setInfoList,
349
+ verticalMode,
350
+ replayCounter
200
351
  ]);
201
352
  const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK && !!playgroundSDK.cancelExecution;
202
353
  return {
@@ -206,9 +357,9 @@ function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, se
206
357
  };
207
358
  }
208
359
  exports.usePlaygroundExecution = __webpack_exports__.usePlaygroundExecution;
209
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
360
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
210
361
  "usePlaygroundExecution"
211
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
362
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
212
363
  Object.defineProperty(exports, '__esModule', {
213
364
  value: true
214
365
  });