Skip to content

Commit cc19849

Browse files
author
linyuan.yang
committed
去掉 occurrence,添加一个 trigger_fire 单纯记录
1 parent 24d023e commit cc19849

27 files changed

Lines changed: 156 additions & 546 deletions

File tree

‎packages/admin/src/components/AgendaBoard.vue‎

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {
77
firstNextFire,
88
isOverdue,
99
type AgendaItem,
10-
type AgendaOccurrence,
11-
type AgendaOccurrenceStatus,
1210
type AgendaPriority,
1311
type AgendaRow,
1412
type AgendaStatus,
@@ -72,20 +70,11 @@ function statusVariant(s: AgendaStatus): 'success' | 'warning' | 'neutral' {
7270
return 'neutral'
7371
}
7472
75-
function occurrenceVariant(s: AgendaOccurrenceStatus): 'success' | 'warning' | 'danger' | 'neutral' {
76-
if (s === 'done') return 'success'
77-
if (s === 'pending') return 'warning'
78-
if (s === 'missed') return 'danger'
79-
return 'neutral'
80-
}
81-
8273
function priorityLabel(p: AgendaPriority): string { return t(`agenda.priority_${p}`) }
8374
function statusLabel(s: AgendaStatus): string { return t(`agenda.status_${s}`) }
8475
function sourceLabel(s: AgendaItem['source']): string { return t(`agenda.source_${s}`) }
85-
function checkInLabel(requiresCheckIn: AgendaItem['requiresCheckIn']): string { return t(requiresCheckIn ? 'agenda.check_in_on' : 'agenda.check_in_off') }
8676
function triggerKindLabel(trigger: AgendaTrigger): string { return t(`agenda.trigger_${trigger.kind}`) }
8777
function triggerActionLabel(trigger: AgendaTrigger): string { return t(`agenda.action_${trigger.action}`) }
88-
function occurrenceStatusLabel(o: AgendaOccurrence): string { return t(`agenda.occurrence_${o.status}`) }
8978
9079
function formatTime(ts: number | null | undefined): string {
9180
if (!ts) return t('agenda.no_time')
@@ -95,7 +84,6 @@ function formatTime(ts: number | null | undefined): string {
9584
interface EditForm {
9685
content: string
9786
priority: AgendaPriority
98-
requiresCheckIn: boolean
9987
dueAt: string
10088
}
10189
@@ -104,15 +92,13 @@ const editingRow = ref<AgendaRow | null>(null)
10492
const editForm = reactive<EditForm>({
10593
content: '',
10694
priority: 'normal',
107-
requiresCheckIn: false,
10895
dueAt: '',
10996
})
11097
11198
function openEdit(row: AgendaRow): void {
11299
editingRow.value = row
113100
editForm.content = row.item.content
114101
editForm.priority = row.item.priority
115-
editForm.requiresCheckIn = row.item.requiresCheckIn
116102
editForm.dueAt = row.item.dueAt ? tsToLocalInput(row.item.dueAt) : ''
117103
showEdit.value = true
118104
}
@@ -127,7 +113,6 @@ function submitEdit(): void {
127113
const patch: Record<string, unknown> = {
128114
content,
129115
priority: editForm.priority,
130-
requiresCheckIn: editForm.requiresCheckIn,
131116
dueAt: editForm.dueAt ? localInputToIso(editForm.dueAt) : null,
132117
}
133118
emit('update', { row, patch })
@@ -163,19 +148,13 @@ function submitTriggerEdit(): void {
163148
}
164149
165150
function rowKeyFn(row: AgendaRow): number { return row.item.id }
166-
function countOcc(row: AgendaRow, status: AgendaOccurrenceStatus): number {
167-
return row.occurrences.filter(o => o.status === status).length
168-
}
169151
function activeTriggers(row: AgendaRow): number { return row.triggers.filter(t => t.enabled).length }
170152
function sortedTriggers(triggers: AgendaTrigger[]): AgendaTrigger[] {
171153
return [...triggers].sort((a, b) => {
172154
if (a.enabled !== b.enabled) return a.enabled ? -1 : 1
173155
return b.createdAt - a.createdAt
174156
})
175157
}
176-
function sortedOccurrences(occurrences: AgendaOccurrence[]): AgendaOccurrence[] {
177-
return [...occurrences].sort((a, b) => b.scheduledAt - a.scheduledAt)
178-
}
179158
</script>
180159

181160
<template>
@@ -264,19 +243,9 @@ function sortedOccurrences(occurrences: AgendaOccurrence[]): AgendaOccurrence[]
264243
<template #meta="{ item: row }">
265244
<span v-if="showProfile" class="agenda-meta-chip mono">{{ t('agenda.profile_col') }}: {{ row.agendaId.slice(0, 8) }}</span>
266245
<span class="agenda-meta-chip">{{ t('agenda.source_col') }}: {{ sourceLabel(row.item.source) }}</span>
267-
<span v-if="row.item.requiresCheckIn" class="agenda-meta-chip">{{ t('agenda.check_in_col') }}: {{ checkInLabel(row.item.requiresCheckIn) }}</span>
268246
<span v-if="row.triggers.length" class="agenda-meta-chip blue">
269247
{{ t('agenda.triggers_col') }}: {{ activeTriggers(row) }}/{{ row.triggers.length }}
270248
</span>
271-
<span v-if="countOcc(row, 'missed')" class="agenda-meta-chip overdue" :title="t('agenda.occurrence_missed_chip_hint')">
272-
{{ t('agenda.occurrence_missed') }}: {{ countOcc(row, 'missed') }}
273-
</span>
274-
<span v-if="countOcc(row, 'pending')" class="agenda-meta-chip orange" :title="t('agenda.occurrence_chip_hint')">
275-
{{ t('agenda.occurrence_pending') }}: {{ countOcc(row, 'pending') }}
276-
</span>
277-
<span v-if="countOcc(row, 'done')" class="agenda-meta-chip" :title="t('agenda.occurrence_done_chip_hint')">
278-
{{ t('agenda.occurrence_done') }}: {{ countOcc(row, 'done') }}
279-
</span>
280249
<span v-if="row.item.dueAt" class="agenda-meta-chip" :class="{ overdue: isOverdue(row) }">
281250
{{ t('agenda.due_col') }}: {{ formatTime(row.item.dueAt) }}
282251
</span>
@@ -386,33 +355,6 @@ function sortedOccurrences(occurrences: AgendaOccurrence[]): AgendaOccurrence[]
386355
</li>
387356
</ul>
388357
</section>
389-
390-
<section v-if="row.occurrences.length" class="agenda-sub-section">
391-
<div class="agenda-sub-title">
392-
<h4>{{ t('agenda.occurrence_section') }}</h4>
393-
<span class="agenda-sub-counts">
394-
<SBadge v-if="countOcc(row, 'pending')" variant="warning" size="xs">{{ t('agenda.occurrence_pending') }} {{ countOcc(row, 'pending') }}</SBadge>
395-
<SBadge v-if="countOcc(row, 'missed')" variant="danger" size="xs">{{ t('agenda.occurrence_missed') }} {{ countOcc(row, 'missed') }}</SBadge>
396-
<SBadge v-if="countOcc(row, 'done')" variant="success" size="xs">{{ t('agenda.occurrence_done') }} {{ countOcc(row, 'done') }}</SBadge>
397-
</span>
398-
</div>
399-
<p class="agenda-sub-hint">{{ t('agenda.occurrence_hint') }}</p>
400-
<ul class="agenda-occurrence-list">
401-
<li
402-
v-for="occ in sortedOccurrences(row.occurrences)"
403-
:key="occ.id"
404-
class="agenda-occurrence-row"
405-
:class="{
406-
'agenda-occurrence-row--done': occ.status === 'done',
407-
'agenda-occurrence-row--missed': occ.status === 'missed',
408-
}"
409-
>
410-
<SBadge :variant="occurrenceVariant(occ.status)" size="xs">{{ occurrenceStatusLabel(occ) }}</SBadge>
411-
<span class="agenda-occurrence-time mono">{{ formatTime(occ.scheduledAt) }}</span>
412-
<span v-if="occ.doneAt" class="agenda-occurrence-time mono muted">→ {{ formatTime(occ.doneAt) }}</span>
413-
</li>
414-
</ul>
415-
</section>
416358
</div>
417359
</template>
418360
</SEntityList>
@@ -428,12 +370,6 @@ function sortedOccurrences(occurrences: AgendaOccurrence[]): AgendaOccurrence[]
428370
<option value="high">{{ t('agenda.priority_high') }}</option>
429371
</SSelect>
430372
</SFormItem>
431-
<SFormItem :label="t('agenda.check_in_col')" :hint="t('agenda.check_in_hint')">
432-
<label class="agenda-check-in-toggle">
433-
<input v-model="editForm.requiresCheckIn" type="checkbox" />
434-
<span>{{ t('agenda.check_in_label') }}</span>
435-
</label>
436-
</SFormItem>
437373
<SFormItem :label="t('agenda.edit_due_at')" :hint="t('agenda.edit_due_at_hint')">
438374
<div class="agenda-edit-due">
439375
<input v-model="editForm.dueAt" type="datetime-local" class="agenda-edit-datetime" />
@@ -663,8 +599,7 @@ function sortedOccurrences(occurrences: AgendaOccurrence[]): AgendaOccurrence[]
663599
padding: var(--sui-sp-3) 0;
664600
}
665601
666-
.agenda-trigger-list,
667-
.agenda-occurrence-list {
602+
.agenda-trigger-list {
668603
list-style: none;
669604
margin: 0;
670605
padding: 0;
@@ -730,47 +665,12 @@ function sortedOccurrences(occurrences: AgendaOccurrence[]): AgendaOccurrence[]
730665
}
731666
.agenda-trigger-msg { grid-column: 1 / -1; }
732667
733-
.agenda-occurrence-row {
734-
display: flex;
735-
align-items: center;
736-
gap: var(--sui-sp-2);
737-
padding: var(--sui-sp-1) var(--sui-sp-2);
738-
border-radius: var(--sui-radius-sm);
739-
font-size: var(--sui-fs-sm);
740-
}
741-
.agenda-occurrence-row--done { opacity: 0.65; }
742-
.agenda-occurrence-row--cancelled {
743-
background: var(--sui-bg-soft);
744-
color: var(--sui-fg-muted);
745-
text-decoration: line-through;
746-
}
747-
.agenda-occurrence-row--missed {
748-
background: var(--sui-danger-soft);
749-
border-left: 3px solid var(--sui-danger);
750-
padding-left: calc(var(--sui-sp-2) - 3px);
751-
}
752-
.agenda-occurrence-row--missed,
753-
.agenda-occurrence-row--missed .agenda-occurrence-time {
754-
color: var(--sui-on-danger-soft);
755-
}
756-
.agenda-occurrence-row--missed .agenda-occurrence-time.muted {
757-
color: var(--sui-on-danger-soft);
758-
opacity: 0.7;
759-
}
760-
.agenda-sub-counts {
761-
display: inline-flex;
762-
gap: var(--sui-sp-2);
763-
flex-wrap: wrap;
764-
}
765668
.agenda-sub-hint {
766669
margin: 0 0 var(--sui-sp-2);
767670
color: var(--sui-fg-muted);
768671
font-size: var(--sui-fs-xs);
769672
line-height: 1.5;
770673
}
771-
.agenda-occurrence-time { color: var(--sui-fg); }
772-
.agenda-occurrence-time.mono { font-family: var(--sui-font-mono); }
773-
.agenda-occurrence-time.muted { color: var(--sui-fg-muted); }
774674
775675
.agenda-edit-due {
776676
display: flex;

‎packages/admin/src/composables/useAgendas.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ export type AgendaPriority = 'low' | 'normal' | 'high'
88
export type AgendaSource = 'user' | 'tool' | 'sync' | 'rule'
99
export type AgendaTriggerKind = 'absolute' | 'interval' | 'cron'
1010
export type AgendaTriggerAction = 'notify' | 'notify_and_record' | 'invoke'
11-
export type AgendaOccurrenceStatus = 'pending' | 'done' | 'missed'
1211
export type AgendaStatusFilter = AgendaStatus | 'all'
1312

1413
export interface AgendaItem {
1514
id: number
1615
content: string
1716
status: AgendaStatus
1817
priority: AgendaPriority
19-
requiresCheckIn: boolean
2018
dueAt: number | null
2119
source: AgendaSource
2220
createdAt: number
@@ -40,19 +38,10 @@ export interface AgendaTrigger {
4038
createdAt: number
4139
}
4240

43-
export interface AgendaOccurrence {
44-
id: number
45-
itemId: number
46-
scheduledAt: number
47-
status: AgendaOccurrenceStatus
48-
doneAt: number | null
49-
}
50-
5141
/** 列表行:服务端 AgendaRecord + 所属模板 id。 */
5242
export interface AgendaRow {
5343
item: AgendaItem
5444
triggers: AgendaTrigger[]
55-
occurrences: AgendaOccurrence[]
5645
agendaId: string
5746
}
5847

‎packages/admin/src/i18n/en.ts‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -618,20 +618,7 @@ export default {
618618
trigger_disabled: 'Disabled',
619619
trigger_disabled_hint: 'When the schedule changes, old triggers are disabled rather than deleted — fireCount/lastFiredAt are kept for audit.',
620620
overdue: 'Overdue',
621-
check_in_col: 'Check-in',
622-
check_in_on: 'Per-fire check-in',
623-
check_in_off: 'Off',
624-
check_in_label: 'Per-fire check-in routine',
625-
check_in_hint: 'When on, each fire creates an occurrence the user closes individually (e.g. daily water / weekly report).',
626621
done_at: 'Done At',
627-
occurrence_section: 'Occurrences',
628-
occurrence_pending: 'To complete',
629-
occurrence_done: 'Completed',
630-
occurrence_missed: 'Missed',
631-
occurrence_hint: 'Only for "per-occurrence" completion mode: every fire creates an instance the user must check off individually. An instance still pending when the next fire arrives is auto-marked missed.',
632-
occurrence_chip_hint: 'Instances waiting for the user to confirm',
633-
occurrence_missed_chip_hint: 'Instances auto-marked missed because the next fire arrived before confirmation',
634-
occurrence_done_chip_hint: 'Instances the user has confirmed',
635622
edit: 'Edit',
636623
edit_title: 'Edit item #{id}',
637624
edit_content: 'Content',

‎packages/admin/src/i18n/zh.ts‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -618,20 +618,7 @@ export default {
618618
trigger_disabled: '已停用',
619619
trigger_disabled_hint: '调度变更时旧触发器会被停用而非删除,保留 fireCount/lastFiredAt 等历史数据用于审计。',
620620
overdue: '已逾期',
621-
check_in_col: '打卡',
622-
check_in_on: '逐次打卡',
623-
check_in_off: '关闭',
624-
check_in_label: '逐次打卡型(每次触发生成一条打卡实例)',
625-
check_in_hint: '开启后,每次触发都会生成一条打卡实例,由用户逐条完成(如每日喝水 / 每周交周报)。',
626621
done_at: '完成时间',
627-
occurrence_section: '完成实例',
628-
occurrence_pending: '待完成',
629-
occurrence_done: '已完成',
630-
occurrence_missed: '已错过',
631-
occurrence_hint: '仅"逐次完成"模式:每次触发生成一条实例,需独立标记完成;下次触发到来前未完成会自动转为"已错过"。',
632-
occurrence_chip_hint: '已生成、等待用户确认完成的实例数',
633-
occurrence_missed_chip_hint: '触发后未在下次触发前确认完成、被自动标记错过的实例数',
634-
occurrence_done_chip_hint: '已确认完成的实例数',
635622
edit: '编辑',
636623
edit_title: '编辑事项 #{id}',
637624
edit_content: '内容',

‎packages/docs-site/guide/agenda.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ An agenda **item** has a content, category, priority, optional due date, and a c
1616
| `interval` | Milliseconds between fires | `86400000` (every 24h) |
1717
| `cron` | 6-field cron (`sec min hour day month weekday`) | `0 0 9 * * 1-5` (9am weekdays) |
1818

19-
When a trigger fires it delivers its `message` (falling back to the item content) to the bound session/channel using its `action` mode. Recurring triggers can track per-fire **occurrences** (pending → done / missed); one-shot `absolute` triggers retry briefly on delivery failure, then give up.
19+
When a trigger fires it delivers its `message` to the bound session/channel using its `action` mode, and the fire is recorded in the `trigger_fire` log table (pure audit, not used for scheduling). One-shot `absolute` triggers retry briefly on delivery failure, then give up.
2020

2121
## Configuration
2222

@@ -44,7 +44,7 @@ Once enabled, the agent gets these tools:
4444
| `agenda_complete` | Mark an item done |
4545
| `agenda_cancel` | Cancel an item |
4646
| `agenda_trigger` | Fire / manage a trigger |
47-
| `agenda_wiki` | In-tool reference for edge cases (occurrences, multi-trigger, action choice) |
47+
| `agenda_wiki` | In-tool reference for edge cases (multi-trigger, dueAt vs trigger, action choice) |
4848

4949
## Agenda vs Heartbeat vs Scheduler
5050

‎packages/docs-site/zh/guide/agenda.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Agenda 是 sbot 的有状态提醒 / 日程系统。每个日程**条目**(待
1616
| `interval` | 两次触发间隔的毫秒数 | `86400000`(每 24 小时) |
1717
| `cron` | 6 字段 cron(`秒 分 时 日 月 周`) | `0 0 9 * * 1-5`(工作日 9 点) |
1818

19-
触发时把 `message`(缺省回退到条目内容)按其 `action` 模式投递到绑定的会话 / 渠道。周期触发器可追踪每次的**发生记录(occurrence)**(pending → done / missed);一次性 `absolute` 触发器投递失败会短暂重试,超期则放弃。
19+
触发时把 `message` 按其 `action` 模式投递到绑定的会话 / 渠道,并在 `trigger_fire` 日志表里记一行(纯审计,不参与调度)。一次性 `absolute` 触发器投递失败会短暂重试,超期则放弃。
2020

2121
## 配置项
2222

@@ -44,7 +44,7 @@ Agenda 是 sbot 的有状态提醒 / 日程系统。每个日程**条目**(待
4444
| `agenda_complete` | 标记条目完成 |
4545
| `agenda_cancel` | 取消条目 |
4646
| `agenda_trigger` | 触发 / 管理触发器 |
47-
| `agenda_wiki` | 边界场景的工具内参考(occurrence、多触发器、action 选择等) |
47+
| `agenda_wiki` | 边界场景的工具内参考(多触发器、dueAt vs 触发器、action 选择等) |
4848

4949
## Agenda vs Heartbeat vs 调度器
5050

0 commit comments

Comments
 (0)