@leiyi-works/dsh-auto-restart 0.3.8 → 0.3.9

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/index.js +8 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -76,8 +76,8 @@ const DEFAULTS = Object.freeze({
76
76
  waitForIdle: true,
77
77
  /** 重启后是否自动给被后台任务打断的会话发一条“继续”。 */
78
78
  continueInterrupted: true,
79
- /** 会话持有运行中的 job 时,安静多久才算“在等后台任务”(可被重启打断);低于这个值按“正在干活”处理。 */
80
- jobWaitQuietMs: 180000,
79
+ /** 兜底:会话持有 job 又安静了多久也算“在等后台任务”;0 = 关闭兜底,只认当前工具是不是 job_*。 */
80
+ jobWaitQuietMs: 0,
81
81
  /** 自动继续时发送的文本。 */
82
82
  continueText: '继续',
83
83
  /** 多久以内的中断记录还值得自动继续(毫秒)。 */
@@ -682,7 +682,7 @@ function sanitizeConfig(raw) {
682
682
  cfg.enabled = bool(raw.enabled, cfg.enabled)
683
683
  cfg.dryRun = bool(raw.dryRun, cfg.dryRun)
684
684
  cfg.waitForIdle = bool(raw.waitForIdle, cfg.waitForIdle)
685
- cfg.jobWaitQuietMs = num(raw.jobWaitQuietMs, cfg.jobWaitQuietMs, 30000, 3600000)
685
+ cfg.jobWaitQuietMs = num(raw.jobWaitQuietMs, cfg.jobWaitQuietMs, 0, 3600000)
686
686
  cfg.continueInterrupted = bool(raw.continueInterrupted, cfg.continueInterrupted)
687
687
  cfg.continueWindowMs = num(raw.continueWindowMs, cfg.continueWindowMs, 60000, 86400000)
688
688
  if (typeof raw.continueText === 'string' && raw.continueText.trim() !== '') cfg.continueText = raw.continueText.slice(0, 200)
@@ -1149,10 +1149,13 @@ function tick(baseConfig) {
1149
1149
  const sessionId = String(id)
1150
1150
  const hasJobs = runningJobsFor(sessionId).length > 0
1151
1151
  const active = state.activeTools instanceof Map ? state.activeTools.get(sessionId) : undefined
1152
- const inJobTool = active !== undefined && /^job_/i.test(String(active.name))
1152
+ // Only job_output blocks on a job; job_list/job_kill/job_read return at once
1153
+ // and must not make a busy Session look interruptible.
1154
+ const inJobTool = active !== undefined && /^job_output$/i.test(String(active.name))
1153
1155
  const lastAt = state.sessionLastEventAt instanceof Map ? (state.sessionLastEventAt.get(sessionId) ?? 0) : 0
1154
1156
  const quietMs = lastAt > 0 ? now - lastAt : Number.POSITIVE_INFINITY
1155
- if (hasJobs && (inJobTool || quietMs >= cfg.jobWaitQuietMs)) jobBlocked.push(sessionId)
1157
+ const fallbackWait = cfg.jobWaitQuietMs > 0 && quietMs >= cfg.jobWaitQuietMs
1158
+ if (hasJobs && (inJobTool || fallbackWait)) jobBlocked.push(sessionId)
1156
1159
  else hardBusy.push(sessionId)
1157
1160
  }
1158
1161
  if (hardBusy.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leiyi-works/dsh-auto-restart",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "type": "module",
5
5
  "title": "自动重启",
6
6
  "description": "装/更插件后自动重启 DSH 并回到原会话:检测 profile 插件文件变化,一直等所有会话空闲且最近活动安静,由常驻后台看门狗(登录自启、不碰 WMI)或 WMI 守护先杀主进程再拉起(可最大化窗口),带冷却、试运行、日志和右侧原生侧边栏面板。",