feat: prioritize actionable update triage (Closes #773)
This commit is contained in:
1 parent
84302d6f1e
commit
d54f58bf36
5 files changed
+112
-9
No files matched your search
@@ -1047,7 +1047,8 @@
|
||||
onProgress: state => {
|
||||
const progress = qs('#update-triage-progress');
|
||||
progress.hidden = false;
|
||||
progress.textContent = 'Update ' + state.index + ' of ' + state.total;
|
||||
progress.textContent = 'Update ' + state.index + ' of ' + state.total +
|
||||
(state.reason ? ' · ' + state.reason : '');
|
||||
},
|
||||
onFinish: outcome => {
|
||||
notificationReader.prefetch();
|
||||
|
||||
+18
-2
@@ -44,6 +44,19 @@ function needsAttention(item) {
|
||||
return Boolean(item && (item.has_update || item.is_review || urgencyReason(item)));
|
||||
}
|
||||
|
||||
function updateActionability(item) {
|
||||
const priorityLabels = ['p0', 'priority-high', 'critical'];
|
||||
if ((item?.labels || []).some(label => priorityLabels.includes(String(label).toLowerCase()))) {
|
||||
return { priority: 0, reason: 'Critical' };
|
||||
}
|
||||
if (item?.is_review) return { priority: 1, reason: 'Review requested' };
|
||||
if (item?.is_assigned && ['Overdue', 'Due today'].includes(item?.due_label)) {
|
||||
return { priority: 2, reason: item.due_label };
|
||||
}
|
||||
if (item?.is_assigned) return { priority: 3, reason: 'Assigned to you' };
|
||||
return { priority: 4, reason: '' };
|
||||
}
|
||||
|
||||
function buildMyWork(data, now = new Date()) {
|
||||
const login = data.user?.login || '';
|
||||
const issues = (data.issues || []).map((item) => ({ ...item, kind: 'issue' }));
|
||||
@@ -82,13 +95,15 @@ function buildMyWork(data, now = new Date()) {
|
||||
const subjectKind = String(update.subject_type || '').toLowerCase().includes('pull') ? 'pull' : 'issue';
|
||||
const existing = byKey.get(subjectKind + ':' + key);
|
||||
if (existing) {
|
||||
const actionability = updateActionability(existing);
|
||||
existing.has_update = true;
|
||||
existing.needs_attention = true;
|
||||
existing.attention_reason = 'Unread update';
|
||||
existing.notification_id = update.id;
|
||||
existing.url = update.url || existing.url;
|
||||
existing.updated_at = update.updated_at || existing.updated_at;
|
||||
existing._priority = Math.min(existing._priority, 1);
|
||||
existing.update_reason = actionability.reason;
|
||||
existing._priority = actionability.priority;
|
||||
return;
|
||||
}
|
||||
if (!update.url) return;
|
||||
@@ -103,7 +118,8 @@ function buildMyWork(data, now = new Date()) {
|
||||
attention_reason: 'Unread update',
|
||||
notification_id: update.id,
|
||||
reason: 'Unread update',
|
||||
_priority: 1,
|
||||
update_reason: '',
|
||||
_priority: 4,
|
||||
};
|
||||
work.push(item);
|
||||
byKey.set(subjectKind + ':' + key, item);
|
||||
|
||||
@@ -64,7 +64,12 @@
|
||||
state.current = identity(items[index]);
|
||||
persist();
|
||||
const originalIndex = state.identities.indexOf(state.current);
|
||||
options.onProgress({ index:originalIndex + 1, total:state.identities.length });
|
||||
const progress = {
|
||||
index:originalIndex + 1,
|
||||
total:state.identities.length,
|
||||
};
|
||||
if (items[index]?.update_reason) progress.reason = String(items[index].update_reason);
|
||||
options.onProgress(progress);
|
||||
options.onOpen(items[index]);
|
||||
return true;
|
||||
}
|
||||
@@ -79,7 +84,12 @@
|
||||
state.current = identity(next);
|
||||
if (openNext) return openCurrent();
|
||||
persist();
|
||||
options.onProgress({ index:state.identities.indexOf(state.current) + 1, total:state.identities.length });
|
||||
const progress = {
|
||||
index:state.identities.indexOf(state.current) + 1,
|
||||
total:state.identities.length,
|
||||
};
|
||||
if (next?.update_reason) progress.reason = String(next.update_reason);
|
||||
options.onProgress(progress);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user