dsh-plugin-haitang-todo 1.3.21 → 1.3.23

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/client.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * imported without changing the workbench.
15
15
  */
16
16
  window.__ModuleLoader__.load({
17
- id: 'dsh-plugin-haitang-todo',
17
+ id: '@local/sidebar-todo',
18
18
  factory(require) {
19
19
  const React = require('react');
20
20
  const h = React.createElement;
@@ -28,15 +28,14 @@ window.__ModuleLoader__.load({
28
28
  /** Document-relative base of the Host API (see index.js). */
29
29
  const API_BASE = 'api/sidebarTodo';
30
30
  /** Bump CLIENT_BUILD whenever client.js changes, so the running page is identifiable. */
31
- const CLIENT_VERSION = '1.3.18';
32
- const CLIENT_BUILD = '2026-11-25T10:32';
31
+ const CLIENT_VERSION = '1.3.39';
32
+ const CLIENT_BUILD = '2026-11-27T10:10';
33
33
  /** Debounce before a change is written to this browser and the Host. */
34
34
  const SAVE_DELAY = 700;
35
35
 
36
36
  const EN = {
37
37
  title: 'Sidebar Todo',
38
38
  label: 'Sidebar Todo',
39
- description: 'The workbench todo page, in the sidebar: period calendar, category lanes, repeat rules and completion ticks.',
40
39
  backToChat: 'Back to chat',
41
40
  sync: 'Sync workbench',
42
41
  syncing: 'Syncing…',
@@ -46,14 +45,16 @@ window.__ModuleLoader__.load({
46
45
  periodTitle: 'Period view · calendar list',
47
46
  periodHint: 'Click a day header, empty space or the add zone to create a todo',
48
47
  monthView: 'Month view',
48
+ monthDragRepeat: 'Repeating todos: change the repeat rule in the editor.',
49
49
  autoLayout: 'Auto',
50
50
  weekView: 'Week view',
51
51
  prev: 'Previous',
52
+ prevMonth: 'Previous month',
53
+ nextMonth: 'Next month',
52
54
  next: 'Next',
53
55
  reset: 'Today',
54
56
  resetMonth: 'This month',
55
57
  addZone: 'Click to add a todo',
56
- periodNote: 'Unfinished todos stay on their date and also appear on the next day; set repeats in the editor.',
57
58
  categoryTitle: 'Category view',
58
59
  categoryHint: 'Periodic and temporary work merge into this week, grouped by category',
59
60
  weekNumber: 'Week ',
@@ -97,8 +98,6 @@ window.__ModuleLoader__.load({
97
98
  saved: 'Saved',
98
99
  savingLabel: 'Saving…',
99
100
  hostError: 'Writing the local file failed; the changes stay in this browser for now.',
100
- mergedNotice: 'Newer data from another writer was merged automatically; refresh to see the latest.',
101
- mergedConflicts: 'conflicts:',
102
101
  storageBlocked: 'This browser blocked local storage; changes last only until the page closes.',
103
102
  syncOk: 'Imported workbench todos',
104
103
  syncNone: 'No workbench todo data found.',
@@ -130,18 +129,6 @@ window.__ModuleLoader__.load({
130
129
  meetingBatchSaved: 'Saved {n} meeting transcript(s)',
131
130
  meetingBatchFailed: 'Failed {m}',
132
131
  meetingNoSourceDate: 'no source date found; saving under today',
133
- maintenanceEntry: 'Maintenance: .bin → text',
134
- maintenanceTitle: 'Host copy: .bin/.txt → .md/.json/.txt/.log',
135
- maintenanceSrc: 'Source path (.bin/.txt under D:\\dsh)',
136
- maintenanceDest: 'Target path (.md/.json/.txt/.log/.bin under D:\\dsh)',
137
- maintenanceKeepHint: 'The source file is never modified, moved or deleted.',
138
- maintenanceSrcKept: 'Source kept: {path}',
139
- maintenanceDestDone: 'Target: {path}',
140
- maintenanceOverwrite: 'Overwrite if the target exists',
141
- maintenanceRun: 'Convert',
142
- maintenanceRunning: 'Converting…',
143
- maintenanceOk: 'Converted: {bytes} bytes, sha256={sha256}',
144
- maintenanceFailed: 'Convert failed',
145
132
  imported: 'Imported',
146
133
  catPeriodic: 'Periodic work',
147
134
  catMonthly: 'Monthly goals',
@@ -191,7 +178,6 @@ window.__ModuleLoader__.load({
191
178
  const ZH = {
192
179
  title: '侧栏待办',
193
180
  label: '侧栏待办',
194
- description: '工作台待办事项的侧栏版:周期日历清单、象限视图、重复规则与完成打勾,数据可自动保存并从工作台同步。',
195
181
  backToChat: '回到对话',
196
182
  sync: '同步工作台',
197
183
  syncing: '同步中…',
@@ -201,14 +187,16 @@ window.__ModuleLoader__.load({
201
187
  periodTitle: '周期视图 · 日历清单',
202
188
  periodHint: '单击日期标题栏、日期空白区域或添加按钮即可新增',
203
189
  monthView: '月度视图',
190
+ monthDragRepeat: '周期任务请在编辑里改重复规则',
204
191
  autoLayout: '自适应',
205
192
  weekView: '返回周视图',
206
193
  prev: '上一周',
194
+ prevMonth: '上一月',
195
+ nextMonth: '下一月',
207
196
  next: '下一周',
208
197
  reset: '回到今天',
209
198
  resetMonth: '回到本月',
210
199
  addZone: '单击添加待办',
211
- periodNote: '未完成待办保留在原日期,并顺延显示在下一天;重复规则在待办编辑时设置。',
212
200
  categoryTitle: '象限视图',
213
201
  categoryHint: '周期性工作和临时性工作合并为本周周工作,按分类内容展示',
214
202
  weekNumber: '第',
@@ -252,8 +240,6 @@ window.__ModuleLoader__.load({
252
240
  saved: '已保存',
253
241
  savingLabel: '保存中…',
254
242
  hostError: '本地文件写入失败,内容暂时只保存在浏览器里。',
255
- mergedNotice: '已自动合并其他入口写入的新数据,刷新面板后可看到最新内容',
256
- mergedConflicts: '冲突条目',
257
243
  storageBlocked: '浏览器拒绝了本地存储,内容只在关闭页面之前有效。',
258
244
  syncOk: '已导入工作台待办',
259
245
  syncNone: '没找到工作台待办数据。',
@@ -285,18 +271,6 @@ window.__ModuleLoader__.load({
285
271
  meetingBatchSaved: '已保存 {n} 个会议纪要',
286
272
  meetingBatchFailed: '失败 {m} 个',
287
273
  meetingNoSourceDate: '未识别到源日期,按今天保存',
288
- maintenanceEntry: '维护:.bin → 文本',
289
- maintenanceTitle: '维护:把 .bin/.txt 转成 Host 可读文本',
290
- maintenanceSrc: '源路径(D:\\dsh 下的 .bin/.txt)',
291
- maintenanceDest: '目标路径(D:\\dsh 下的 .md/.json/.txt/.log 或 .bin)',
292
- maintenanceKeepHint: '转换不会修改、移动或删除源文件。',
293
- maintenanceSrcKept: '原文件已保留:{path}',
294
- maintenanceDestDone: '目标文件:{path}',
295
- maintenanceOverwrite: '目标已存在时覆盖',
296
- maintenanceRun: '转换',
297
- maintenanceRunning: '转换中…',
298
- maintenanceOk: '已转换:{bytes} 字节,sha256={sha256}',
299
- maintenanceFailed: '转换失败',
300
274
  imported: '已导入',
301
275
  catPeriodic: '周期性工作',
302
276
  catMonthly: '月目标',
@@ -384,27 +358,30 @@ window.__ModuleLoader__.load({
384
358
  '.dsh-todo-days{display:grid;grid-template-columns:repeat(7,minmax(102px,1fr));min-width:714px}',
385
359
  '.dsh-todo-day{border-right:1px solid var(--dsw-alias-border-l1);min-height:270px;cursor:pointer;display:flex;flex-direction:column}',
386
360
  '.dsh-todo-day:last-child{border-right:0}',
387
- '.dsh-todo-day--today{background:var(--dsw-alias-bg-layer-2);box-shadow:inset 0 0 0 2px var(--dsw-alias-brand-primary)}',
388
- '.dsh-todo-day-head{padding:9px 9px;border-bottom:1px solid var(--dsw-alias-border-l1);font-size:11px;',
361
+ '.dsh-todo-day--today{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-state-success-primary);border-radius:6px}',
362
+ '.dsh-todo-day-head{display:flex;align-items:flex-start;gap:5px;padding:9px 9px;border-bottom:1px solid var(--dsw-alias-border-l1);font-size:11px;',
389
363
  'color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2)}',
390
364
  '.dsh-todo-day--today .dsh-todo-day-head{color:var(--dsw-alias-brand-primary)}',
391
- '.dsh-todo-day-head b{display:block;font-size:17px;color:var(--dsw-alias-label-primary)}',
365
+ '.dsh-todo-day-head b{display:inline;font-size:17px;color:var(--dsw-alias-label-primary)}',
392
366
  '.dsh-todo-day--today .dsh-todo-day-head b{color:var(--dsw-alias-brand-primary)}',
393
- '.dsh-todo-task-list{flex:1 1 auto;padding:8px;display:flex;flex-direction:column;gap:7px;min-height:0;cursor:pointer;overflow:auto}',
367
+ '.dsh-todo-task-list{flex:1 1 auto;padding:8px;display:flex;flex-direction:column;gap:7px;min-height:0;cursor:pointer}',
394
368
  '.dsh-todo-task{border:1px solid var(--dsw-alias-border-l1);border-left:3px solid var(--dsw-alias-brand-primary);',
395
369
  'border-radius:7px;background:var(--dsw-alias-bg-base);padding:7px 8px;font-size:11px;line-height:1.45;cursor:pointer}',
396
370
  '.dsh-todo-task:hover{background:var(--dsw-alias-bg-layer-2)}',
397
371
  '.dsh-todo-task{cursor:grab}',
398
372
  '.dsh-todo-task--dragging{opacity:.45;cursor:grabbing}',
399
373
  '.dsh-todo-day--drop{background:var(--dsw-alias-bg-layer-2);box-shadow:inset 0 0 0 2px var(--dsw-alias-brand-primary)}',
400
- '.dsh-todo-period-panel{display:flex;flex-direction:column;height:calc(100vh - 200px);height:calc(100dvh - 200px);min-height:420px;overflow:hidden}',
401
- '.dsh-todo-period-body{flex:1 1 auto;min-height:0;overflow:auto}',
402
- '.dsh-todo-weeks{display:flex;flex-direction:column;height:100%;min-height:0}',
403
- '.dsh-todo-weeks .dsh-todo-week{flex:1 1 50%;display:flex;flex-direction:column;min-height:0}',
404
- '.dsh-todo-weeks .dsh-todo-days{flex:1 1 auto;min-height:0}',
405
- '.dsh-todo-period-panel .dsh-todo-day{min-height:0;overflow:hidden}',
406
- '.dsh-todo-period-panel .dsh-todo-month{height:100%;overflow:auto}',
407
- '.dsh-todo-period-panel .dsh-todo-month-grid>div{min-height:clamp(64px,calc((100dvh - 330px)/6),150px)}',
374
+ '.dsh-todo-period-panel{display:flex;flex-direction:column;flex:0 0 auto;min-height:0;overflow:visible}',
375
+ '.dsh-todo-period-body{flex:1 1 auto;min-height:0;overflow:visible}',
376
+ '.dsh-todo-weeks{display:flex;flex-direction:column;min-height:0;gap:13px}',
377
+ '.dsh-todo-weeks .dsh-todo-week{flex:0 0 auto;display:flex;flex-direction:row;min-height:140px}',
378
+ '.dsh-todo-week-main{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}',
379
+ '.dsh-todo-week>.dsh-todo-weeknum{flex:0 0 28px;width:28px;min-height:0!important}',
380
+ '.dsh-todo-weeks .dsh-todo-days{flex:0 0 auto;min-height:0;overflow:visible}',
381
+ '.dsh-todo-period-panel .dsh-todo-day{min-height:0;overflow:visible;box-sizing:border-box}',
382
+ '.dsh-todo-period-panel .dsh-todo-month{display:flex;flex-direction:column;min-height:0;overflow:visible;box-sizing:border-box}',
383
+ '.dsh-todo-period-panel .dsh-todo-month-grid{flex:0 0 auto;min-height:0;grid-template-rows:auto;grid-auto-rows:minmax(84px,auto);overflow:visible}',
384
+ '.dsh-todo-period-panel .dsh-todo-month-grid>div{min-height:84px;height:100%;box-sizing:border-box;overflow:visible;padding:4px 5px;align-self:stretch}',
408
385
  '.dsh-todo-task--done{opacity:.5;text-decoration:line-through}',
409
386
  '.dsh-todo-task--overdue{border-left-color:var(--dsw-alias-state-warn-primary);',
410
387
  'color:var(--dsw-alias-state-warn-primary)}',
@@ -445,15 +422,32 @@ window.__ModuleLoader__.load({
445
422
  '.dsh-todo-note{padding:10px 16px 14px;margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}',
446
423
  '.dsh-todo-month{padding:0 12px 14px}',
447
424
  '.dsh-todo-month-title{padding:10px 4px;font-size:14px;font-weight:700;color:var(--dsw-alias-label-secondary)}',
448
- '.dsh-todo-month-grid{display:grid;grid-template-columns:repeat(7,minmax(88px,1fr));min-width:640px;',
425
+ '.dsh-todo-month-grid{display:grid;grid-template-columns:28px repeat(7,minmax(88px,1fr));min-width:668px;',
449
426
  'border-top:1px solid var(--dsw-alias-border-l1);border-left:1px solid var(--dsw-alias-border-l1)}',
450
427
  '.dsh-todo-month-grid>div{min-height:84px;padding:6px;border-right:1px solid var(--dsw-alias-border-l1);',
451
428
  'border-bottom:1px solid var(--dsw-alias-border-l1)}',
429
+ '.dsh-todo-month-weeknum{min-height:84px!important;display:flex;align-items:center;justify-content:center;',
430
+ 'padding-top:0;text-align:center;box-sizing:border-box;font-size:10px;font-weight:600;color:var(--dsw-alias-label-secondary);',
431
+ 'background:var(--dsw-alias-bg-layer-2);border-right:1px solid var(--dsw-alias-border-l1);border-bottom:1px solid var(--dsw-alias-border-l1)}',
452
432
  '.dsh-todo-month-weekday{min-height:0!important;text-align:center;font-size:11px;font-weight:700;',
453
433
  'background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary)}',
454
- '.dsh-todo-month-cell--today{background:var(--dsw-alias-bg-layer-2);box-shadow:inset 0 0 0 2px var(--dsw-alias-brand-primary)}',
455
- '.dsh-todo-month-task{display:block;margin-top:5px;padding:3px 5px;border-left:2px solid var(--dsw-alias-brand-primary);',
456
- 'border-radius:4px;background:var(--dsw-alias-bg-layer-2);font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
434
+ '.dsh-todo-month-head{align-items:flex-start}',
435
+ '.dsh-todo-month-head .dsh-todo-month-head-title{margin:0;font-size:15px;line-height:24px}',
436
+ '.dsh-todo-month-cell--today{background:var(--dsw-alias-bg-layer-2);border-radius:6px;outline:1px solid var(--dsw-alias-state-success-primary);outline-offset:-1px;position:relative;z-index:2}',
437
+ '.dsh-todo-month-task{display:flex;align-items:center;gap:4px;margin-top:5px;padding:2px 4px;border-left:2px solid var(--dsw-alias-brand-primary);',
438
+ 'border-radius:4px;background:var(--dsw-alias-bg-layer-2);font-size:10px;cursor:pointer}',
439
+ '.dsh-todo-month-task-text{flex:1 1 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
440
+ '.dsh-todo-month-task--done .dsh-todo-month-task-text{text-decoration:line-through;opacity:.62}',
441
+ '.dsh-todo-month-task-del{flex:none;display:none;border:0;background:transparent;color:var(--dsw-alias-state-error-primary);cursor:pointer;font-size:11px;line-height:1;padding:0 2px}',
442
+ '.dsh-todo-month-task:hover .dsh-todo-month-task-del,.dsh-todo-month-task:focus-within .dsh-todo-month-task-del{display:inline-block}',
443
+ '.dsh-todo-month-task--done{opacity:.85}',
444
+ '.dsh-todo-month-task--overdue{border-left-color:var(--dsw-alias-state-warn-primary);background:rgba(245,158,11,.16)}',
445
+ '.dsh-todo-month-task--today{border-left-color:var(--dsw-alias-state-success-primary)}',
446
+ '.dsh-todo-month-task--temporary{border-left-style:dashed}',
447
+ '.dsh-todo-month-cell--drop{box-shadow:inset 0 0 0 2px var(--dsw-alias-brand-primary);background:var(--dsw-alias-bg-layer-2)}',
448
+ '.dsh-todo-month-task{cursor:grab}',
449
+ '.dsh-todo-month-task--done{cursor:not-allowed}',
450
+ '.dsh-todo-month-task--dragging{opacity:.45}',
457
451
  '.dsh-todo-categories{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;padding:16px}',
458
452
  '.dsh-todo-lane{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;overflow:hidden;background:var(--dsw-alias-bg-base)}',
459
453
  '.dsh-todo-lane--fullscreen{position:fixed;inset:18px;z-index:30;overflow:auto;box-shadow:0 20px 60px #0006}',
@@ -823,7 +817,15 @@ window.__ModuleLoader__.load({
823
817
  if (!record.id) record.id = 1;
824
818
  }
825
819
  }
826
- return { tasks, projects, importedAt: typeof raw.importedAt === 'string' ? raw.importedAt : '' };
820
+ let ui = null;
821
+ if (raw.ui && typeof raw.ui === 'object') {
822
+ const tab = raw.ui.tab === 'category' ? 'category' : raw.ui.tab === 'period' ? 'period' : '';
823
+ const periodMode = raw.ui.periodMode === 'month' ? 'month' : raw.ui.periodMode === 'week' ? 'week' : '';
824
+ if (tab || periodMode) ui = { tab: tab || 'period', periodMode: periodMode || 'week' };
825
+ }
826
+ const normalized = { tasks, projects, importedAt: typeof raw.importedAt === 'string' ? raw.importedAt : '' };
827
+ if (ui) normalized.ui = ui;
828
+ return normalized;
827
829
  }
828
830
 
829
831
  function readLocalDocument() {
@@ -1051,7 +1053,6 @@ window.__ModuleLoader__.load({
1051
1053
  storageBlocked: false,
1052
1054
  syncing: false,
1053
1055
  baseRev: '',
1054
- mergeNotice: '',
1055
1056
  nextTaskId: 1,
1056
1057
  nextProjectId: 1,
1057
1058
  nextRecordId: 1,
@@ -1075,7 +1076,14 @@ window.__ModuleLoader__.load({
1075
1076
  };
1076
1077
 
1077
1078
  // ----- persistence ---------------------------------------------------
1078
- const documentOf = () => ({ version: 1, tasks: model.tasks, projects: model.projects, importedAt: model.importedAt || '', updatedAt: new Date().toISOString() });
1079
+ const documentOf = () => ({
1080
+ version: 1,
1081
+ tasks: model.tasks,
1082
+ projects: model.projects,
1083
+ importedAt: model.importedAt || '',
1084
+ ui: { tab: model.mainView === 'category' ? 'category' : 'period', periodMode: model.showMonth ? 'month' : 'week' },
1085
+ updatedAt: new Date().toISOString(),
1086
+ });
1079
1087
 
1080
1088
  model.recount = () => {
1081
1089
  let maxTask = 0;
@@ -1105,10 +1113,14 @@ window.__ModuleLoader__.load({
1105
1113
  if (data && typeof data.version === 'string') model.hostVersion = data.version;
1106
1114
  if (data && data.merged) {
1107
1115
  const conflicts = Array.isArray(data.conflicts) ? data.conflicts : [];
1108
- model.mergeNotice = tr('mergedNotice') + (conflicts.length > 0 ? ' · ' + tr('mergedConflicts') + ' ' + conflicts.length : '');
1116
+ // Merge logic stays; the notice is no longer surfaced in the UI.
1117
+ try {
1118
+ console.debug('[sidebar-todo] merged from another writer', conflicts);
1119
+ } catch (error) {
1120
+ /* console may be unavailable */
1121
+ }
1109
1122
  const normalized = data.document ? normalizeDocument(data.document) : null;
1110
1123
  if (normalized) model.adopt(normalized);
1111
- model.showToast(model.mergeNotice);
1112
1124
  }
1113
1125
  model.bump();
1114
1126
  })
@@ -1146,6 +1158,16 @@ window.__ModuleLoader__.load({
1146
1158
  model.tasks = document.tasks;
1147
1159
  model.projects = document.projects;
1148
1160
  model.importedAt = document.importedAt || '';
1161
+ if (document.ui && typeof document.ui === 'object') {
1162
+ model.mainView = document.ui.tab === 'category' ? 'category' : 'period';
1163
+ model.showMonth = document.ui.periodMode === 'month';
1164
+ model.manualView = true;
1165
+ } else {
1166
+ // Old documents without ui preferences: fall back to period view + week view.
1167
+ model.mainView = 'period';
1168
+ model.showMonth = false;
1169
+ model.manualView = true;
1170
+ }
1149
1171
  model.recount();
1150
1172
  model.bump();
1151
1173
  };
@@ -1409,7 +1431,7 @@ window.__ModuleLoader__.load({
1409
1431
 
1410
1432
  model.currentWeekNumber = () => weekNumber(monday());
1411
1433
  model.monthViewDate = () => new Date(today().getFullYear(), today().getMonth() + model.monthOffset, 1);
1412
- model.monthTitle = () => model.monthViewDate().getFullYear() + '年' + (model.monthViewDate().getMonth() + 1) + '月 · 月度待办';
1434
+ model.monthTitle = () => model.monthViewDate().getFullYear() + '年' + (model.monthViewDate().getMonth() + 1) + '月';
1413
1435
 
1414
1436
  model.monthCells = () => {
1415
1437
  const first = model.monthViewDate();
@@ -1447,6 +1469,7 @@ window.__ModuleLoader__.load({
1447
1469
  model.manualView = false;
1448
1470
  model.updateViewport();
1449
1471
  model.bump();
1472
+ model.schedulePersist();
1450
1473
  };
1451
1474
 
1452
1475
  // ----- create / edit tasks ------------------------------------------
@@ -2458,6 +2481,7 @@ window.__ModuleLoader__.load({
2458
2481
  const [composing, setComposing] = React.useState(false);
2459
2482
  const [dropActive, setDropActive] = React.useState(false);
2460
2483
  const meetingFileInputRef = React.useRef(null);
2484
+ const periodRef = React.useRef(null);
2461
2485
  const modelRef = React.useRef(null);
2462
2486
  if (!modelRef.current) modelRef.current = createModel(tr);
2463
2487
  const model = modelRef.current;
@@ -2493,12 +2517,27 @@ window.__ModuleLoader__.load({
2493
2517
  }
2494
2518
  });
2495
2519
 
2496
- // Keep the period layout tied to the real viewport: re-pick two-week/month on resize.
2520
+ // Period layout: fill the parent box when sparse, then grow with content.
2521
+ // Day cells never scroll internally; overflow goes to the surrounding panel/page.
2497
2522
  React.useEffect(() => {
2498
- const apply = () => model.updateViewport();
2499
- apply();
2523
+ const applyLayout = () => {
2524
+ model.updateViewport();
2525
+ const panel = periodRef.current;
2526
+ if (!panel || typeof panel.getBoundingClientRect !== 'function') return;
2527
+ // Never size the panel in pixels: it must grow with its content.
2528
+ panel.style.height = '';
2529
+ panel.style.minHeight = '';
2530
+ panel.style.maxHeight = 'none';
2531
+ const body = typeof panel.querySelector === 'function' ? panel.querySelector('.dsh-todo-period-body') : null;
2532
+ if (body) body.style.overflowY = 'visible';
2533
+ };
2534
+ applyLayout();
2535
+ let frame = 0;
2536
+ if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {
2537
+ frame = window.requestAnimationFrame(applyLayout);
2538
+ }
2500
2539
  if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
2501
- const onResize = () => apply();
2540
+ const onResize = () => applyLayout();
2502
2541
  window.addEventListener('resize', onResize);
2503
2542
  return () => {
2504
2543
  try {
@@ -2506,10 +2545,11 @@ window.__ModuleLoader__.load({
2506
2545
  } catch (error) {
2507
2546
  /* ignore */
2508
2547
  }
2548
+ if (frame && typeof window.cancelAnimationFrame === 'function') window.cancelAnimationFrame(frame);
2509
2549
  };
2510
2550
  }
2511
2551
  return undefined;
2512
- }, []);
2552
+ });
2513
2553
 
2514
2554
  const backToChat = () => {
2515
2555
  try {
@@ -2713,6 +2753,7 @@ window.__ModuleLoader__.load({
2713
2753
  {
2714
2754
  key: day.key,
2715
2755
  className: dayClass,
2756
+ style: { height: 'auto', maxHeight: 'none', overflow: 'visible' },
2716
2757
  onDragOver: (event) => {
2717
2758
  if (!model.dragKey) return;
2718
2759
  event.preventDefault();
@@ -2754,8 +2795,8 @@ window.__ModuleLoader__.load({
2754
2795
  model.openEditor(day);
2755
2796
  },
2756
2797
  },
2757
- day.weekday + ' ',
2758
2798
  h('b', null, String(day.date.getDate())),
2799
+ h('span', null, day.weekday),
2759
2800
  ),
2760
2801
  h(
2761
2802
  'div',
@@ -2838,6 +2879,7 @@ window.__ModuleLoader__.load({
2838
2879
  model.manualView = true;
2839
2880
  model.showMonth = !model.showMonth;
2840
2881
  model.bump();
2882
+ model.schedulePersist();
2841
2883
  },
2842
2884
  },
2843
2885
  model.showMonth ? tr('weekView') : tr('monthView'),
@@ -2861,7 +2903,7 @@ window.__ModuleLoader__.load({
2861
2903
  className: 'dsh-todo-action',
2862
2904
  onClick: () => (model.showMonth ? model.shiftMonth(-1) : model.shiftWeek(-1)),
2863
2905
  },
2864
- tr('prev'),
2906
+ model.showMonth ? tr('prevMonth') : tr('prev'),
2865
2907
  ),
2866
2908
  h(
2867
2909
  'button',
@@ -2871,7 +2913,7 @@ window.__ModuleLoader__.load({
2871
2913
  className: 'dsh-todo-action',
2872
2914
  onClick: () => (model.showMonth ? model.shiftMonth(1) : model.shiftWeek(1)),
2873
2915
  },
2874
- tr('next'),
2916
+ model.showMonth ? tr('nextMonth') : tr('next'),
2875
2917
  ),
2876
2918
  h(
2877
2919
  'button',
@@ -2895,37 +2937,185 @@ window.__ModuleLoader__.load({
2895
2937
  weekday: WEEKDAYS[date.getDay() === 0 ? 6 : date.getDay() - 1],
2896
2938
  });
2897
2939
 
2940
+ // Month cells reuse the week-view status rules: done / overdue / today / temporary.
2941
+ const monthTaskClass = (task) => {
2942
+ let name = 'dsh-todo-month-task';
2943
+ if (model.isTaskDone(task)) {
2944
+ name += ' dsh-todo-month-task--done';
2945
+ } else {
2946
+ const tone = model.itemTone(task, false);
2947
+ if (tone === 'overdue') name += ' dsh-todo-month-task--overdue';
2948
+ else if (tone === 'today') name += ' dsh-todo-month-task--today';
2949
+ }
2950
+ if (task.category === 'temporary') name += ' dsh-todo-month-task--temporary';
2951
+ return name;
2952
+ };
2953
+
2954
+ const monthWeekNumbers = (() => {
2955
+ const cells = model.monthCells();
2956
+ const numbers = {};
2957
+ for (let start = 0; start < cells.length; start += 7) {
2958
+ const first = cells.slice(start, start + 7).find(Boolean);
2959
+ numbers[start] = first ? String(weekNumber(first)) : '';
2960
+ }
2961
+ return numbers;
2962
+ })();
2963
+
2898
2964
  const monthView = h(
2899
2965
  'div',
2900
2966
  { className: 'dsh-todo-month' },
2901
- h('div', { className: 'dsh-todo-month-title' }, model.monthTitle()),
2902
2967
  h(
2903
2968
  'div',
2904
- { className: 'dsh-todo-month-grid' },
2969
+ { className: 'dsh-todo-month-grid', style: { gridTemplateRows: 'auto', gridAutoRows: 'minmax(84px, auto)', height: 'auto', overflow: 'visible' } },
2970
+ h('div', { key: 'corner', className: 'dsh-todo-month-weekday' }),
2905
2971
  WEEKDAYS.map((name) => h('div', { key: name, className: 'dsh-todo-month-weekday' }, name)),
2906
2972
  model.monthCells().map((cell, index) => {
2907
- if (!cell) return h('div', { key: index });
2908
- const editorOpen = model.editorDay === keyOf(cell);
2909
- return h(
2973
+ const rowItems = [];
2974
+ if (index % 7 === 0) {
2975
+ rowItems.push(
2976
+ h(
2977
+ 'div',
2978
+ { key: 'week-' + index, className: 'dsh-todo-month-weeknum', title: tr('weekNumber') + (monthWeekNumbers[index] || '') },
2979
+ monthWeekNumbers[index] || '',
2980
+ ),
2981
+ );
2982
+ }
2983
+ if (!cell) {
2984
+ rowItems.push(h('div', { key: index }));
2985
+ return rowItems;
2986
+ }
2987
+ const cellKey = keyOf(cell);
2988
+ const editorOpen = model.editorDay === cellKey;
2989
+ let cellClass = model.isToday(cell) ? 'dsh-todo-month-cell--today' : '';
2990
+ if (model.dragOverKey === cellKey) cellClass += ' dsh-todo-month-cell--drop';
2991
+ const cellNode = h(
2910
2992
  'div',
2911
2993
  {
2912
2994
  key: index,
2913
- className: model.isToday(cell) ? 'dsh-todo-month-cell--today' : '',
2914
- style: { cursor: 'pointer' },
2995
+ className: cellClass,
2996
+ style: { cursor: 'pointer', height: '100%', minHeight: '84px', maxHeight: 'none', overflow: 'visible', boxSizing: 'border-box', display: 'flex', flexDirection: 'column', alignItems: 'stretch' },
2997
+ onDragOver: (event) => {
2998
+ if (!model.dragKey) return;
2999
+ event.preventDefault();
3000
+ try {
3001
+ if (event.dataTransfer) event.dataTransfer.dropEffect = 'move';
3002
+ } catch (error) {
3003
+ /* ignore */
3004
+ }
3005
+ model.dragOverDay(cellKey);
3006
+ },
3007
+ onDragLeave: (event) => {
3008
+ if (event && event.currentTarget && event.relatedTarget && event.currentTarget.contains(event.relatedTarget)) return;
3009
+ model.clearDragOver(cellKey);
3010
+ },
3011
+ onDrop: (event) => {
3012
+ if (!model.dragKey) return;
3013
+ event.preventDefault();
3014
+ let payload = '';
3015
+ try {
3016
+ payload = String((event.dataTransfer && event.dataTransfer.getData('text/plain')) || '');
3017
+ } catch (error) {
3018
+ payload = '';
3019
+ }
3020
+ const parts = payload.split('|');
3021
+ const source = model.tasks.find((task) => Number(task.id) === Number(parts[0]));
3022
+ const fromKey = parts[1] || '';
3023
+ model.endTaskDrag();
3024
+ if (!source) return;
3025
+ if (source.repeat) {
3026
+ model.showToast(tr('monthDragRepeat'));
3027
+ return;
3028
+ }
3029
+ if (fromKey === cellKey) return;
3030
+ model.moveTaskToDate({ source, occurrenceKey: fromKey || source.startDate }, cellKey);
3031
+ },
2915
3032
  onClick: editorOpen
2916
3033
  ? undefined
2917
3034
  : (event) => {
3035
+ const target = event && event.target;
3036
+ if (target && typeof target.closest === 'function' && target.closest('.dsh-todo-month-task')) return;
2918
3037
  event.stopPropagation();
2919
3038
  model.openEditor(monthDay(cell));
2920
3039
  },
2921
3040
  },
2922
3041
  h('b', null, String(cell.getDate())),
2923
- model
2924
- .tasksFor(cell)
2925
- .slice(0, editorOpen ? 0 : 2)
2926
- .map((task) => h('span', { key: task.id, className: 'dsh-todo-month-task' }, task.text)),
2927
- editorOpen ? renderTodoEditor(monthDay(cell)) : null,
3042
+ h(
3043
+ 'div',
3044
+ {
3045
+ className: 'dsh-todo-month-cell-body',
3046
+ style: {
3047
+ height: 'auto',
3048
+ flex: '1 1 auto',
3049
+ minHeight: '44px',
3050
+ marginTop: '2px',
3051
+ padding: '2px 3px',
3052
+ boxSizing: 'border-box',
3053
+ background: 'var(--dsw-alias-bg-layer-2)',
3054
+ borderRadius: '4px',
3055
+ overflow: 'visible',
3056
+ },
3057
+ },
3058
+ (editorOpen ? [] : model.tasksFor(cell)).map((task) => {
3059
+ const source = task.source || task;
3060
+ const done = model.isTaskDone(task);
3061
+ const repeating = Boolean(source.repeat);
3062
+ let taskClass = monthTaskClass(task);
3063
+ if (model.dragKey && model.dragKey === task.occurrenceKey) taskClass += ' dsh-todo-month-task--dragging';
3064
+ return h(
3065
+ 'span',
3066
+ {
3067
+ key: task.id,
3068
+ className: taskClass,
3069
+ title: task.text,
3070
+ draggable: !done,
3071
+ onDragStart: (event) => {
3072
+ if (repeating) {
3073
+ if (event && event.preventDefault) event.preventDefault();
3074
+ model.showToast(tr('monthDragRepeat'));
3075
+ return;
3076
+ }
3077
+ try {
3078
+ if (event && event.dataTransfer) {
3079
+ event.dataTransfer.setData('text/plain', String(source.id) + '|' + String(task.occurrenceKey || source.startDate));
3080
+ event.dataTransfer.effectAllowed = 'move';
3081
+ }
3082
+ } catch (error) {
3083
+ /* ignore */
3084
+ }
3085
+ model.beginTaskDrag(task);
3086
+ },
3087
+ onDragEnd: () => model.endTaskDrag(),
3088
+ onClick: (event) => {
3089
+ if (event && event.stopPropagation) event.stopPropagation();
3090
+ model.toggleTask(task);
3091
+ },
3092
+ onDoubleClick: (event) => {
3093
+ if (event && event.stopPropagation) event.stopPropagation();
3094
+ model.openTaskEditor(task);
3095
+ },
3096
+ },
3097
+ h('span', { className: 'dsh-todo-month-task-text' }, task.text + (task.category === 'temporary' ? ' · ' + tr('temporaryKind') : '')),
3098
+ h(
3099
+ 'button',
3100
+ {
3101
+ type: 'button',
3102
+ className: 'dsh-todo-month-task-del',
3103
+ title: tr('remove'),
3104
+ 'aria-label': tr('remove'),
3105
+ onClick: (event) => {
3106
+ if (event && event.stopPropagation) event.stopPropagation();
3107
+ model.deleteItem(task);
3108
+ },
3109
+ },
3110
+ '×',
3111
+ ),
3112
+ );
3113
+ }),
3114
+ editorOpen ? renderTodoEditor(monthDay(cell)) : null,
3115
+ ),
2928
3116
  );
3117
+ rowItems.push(cellNode);
3118
+ return rowItems;
2929
3119
  }),
2930
3120
  ),
2931
3121
  );
@@ -2937,23 +3127,46 @@ window.__ModuleLoader__.load({
2937
3127
  h(
2938
3128
  'div',
2939
3129
  { key: row.title, className: 'dsh-todo-week' },
2940
- h('div', { className: 'dsh-todo-week-title' }, row.title),
2941
- h('div', { className: 'dsh-todo-days' }, row.days.map(renderDay)),
3130
+ h(
3131
+ 'div',
3132
+ {
3133
+ className: 'dsh-todo-month-weeknum dsh-todo-weeknum',
3134
+ title: tr('weekNumber') + String(weekNumber(row.days[0].date)),
3135
+ },
3136
+ String(weekNumber(row.days[0].date)),
3137
+ ),
3138
+ h(
3139
+ 'div',
3140
+ { className: 'dsh-todo-week-main' },
3141
+ h('div', { className: 'dsh-todo-days' }, row.days.map(renderDay)),
3142
+ ),
2942
3143
  ),
2943
3144
  ),
2944
3145
  );
2945
3146
 
3147
+ const weekMonthTitle = (() => {
3148
+ const rows = model.weekRows();
3149
+ const first = rows[0] && rows[0].days[0];
3150
+ return first ? first.date.getFullYear() + '年' + (first.date.getMonth() + 1) + '月' : '';
3151
+ })();
3152
+
2946
3153
  const periodSection = h(
2947
3154
  'section',
2948
- { className: 'dsh-todo-panel dsh-todo-period-panel' },
2949
- h(
2950
- 'div',
2951
- { className: 'dsh-todo-section-head' },
2952
- h('div', null, h('h2', null, tr('periodTitle')), h('span', { className: 'dsh-todo-muted' }, tr('periodHint'))),
2953
- h('div', { className: 'dsh-todo-actions' }, periodActions),
2954
- ),
3155
+ { className: 'dsh-todo-panel dsh-todo-period-panel', ref: periodRef, style: { height: 'auto', maxHeight: 'none', flex: '0 0 auto', overflow: 'visible' } },
3156
+ model.showMonth
3157
+ ? h(
3158
+ 'div',
3159
+ { className: 'dsh-todo-section-head dsh-todo-month-head' },
3160
+ h('h2', { className: 'dsh-todo-month-head-title' }, model.monthTitle()),
3161
+ h('div', { className: 'dsh-todo-actions' }, periodActions),
3162
+ )
3163
+ : h(
3164
+ 'div',
3165
+ { className: 'dsh-todo-section-head' },
3166
+ h('div', null, h('h2', null, weekMonthTitle)),
3167
+ h('div', { className: 'dsh-todo-actions' }, periodActions),
3168
+ ),
2955
3169
  h('div', { className: 'dsh-todo-period-body' }, model.showMonth ? monthView : weeksView),
2956
- h('p', { className: 'dsh-todo-note' }, tr('periodNote')),
2957
3170
  );
2958
3171
 
2959
3172
  // ----- category view -----------------------------------------------
@@ -3657,75 +3870,6 @@ window.__ModuleLoader__.load({
3657
3870
  )
3658
3871
  : null;
3659
3872
 
3660
- const maintenanceModal = model.maintenanceOpen
3661
- ? h(
3662
- 'div',
3663
- { className: 'dsh-todo-modal-backdrop', onClick: (event) => { if (event.target === event.currentTarget) model.closeMaintenance(); } },
3664
- h(
3665
- 'div',
3666
- { className: 'dsh-todo-modal', role: 'dialog', 'aria-modal': true, 'aria-label': tr('maintenanceTitle') },
3667
- h(
3668
- 'div',
3669
- { className: 'dsh-todo-modal-head' },
3670
- h('h3', null, tr('maintenanceTitle')),
3671
- h('button', { type: 'button', className: 'dsh-todo-modal-close', 'aria-label': tr('cancel'), onClick: () => model.closeMaintenance() }, '×'),
3672
- ),
3673
- h('input', {
3674
- className: 'dsh-todo-field',
3675
- placeholder: tr('maintenanceSrc'),
3676
- 'aria-label': tr('maintenanceSrc'),
3677
- value: model.maintenanceSrc,
3678
- onChange: (event) => {
3679
- model.maintenanceSrc = event.target.value;
3680
- model.bump();
3681
- },
3682
- }),
3683
- h('p', { className: 'dsh-todo-muted' }, tr('maintenanceKeepHint')),
3684
- h('input', {
3685
- className: 'dsh-todo-field',
3686
- placeholder: tr('maintenanceDest'),
3687
- 'aria-label': tr('maintenanceDest'),
3688
- value: model.maintenanceDest,
3689
- onChange: (event) => {
3690
- model.maintenanceDest = event.target.value;
3691
- model.bump();
3692
- },
3693
- }),
3694
- h(
3695
- 'label',
3696
- { className: 'dsh-todo-muted' },
3697
- h('input', {
3698
- type: 'checkbox',
3699
- checked: model.maintenanceOverwrite === true,
3700
- onChange: (event) => {
3701
- model.maintenanceOverwrite = event.target.checked === true;
3702
- model.bump();
3703
- },
3704
- }),
3705
- ' ',
3706
- tr('maintenanceOverwrite'),
3707
- ),
3708
- model.maintenanceError ? h('p', { className: 'dsh-todo-warn' }, model.maintenanceError) : null,
3709
- model.maintenanceResult ? h('p', { className: 'dsh-todo-muted dsh-todo-pre' }, model.maintenanceResult) : null,
3710
- h(
3711
- 'div',
3712
- { className: 'dsh-todo-editor-actions' },
3713
- h(
3714
- 'button',
3715
- {
3716
- type: 'button',
3717
- className: 'dsh-todo-action dsh-todo-primary',
3718
- disabled: model.maintenanceBusy,
3719
- onClick: () => model.runMaintenance(),
3720
- },
3721
- model.maintenanceBusy ? tr('maintenanceRunning') : tr('maintenanceRun'),
3722
- ),
3723
- h('button', { type: 'button', className: 'dsh-todo-action', onClick: () => model.closeMaintenance() }, tr('cancel')),
3724
- ),
3725
- ),
3726
- )
3727
- : null;
3728
-
3729
3873
  const recordDeleteModal = model.recordDeleteTarget
3730
3874
  ? h(
3731
3875
  'div',
@@ -3788,7 +3932,6 @@ window.__ModuleLoader__.load({
3788
3932
  'div',
3789
3933
  null,
3790
3934
  h('h1', { className: 'dsh-todo-title' }, tr('title')),
3791
- h('p', { className: 'dsh-todo-desc' }, tr('description')),
3792
3935
  ),
3793
3936
  ),
3794
3937
  h(
@@ -3807,7 +3950,6 @@ window.__ModuleLoader__.load({
3807
3950
  h(
3808
3951
  'div',
3809
3952
  { className: 'dsh-todo-toolbar' },
3810
- h('strong', null, model.weekLabel()),
3811
3953
  h(
3812
3954
  'div',
3813
3955
  { className: 'dsh-todo-segmented' },
@@ -3819,6 +3961,7 @@ window.__ModuleLoader__.load({
3819
3961
  onClick: () => {
3820
3962
  model.mainView = 'period';
3821
3963
  model.bump();
3964
+ model.schedulePersist();
3822
3965
  },
3823
3966
  },
3824
3967
  tr('periodView'),
@@ -3831,6 +3974,7 @@ window.__ModuleLoader__.load({
3831
3974
  onClick: () => {
3832
3975
  model.mainView = 'category';
3833
3976
  model.bump();
3977
+ model.schedulePersist();
3834
3978
  },
3835
3979
  },
3836
3980
  tr('categoryView'),
@@ -3840,20 +3984,13 @@ window.__ModuleLoader__.load({
3840
3984
  ),
3841
3985
  model.mainView === 'period' ? periodSection : categorySection,
3842
3986
  model.storageBlocked ? h('p', { className: 'dsh-todo-warn' }, tr('storageBlocked')) : null,
3843
- model.mergeNotice ? h('p', { className: 'dsh-todo-warn' }, model.mergeNotice) : null,
3844
3987
  model.meetingNotice ? h('p', { className: 'dsh-todo-muted' }, model.meetingNotice) : null,
3845
- h(
3846
- 'div',
3847
- { className: 'dsh-todo-maint' },
3848
- h('button', { type: 'button', className: 'dsh-todo-maint-link', onClick: () => model.openMaintenance() }, tr('maintenanceEntry')),
3849
- ),
3850
3988
  model.hostError ? h('p', { className: 'dsh-todo-warn' }, tr('hostError')) : null,
3851
3989
  ),
3852
3990
  taskModal,
3853
3991
  projectModal,
3854
3992
  importModal,
3855
3993
  meetingModal,
3856
- maintenanceModal,
3857
3994
  recordDeleteModal,
3858
3995
  model.highlightBar
3859
3996
  ? h(
package/cordis.patch.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  - insert:
2
2
  - id: sidebar-todo
3
- name: 'dsh-plugin-haitang-todo'
3
+ name: '@local/sidebar-todo'
4
4
  config: {}
package/index.js CHANGED
@@ -19,7 +19,7 @@ import os from 'node:os'
19
19
  import path from 'node:path'
20
20
  import { createHash } from 'node:crypto'
21
21
 
22
- const PLUGIN_VERSION = '1.5.7'
22
+ const PLUGIN_VERSION = '1.5.8'
23
23
  /** Absolute registration paths of the panel API; each carries one operation. */
24
24
  const API_BASE = '/api/sidebarTodo'
25
25
  /** Panel document version, bumped when the todo shape changes. */
@@ -138,6 +138,15 @@ function sortProblemRecordsNewestFirst(list) {
138
138
  })
139
139
  }
140
140
 
141
+ /** Non-destructive UI preferences (last used view). Kept exactly as {tab, periodMode}. */
142
+ function normalizeUi(value) {
143
+ if (!isPlainObject(value)) return null
144
+ const tab = value.tab === 'category' ? 'category' : value.tab === 'period' ? 'period' : ''
145
+ const periodMode = value.periodMode === 'month' ? 'month' : value.periodMode === 'week' ? 'week' : ''
146
+ if (!tab && !periodMode) return null
147
+ return { tab: tab || 'period', periodMode: periodMode || 'week' }
148
+ }
149
+
141
150
  function normalizeDocument(value) {
142
151
  if (!isPlainObject(value)) return null
143
152
  if (!Array.isArray(value.tasks)) return null
@@ -148,13 +157,16 @@ function normalizeDocument(value) {
148
157
  if (Array.isArray(records)) project.records.problem = sortProblemRecordsNewestFirst(records)
149
158
  }
150
159
  const importedAt = typeof value.importedAt === 'string' ? value.importedAt : ''
151
- return {
160
+ const ui = normalizeUi(value.ui)
161
+ const document = {
152
162
  version: DOCUMENT_VERSION,
153
163
  tasks,
154
164
  projects,
155
165
  importedAt,
156
166
  updatedAt: Date.now(),
157
167
  }
168
+ if (ui) document.ui = ui
169
+ return document
158
170
  }
159
171
 
160
172
  let cachedDirectory = null
@@ -1179,6 +1191,10 @@ const handlers = {
1179
1191
  conflicts = result.conflicts
1180
1192
  mergedFlag = true
1181
1193
  }
1194
+ // UI preference: the panel's value wins; keep the stored one when the panel sent none.
1195
+ const ui = normalizeUi(incoming.ui) || normalizeUi(disk.ui)
1196
+ if (ui) merged.ui = ui
1197
+ else delete merged.ui
1182
1198
  const serialized = JSON.stringify(merged, null, 2)
1183
1199
  if (serialized.length > MAX_DOCUMENT_BYTES) return fail(413, '待办文档过大,已拒绝保存')
1184
1200
  const backup = await backupStateFile(directory)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-haitang-todo",
3
- "version": "1.3.21",
3
+ "version": "1.3.23",
4
4
  "type": "module",
5
5
  "description": "Haitang Todo: a todo panel in the DeepSeek Harness Web UI sidebar with tasks, projects problem logs, monthly goals and a week (period) view.",
6
6
  "license": "MIT",