@leiyi-works/dsh-auto-restart 0.1.4 → 0.1.5

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 (3) hide show
  1. package/README.md +1 -1
  2. package/client.js +126 -11
  3. package/package.json +4 -3
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  只支持 **Windows 桌面端**(Electron 外壳 + Host 子进程的形态)。`dsh web` / headless 不会重启(插件会写日志说明不支持)。
6
6
 
7
- 左侧菜单有一个「自动重启」面板:状态、上次重启回执、开关与参数都在那里改,改完即时生效。
7
+ 左侧菜单有一个「自动重启」入口:点一下先回到会话,再在**右侧原生侧边栏**打开面板(和「临时目录」等插件一致,不遮挡会话);状态、上次重启回执、开关与参数都在那里改,改完即时生效。右侧边栏不可用时才退回全页面板。
8
8
 
9
9
  ## 它怎么判断"插件变了"
10
10
 
package/client.js CHANGED
@@ -19,6 +19,8 @@ window.__ModuleLoader__.load({
19
19
 
20
20
  /** Global panel id shared by the sidebar row and the main page. */
21
21
  const PANEL_ID = 'auto-restart'
22
+ /** Right-sidebar tab type id. */
23
+ const TAB_ID = 'auto-restart-tab'
22
24
  const API = '/auto-restart'
23
25
  const REFRESH_MS = 5000
24
26
 
@@ -27,14 +29,14 @@ window.__ModuleLoader__.load({
27
29
  height: '100%',
28
30
  overflow: 'auto',
29
31
  boxSizing: 'border-box',
30
- padding: '14px 16px 28px',
32
+ padding: '10px 12px 20px',
31
33
  color: 'var(--dsw-alias-label-primary)',
32
34
  fontSize: 13,
33
35
  lineHeight: 1.55,
34
36
  },
35
- inner: { display: 'flex', flexDirection: 'column', gap: 14, maxWidth: 760 },
36
- header: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' },
37
- title: { margin: 0, fontSize: 16, fontWeight: 600 },
37
+ inner: { display: 'flex', flexDirection: 'column', gap: 12 },
38
+ header: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' },
39
+ title: { margin: 0, fontSize: 15, fontWeight: 600 },
38
40
  badge: {
39
41
  fontSize: 11,
40
42
  lineHeight: '18px',
@@ -70,7 +72,7 @@ window.__ModuleLoader__.load({
70
72
  background: 'var(--dsw-alias-bg-layer-2, rgba(127,127,127,.04))',
71
73
  },
72
74
  cardTitle: { margin: 0, fontSize: 13, fontWeight: 600 },
73
- row: { display: 'flex', alignItems: 'center', gap: 10, justifyContent: 'space-between' },
75
+ row: { display: 'flex', alignItems: 'center', gap: 8, justifyContent: 'space-between', flexWrap: 'wrap' },
74
76
  rowMain: { display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 },
75
77
  rowLabel: { fontSize: 13 },
76
78
  rowHint: { fontSize: 11.5, color: 'var(--dsw-alias-label-secondary)' },
@@ -417,7 +419,86 @@ window.__ModuleLoader__.load({
417
419
  name: '@leiyi-works/dsh-auto-restart',
418
420
  inject: ['slots', 'layout'],
419
421
  apply(ctx) {
420
- // 左侧菜单入口。
422
+ /** Opens/focuses this plugin's native right-sidebar tab; null while unavailable. */
423
+ let nativeOpen = null
424
+ let redirecting = false
425
+
426
+ const openTab = () => {
427
+ if (nativeOpen === null) return false
428
+ try {
429
+ nativeOpen()
430
+ return true
431
+ } catch (error) {
432
+ console.warn('[dsh-auto-restart] right-sidebar openTab failed:', error)
433
+ return false
434
+ }
435
+ }
436
+
437
+ /** Register the right-sidebar tab type and its narrow body. */
438
+ const mountTab = (inner) => {
439
+ let registry
440
+ let slots
441
+ let sidebarRight
442
+ try {
443
+ registry = inner.sidebarRightTabs ?? inner.get?.('sidebarRightTabs')
444
+ slots = inner.slots
445
+ sidebarRight = inner.sidebarRight ?? inner.get?.('sidebarRight')
446
+ } catch {
447
+ return undefined
448
+ }
449
+ if (registry === undefined || typeof registry.register !== 'function' || slots === undefined) return undefined
450
+ const disposers = []
451
+ try {
452
+ const disposeType = registry.register({
453
+ id: TAB_ID,
454
+ kind: TAB_ID,
455
+ title: () => '自动重启',
456
+ })
457
+ if (typeof disposeType === 'function') disposers.push(disposeType)
458
+ const disposeBody = slots.inject('sidebar.right.pane.tab', () =>
459
+ slots.register({ name: 'sidebar.right.pane.tab', key: TAB_ID }, (props) => h(AutoRestartPanel, props)),
460
+ )
461
+ if (typeof disposeBody === 'function') disposers.push(disposeBody)
462
+ if (sidebarRight !== undefined && typeof sidebarRight.openTab === 'function') {
463
+ nativeOpen = () => sidebarRight.openTab(TAB_ID)
464
+ }
465
+ } catch (error) {
466
+ for (const dispose of disposers.reverse()) {
467
+ try {
468
+ dispose()
469
+ } catch {
470
+ /* best-effort teardown */
471
+ }
472
+ }
473
+ console.warn('[dsh-auto-restart] right-sidebar tab registration failed:', error)
474
+ return undefined
475
+ }
476
+ return () => {
477
+ for (const dispose of disposers.reverse()) {
478
+ try {
479
+ dispose()
480
+ } catch {
481
+ /* already gone */
482
+ }
483
+ }
484
+ }
485
+ }
486
+
487
+ ctx.effect(() => {
488
+ try {
489
+ return ctx.inject(['sidebarRightTabs', 'sidebarRight', 'slots'], mountTab)
490
+ } catch {
491
+ return mountTab(ctx)
492
+ }
493
+ }, 'dsh-auto-restart: right-sidebar tab')
494
+
495
+ // Full-page fallback, used only when the native right sidebar is unavailable.
496
+ ctx.effect(
497
+ () => ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: PANEL_ID }, AutoRestartPanel)),
498
+ 'dsh-auto-restart: page fallback',
499
+ )
500
+
501
+ // Left-menu entry: same row style as the other plugins.
421
502
  ctx.effect(
422
503
  () =>
423
504
  ctx.slots.inject('sidebar.panellist', () =>
@@ -425,11 +506,45 @@ window.__ModuleLoader__.load({
425
506
  ),
426
507
  'dsh-auto-restart: sidebar entry',
427
508
  )
428
- // 点入口打开全页面板。
429
- ctx.effect(
430
- () => ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: PANEL_ID }, AutoRestartPanel)),
431
- 'dsh-auto-restart: panel page',
432
- )
509
+
510
+ // Clicking the left entry keeps the conversation: return to it, then open the
511
+ // native right-sidebar tab; fall back to the full-page panel when unavailable.
512
+ ctx.effect(() => {
513
+ const layout = ctx.layout
514
+ if (!layout || !layout.panelInfo) return undefined
515
+ const openAfterReturn = () => {
516
+ if (!openTab()) {
517
+ try {
518
+ layout.selectPanel(PANEL_ID)
519
+ } catch (error) {
520
+ console.warn('[dsh-auto-restart] full-page fallback failed:', error)
521
+ }
522
+ }
523
+ redirecting = false
524
+ }
525
+ const check = () => {
526
+ if (redirecting) return
527
+ let active
528
+ try {
529
+ active = layout.panelInfo.getSnapshot().activePanelId
530
+ } catch {
531
+ return
532
+ }
533
+ if (active !== PANEL_ID) return
534
+ redirecting = true
535
+ try {
536
+ layout.selectPanel(null)
537
+ } catch (error) {
538
+ redirecting = false
539
+ console.warn('[dsh-auto-restart] returning to the conversation failed:', error)
540
+ return
541
+ }
542
+ if (typeof queueMicrotask === 'function') queueMicrotask(openAfterReturn)
543
+ else setTimeout(openAfterReturn, 0)
544
+ }
545
+ check()
546
+ return layout.panelInfo.subscribe(check)
547
+ }, 'dsh-auto-restart: entry opens the right-sidebar tab')
433
548
  },
434
549
  }
435
550
  },
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@leiyi-works/dsh-auto-restart",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "title": "自动重启",
6
- "description": "装/更插件后自动重启 DSH 并回到原会话:检测 profile 插件文件变化,等所有会话空闲且最近活动安静后,由脱离进程树的守护者先杀主进程再拉起(可最大化窗口),带冷却、试运行、日志和左侧「自动重启」面板。",
6
+ "description": "装/更插件后自动重启 DSH 并回到原会话:检测 profile 插件文件变化,等所有会话空闲且最近活动安静后,由脱离进程树的守护者先杀主进程再拉起(可最大化窗口),带冷却、试运行、日志和右侧原生侧边栏面板。",
7
7
  "main": "index.js",
8
8
  "exports": {
9
9
  ".": "./index.js",
@@ -34,7 +34,8 @@
34
34
  "@deepseek-ai/dsh-client-locale",
35
35
  "@deepseek-ai/dsh-client-ui-slots",
36
36
  "@deepseek-ai/dsh-client-ui-layout",
37
- "@deepseek-ai/dsh-client-ui-sidebar"
37
+ "@deepseek-ai/dsh-client-ui-sidebar",
38
+ "@deepseek-ai/dsh-client-ui-sidebar-right"
38
39
  ]
39
40
  }
40
41
  },