@goodandready/dsh-cron 0.1.6 → 0.1.8

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 (2) hide show
  1. package/lib/client.js +53 -14
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -28,13 +28,22 @@ const React = window.React || require('react');
28
28
  const ICON_SEND = '<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>';
29
29
 
30
30
  const STYLES = `
31
- html[${ACTIVE_ATTR}] [data-pane=conversation],
32
- html[${ACTIVE_ATTR}] [class*=centerCol] {
31
+ [data-pane=conversation], [class*=centerCol] {
33
32
  position: relative !important;
34
33
  }
34
+ [${VIEW_ATTR}] {
35
+ z-index: 60;
36
+ background: var(--dsw-alias-bg-base, #171717);
37
+ display: none;
38
+ position: absolute;
39
+ inset: 0;
40
+ }
41
+ html[${ACTIVE_ATTR}] [${VIEW_ATTR}] {
42
+ display: block !important;
43
+ }
35
44
  html[${ACTIVE_ATTR}] [data-pane=conversation] > *:not([${VIEW_ATTR}]),
36
45
  html[${ACTIVE_ATTR}] [class*=centerCol] > *:not([${VIEW_ATTR}]) {
37
- visibility: hidden !important;
46
+ display: none !important;
38
47
  }
39
48
 
40
49
  .dsh-cron-entry-clone { display: flex; align-items: center; gap: 8px; }
@@ -144,16 +153,48 @@ const React = window.React || require('react');
144
153
  };
145
154
  }
146
155
 
147
- function openSession(ctx, sessionId) {
156
+ async function openSession(ctx, sessionId) {
148
157
  if (!sessionId) return false;
149
- const sessions = ctx && typeof ctx.get === 'function' ? ctx.get('sessions') : ctx?.sessions;
150
- if (!sessions || typeof sessions.open !== 'function') return false;
151
- try {
152
- sessions.open(sessionId);
153
- return true;
154
- } catch {
155
- return false;
158
+ const getSessions = () => (ctx && typeof ctx.get === 'function' ? ctx.get('sessions') : (ctx && ctx.sessions));
159
+ let sessions = getSessions();
160
+
161
+ // 1. Попытка вызвать sessions.open(sessionId) немедленно
162
+ if (sessions && typeof sessions.open === 'function') {
163
+ try {
164
+ sessions.open(sessionId);
165
+ return true;
166
+ } catch (e) {}
156
167
  }
168
+
169
+ // 2. Если сессия еще не попала в manager.summaries, обновляем список с бэкенда
170
+ if (sessions && typeof sessions.refresh === 'function') {
171
+ try {
172
+ await sessions.refresh();
173
+ sessions.open(sessionId);
174
+ return true;
175
+ } catch (e) {}
176
+ }
177
+
178
+ // 3. Асинхронные ретраи с интервалом (пока WebSocket/SSE событие добавляет сессию в список)
179
+ for (let i = 0; i < 15; i++) {
180
+ await new Promise(resolve => setTimeout(resolve, 120));
181
+ sessions = getSessions();
182
+ if (sessions && typeof sessions.open === 'function') {
183
+ try {
184
+ sessions.open(sessionId);
185
+ return true;
186
+ } catch (e) {}
187
+ }
188
+ // DOM fallback: клик по сессии в боковой панели, если она уже отрендерилась
189
+ if (typeof document !== 'undefined') {
190
+ const domItem = document.querySelector('[data-session-id="' + sessionId + '"], [role="treeitem"][data-id="' + sessionId + '"], [data-id="' + sessionId + '"]');
191
+ if (domItem) {
192
+ domItem.click();
193
+ return true;
194
+ }
195
+ }
196
+ }
197
+ return false;
157
198
  }
158
199
 
159
200
  function CronScreen(props) {
@@ -320,9 +361,7 @@ const React = window.React || require('react');
320
361
  if (onClose) onClose();
321
362
  else toggle.set(false);
322
363
 
323
- if (!openSession(ctx, data.sessionId)) {
324
- alert('Сессия создана (' + data.sessionId + '), перейдите к ней в списке чатов');
325
- }
364
+ await openSession(ctx, data.sessionId);
326
365
  } catch (err) {
327
366
  alert('Ошибка запуска: ' + err.message);
328
367
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-cron",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Scheduled cron tasks, background automation and agent execution for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",