dsh-ris-ide 1.6.10 → 1.6.11

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.
package/lib/client.js CHANGED
@@ -227,6 +227,36 @@ window.__ModuleLoader__.load({
227
227
  ]
228
228
  var RIS_STREAM_HUB = null
229
229
 
230
+ /**
231
+ * Which frames a subscriber gets.
232
+ *
233
+ * The socket carries the UNION of everyone's topics and ONE tail path, but not
234
+ * every frame belongs to its own topic: the host opens the file for whoever
235
+ * asked for `tail` and then pushes the bytes as `append` (plus `service` /
236
+ * `tail-error` for that same file). Filtering strictly on `sub.topics` dropped
237
+ * every one of those frames, so a log pane kept the single snapshot it mounted
238
+ * with — "启动后日志只有启动命令,最大化/点项目行(重挂载)才出后续内容".
239
+ * `stream-error` is a connection-wide report and goes to every subscriber.
240
+ *
241
+ * @param {string[]} topics - the topics this subscriber asked for.
242
+ * @param {string} topic - the frame's event name.
243
+ * @param {string} [subTail] - the tail path this subscriber follows.
244
+ * @param {string} [servedTail] - the tail path the live socket carries ('' = none).
245
+ * @returns {boolean} whether this frame belongs to that subscriber.
246
+ */
247
+ function risFrameWanted(topics, topic, subTail, servedTail) {
248
+ var list = Array.isArray(topics) ? topics : []
249
+ if (list.indexOf(topic) !== -1) return true
250
+ if (topic === 'stream-error') return true
251
+ if (topic !== 'append' && topic !== 'service' && topic !== 'tail-error') return false
252
+ if (list.indexOf('tail') === -1) return false
253
+ // One socket follows one file: only the pane showing that file may apply the
254
+ // bytes (a pane on another file polls instead — see the LogTail fallback).
255
+ if (typeof servedTail === 'string' && servedTail !== '' &&
256
+ typeof subTail === 'string' && subTail !== '' && subTail !== servedTail) return false
257
+ return true
258
+ }
259
+
230
260
  /** Subscribe an object `{topics, sessionId?, cwd?, handlers, onOpen?}` to the hub. */
231
261
  function risStreamHub() {
232
262
  if (RIS_STREAM_HUB !== null) return RIS_STREAM_HUB
@@ -317,7 +347,9 @@ window.__ModuleLoader__.load({
317
347
  var payload
318
348
  try { payload = JSON.parse(event.data) } catch { return }
319
349
  subscribers.forEach(function (sub) {
320
- if ((sub.topics || []).indexOf(topic) === -1) return
350
+ // A frame does not always belong to its own topic (tail bytes arrive
351
+ // as `append`): risFrameWanted owns that mapping.
352
+ if (!risFrameWanted(sub.topics, topic, sub.tail, servedTail)) return
321
353
  var handler = sub.handlers !== undefined ? sub.handlers[topic] : undefined
322
354
  if (typeof handler === 'function') handler(payload)
323
355
  })
@@ -10846,6 +10878,10 @@ var [ui, setUi] = useState(function () {
10846
10878
  stylesFor: stylesFor,
10847
10879
  SearchResults: SearchResults,
10848
10880
  searchHitActiveIndex: searchHitActiveIndex,
10881
+ // Which frames the single stream socket delivers to which subscriber: the
10882
+ // tail bytes ride in `append` frames, so a strict topic match starved every
10883
+ // log pane. Directly testable, and the shape of the bug is easy to regress.
10884
+ risFrameWanted: risFrameWanted,
10849
10885
  mergeGlobalBreakpoints: mergeGlobalBreakpoints,
10850
10886
  /** Test seam: seed the global breakpoint list (no host/session needed). */
10851
10887
  __setGlobalBreakpoints: function (list) { GLOBAL_BREAKPOINTS = Array.isArray(list) ? list : [] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ris-ide",
3
- "version": "1.6.10",
3
+ "version": "1.6.11",
4
4
  "license": "MIT",
5
5
  "description": "RIS-IDE local dev panel for the DSH web GUI: live log tail, one-click start/stop of workspace programs, JDWP debugging, file tree + editor, and a standalone IDE window that carries no session history. · DSH 右侧栏本地开发面板:日志实时跟随、一键启停本地程序、Java 断点调试、文件树与编辑器、独立 IDE 窗口。",
6
6
  "keywords": [
@@ -2361,6 +2361,28 @@ test('the dropdown highlights the exact file-name match, else the first row', ()
2361
2361
  assert.equal(T.searchHitActiveIndex(undefined, undefined), -1)
2362
2362
  })
2363
2363
 
2364
+ test('the one stream socket delivers tail bytes to a viewer that asked for `tail`', async () => {
2365
+ // The host opens the tail FILE for whoever asked for `tail` and pushes the
2366
+ // bytes as `append` (plus `service` / `tail-error` for the same file). A strict
2367
+ // topic match dropped every one of those frames, so a log pane froze on the one
2368
+ // snapshot it mounted with ("只有在最大化/点项目行重挂载后才有后续内容").
2369
+ assert.equal(T.risFrameWanted(['tail'], 'append', '/w/a.log', '/w/a.log'), true, 'append rides the tail subscription')
2370
+ assert.equal(T.risFrameWanted(['tail'], 'service', '/w/a.log', '/w/a.log'), true, 'service rides the tail subscription')
2371
+ assert.equal(T.risFrameWanted(['tail'], 'tail-error', '/w/a.log', '/w/a.log'), true, 'a tail failure reaches its viewer')
2372
+ assert.equal(T.risFrameWanted(['tail'], 'tail', '/w/a.log', '/w/a.log'), true)
2373
+ assert.equal(T.risFrameWanted(['tree'], 'append', '/w/a.log', '/w/a.log'), false, 'a tree subscriber never sees tail bytes')
2374
+ assert.equal(T.risFrameWanted(['tail'], 'append', '/w/b.log', '/w/a.log'), false, 'only the pane on the served file applies the bytes')
2375
+ assert.equal(T.risFrameWanted(['tail'], 'append', '/w/b.log', ''), true, 'an unknown served tail still delivers')
2376
+ assert.equal(T.risFrameWanted(['tail'], 'tree', '/w/a.log', '/w/a.log'), false, 'unrelated frames stay filtered')
2377
+ assert.equal(T.risFrameWanted(['programs'], 'stream-error'), true, 'a connection-wide failure reaches everyone')
2378
+ assert.equal(T.risFrameWanted(undefined, 'tree'), false)
2379
+ assert.equal(T.risFrameWanted(undefined, 'stream-error'), true)
2380
+ // The dispatcher must route through it instead of the old strict comparison.
2381
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
2382
+ assert.match(source, /if \(!risFrameWanted\(sub\.topics, topic, sub\.tail, servedTail\)\) return/)
2383
+ assert.doesNotMatch(source, /if \(\(sub\.topics \|\| \[\]\)\.indexOf\(topic\) === -1\) return/, 'the strict topic match is the bug')
2384
+ })
2385
+
2364
2386
  test('the highlighted search row is marked, tinted and hover-driven', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
2365
2387
  const { renderToStaticMarkup } = require(`${REACT_ROOT}/react-dom/server`)
2366
2388
  const markup = renderToStaticMarkup(React.createElement(T.SearchResults, {