mirror of
https://github.com/storytold/discord-github-ticket-relay.git
synced 2026-11-29 09:33:58 +01:00
Bot features: a known-issues board in Discord, kept up to date with the most-reported problems and their status (looking into it, being worked on, fix coming, fixed in a release), with pins, hides, titles and notes per issue
This commit is contained in:
1 parent
78480d467f
commit
877400a988
20 files changed
+1256
-16
No files matched your search
@@ -44,6 +44,7 @@ and filed by a GitHub App. Reporters never need a GitHub account.
|
||||
- It runs in its own worker with a monthly limit and keeps GitHub API headroom for filing, so filing never depends on it.
|
||||
- If Claude stops (out of credits, a rejected key, the monthly limit), every page shows an alert until it's fixed. Out of credits, it checks again every 5 minutes and carries on by itself.
|
||||
- **Announcements (optional):** each app's new GitHub releases posted in a Discord channel. Claude rewrites the release notes for the people using the app (or they're posted as written on GitHub), and you can edit them before they go out. Review first keeps new releases waiting under Posts until someone posts them; Automatic posts them as soon as the notes are written. The message, its title and text are templates. The buttons under it are your own: each has a label and a link, which can be any web address, the release on GitHub, or one of the release's files found by name (`{file:*-windows-x64.msi}`), for every app or one; a release without that file just doesn't get the button, and Settings shows what each link finds in the latest release. The release notes button can be renamed or turned off. Pre-releases are left out unless you include them; each app can have its own channel. Pings are off until you choose a role (one for every app, or an app's own, or none), and a "Get update pings" message lets members give themselves the role and drop it again. Releases are checked every 5 minutes with GitHub's GraphQL API; you can also announce an older release by hand, edit or delete a post afterwards, and send a test post. Off until you turn it on; only releases published after that are announced.
|
||||
- **Bot features (optional):** extra things the bot does in your Discord, each turned on separately. First, the **known-issues board**: one message in a channel you pick, kept up to date with the problems members report most (Discord tickets, duplicates counted for their original) and what's happening with each: looking into it, being worked on (an open pull request), fixed and coming in the next update, or fixed in a release ("update to get it"). You choose the apps, the period, how many reports an issue needs, how many are shown and how long fixed ones stay; pin an issue, hide one, show it under a friendlier title or add a workaround under it; every text and status is yours to word; a button opens the ticket panel's channel. Private repositories are left out unless you include them (then without links). The message is edited in place, only when something changes.
|
||||
- **Contributor roles:** a second panel where members sign in with GitHub and get a role based on their merged PRs or commits across all your apps, e.g. Junior Contributor at 1, Contributor at 10. Merged PRs are counted from the pull requests the app keeps (read again just before each check, so one merged a moment ago counts), which works for public repositories without the Pull requests permission.
|
||||
- **Server health:** processes, memory, disk, queues, GitHub API usage and alerts, with a Dev mode so restarts while you deploy aren't counted as crashes.
|
||||
|
||||
|
||||
+12
-1
@@ -154,6 +154,16 @@ Discord endpoint, OAuth), one or more queue workers, and an optional triage work
|
||||
The "Get update pings" message (`announcement_panels`) has a button per ping role
|
||||
(`an:role:<id>`); the interaction is deferred, then the role is added or removed and the reply
|
||||
filled in. Only roles announcements ping can be given this way.
|
||||
- **Bot features › Known issues** (`src/bot-features/known-issues.ts`, off by default per
|
||||
workspace in `known_issues_settings`): the board is computed from the database alone: issues
|
||||
ranked by Discord tickets as Repo status › Most reported counts them, each one's status from the
|
||||
pull request index (`fixesFor`) and the releases the issue sync keeps (an open pull request:
|
||||
being worked on; merged and not in a release: coming; in one: fixed in it; closed with no pull
|
||||
request known: the first release after it closed). Closed as not planned is left off, fixed
|
||||
ones stay `fixed_days`, and `known_issue_overrides` holds the team's pins, hides, titles and
|
||||
notes. The posted message (`known_issue_boards`) is looked at every 10 minutes by the worker's
|
||||
index loop, and right after a change in the console, and edited only when its content (all but
|
||||
the "Updated" time) changed; deleted in Discord, it's marked so and posted again on request.
|
||||
- **No Discord gateway.** The bot is driven entirely by Discord's HTTP interactions endpoint and
|
||||
REST API. It needs no privileged intents and no slash-command registration.
|
||||
- **GitHub App auth.** Short-lived installation tokens are minted from the app's private key
|
||||
@@ -177,7 +187,7 @@ Discord endpoint, OAuth), one or more queue workers, and an optional triage work
|
||||
`triage.prompt.view`. Non-members receive 404 on workspace routes.
|
||||
- The console's tools (Analytics `/analytics`, Repo status `/repos`, Discord tickets `/tickets`,
|
||||
GitHub issues `/issues`, AI triage `/triage`, Contributor roles `/contributors`, Announcements
|
||||
`/announcements`) each have with one tab per page in `AREAS` order and a
|
||||
`/announcements`, Bot features `/bot`) each have with one tab per page in `AREAS` order and a
|
||||
shared header (`src/web/routes/tool.ts`). A tool opens on the first page the person can see;
|
||||
pages they can't open show locked. Addresses from before (`/tickets/triage…`,
|
||||
`/tickets/issues…`) redirect: 301 for GET, 307 for forms.
|
||||
@@ -257,6 +267,7 @@ stable user ID are recorded in the body.
|
||||
| `submission_events` | Append-only timeline for investigation |
|
||||
| `contributor_settings`, `contributor_panels`, `contributor_tiers` | On/off, panel channel, published panel, and role tiers (role + minimum contributions) per workspace |
|
||||
| `announcement_settings`, `announcement_apps`, `announcements`, `announcement_checks`, `announcement_panels` | Announcements: on/off, mode, channel, notes, templates and ping role; each app's on/off, channel and role; each release with its notes, status and post; when each repository was last checked; the "Get update pings" message |
|
||||
| `known_issues_settings`, `known_issue_overrides`, `known_issue_boards` | Bot features › Known issues: on/off, channel, what goes on the board and its texts; pins, hides, titles and notes per issue; the posted board and when it last changed |
|
||||
| `analytics_settings`, `download_assets`, `download_counts`, `download_days`, `download_sync`, `repo_star_changes` | Analytics: on/off; each release file and its total; downloads per 30 minutes (then per day); per repository, when recording began, the last slot read, the star count and any error; the change in the star count per 30 minutes |
|
||||
| `pull_index` | Pull requests of the indexed repositories (open, and closed for 90 days), with the issues each is for |
|
||||
| `repo_status_settings`, `repo_status` | Repo status: on/off, the repositories and how often per workspace; what was last read per repository (stats, the kept activity, the icon, the error and the GraphQL budget left) |
|
||||
|
||||
@@ -0,0 +1,495 @@
|
||||
/**
|
||||
* Bot features › Known issues: one Discord message the bot keeps up to date with the problems
|
||||
* members report most, and what's happening with each. Issues are ranked by their Discord tickets
|
||||
* (as Repo status › Most reported counts them: duplicates count for their original), and each
|
||||
* one's status comes from the pull requests about it and the releases: being worked on, fix
|
||||
* coming in the next update, fixed in a release. The team can pin an issue, hide one, show it
|
||||
* under another title or add a note (a workaround). Everything comes from the database; the
|
||||
* message is edited only when what it says changes.
|
||||
*/
|
||||
import type { Queryable } from '../db/database.js';
|
||||
import { DiscordApiError, DiscordErrorCode } from '../discord/client.js';
|
||||
import { ComponentType, escapeMarkdown, NO_MENTIONS, truncate } from '../discord/messages.js';
|
||||
import { repoReleases, releaseOf } from '../domain/pull-index.js';
|
||||
import { getDiscordConnection, listApps } from '../domain/store.js';
|
||||
import { UserFacingError, type AppRow, type Deps, type DiscordConnectionRow } from '../domain/types.js';
|
||||
import { sha256 } from '../lib/crypto.js';
|
||||
import { fixesFor } from '../repo-status/pulls.js';
|
||||
import { mostReported, periodOf, periodStart, type PeriodId } from '../repo-status/reports.js';
|
||||
|
||||
/** The board is looked at this often, and edited when what it says changed. */
|
||||
export const REFRESH_MS = 10 * 60_000;
|
||||
|
||||
export const STATUSES = ['open', 'working', 'coming', 'released', 'fixed'] as const;
|
||||
export type IssueStatus = (typeof STATUSES)[number];
|
||||
|
||||
export const STATUS_DEFAULTS: Record<IssueStatus, string> = {
|
||||
open: '🔍 Looking into it',
|
||||
working: '🛠️ Being worked on',
|
||||
coming: '📦 Fixed, coming in the next update',
|
||||
released: '✅ Fixed in {version}: update to get it',
|
||||
fixed: '✅ Fixed',
|
||||
};
|
||||
/** What each status means, for the settings page. */
|
||||
export const STATUS_NAMES: Record<IssueStatus, string> = {
|
||||
open: 'Open, nothing linked yet',
|
||||
working: 'An open pull request is working on it',
|
||||
coming: 'Fixed, not released yet',
|
||||
released: 'Fixed in a release ({version} is the release)',
|
||||
fixed: 'Closed as fixed (no release found)',
|
||||
};
|
||||
|
||||
export const TEXT_DEFAULTS = {
|
||||
title: 'Known issues',
|
||||
intro: 'Before you open a ticket, check whether your problem is already here: we know about these.',
|
||||
empty: '🎉 No known issues right now. Something wrong? Open a ticket.',
|
||||
reportButton: 'Report a problem',
|
||||
};
|
||||
export const TEXT_LIMITS = { title: 200, intro: 1000, empty: 500, status: 120, reportButton: 80, issueTitle: 200, note: 300 } as const;
|
||||
export const LIMITS = { minReports: [1, 50], maxIssues: [1, 25], fixedDays: [0, 90] } as const;
|
||||
|
||||
export interface KnownIssuesSettings {
|
||||
enabled: boolean;
|
||||
channelId: string | null;
|
||||
channelName: string | null;
|
||||
/** null: every app. */
|
||||
appIds: string[] | null;
|
||||
period: PeriodId;
|
||||
minReports: number;
|
||||
maxIssues: number;
|
||||
/** Fixed ones stay on the board this many days after they're closed (0: taken off at once). */
|
||||
fixedDays: number;
|
||||
includePrivate: boolean;
|
||||
groupByApp: boolean;
|
||||
showCounts: boolean;
|
||||
titleText: string | null;
|
||||
introText: string | null;
|
||||
emptyText: string | null;
|
||||
statusText: Partial<Record<IssueStatus, string>>;
|
||||
reportButton: boolean;
|
||||
reportButtonLabel: string | null;
|
||||
}
|
||||
|
||||
interface SettingsRow {
|
||||
enabled: boolean;
|
||||
channel_id: string | null;
|
||||
channel_name: string | null;
|
||||
app_ids: unknown;
|
||||
period: string;
|
||||
min_reports: number;
|
||||
max_issues: number;
|
||||
fixed_days: number;
|
||||
include_private: boolean;
|
||||
group_by_app: boolean;
|
||||
show_counts: boolean;
|
||||
title_text: string | null;
|
||||
intro_text: string | null;
|
||||
empty_text: string | null;
|
||||
status_text: unknown;
|
||||
report_button: boolean;
|
||||
report_button_label: string | null;
|
||||
}
|
||||
|
||||
const clamp = (n: number, [lo, hi]: readonly [number, number]) => Math.min(hi, Math.max(lo, Math.round(Number.isFinite(n) ? n : lo)));
|
||||
|
||||
export async function getKnownIssuesSettings(q: Queryable, workspaceId: string): Promise<KnownIssuesSettings> {
|
||||
const { rows } = await q.query<SettingsRow>('SELECT * FROM known_issues_settings WHERE workspace_id = $1', [workspaceId]);
|
||||
const r = rows[0];
|
||||
const status = r?.status_text && typeof r.status_text === 'object' ? (r.status_text as Record<string, unknown>) : {};
|
||||
return {
|
||||
enabled: Boolean(r?.enabled),
|
||||
channelId: r?.channel_id ?? null,
|
||||
channelName: r?.channel_name ?? null,
|
||||
appIds: Array.isArray(r?.app_ids) ? (r.app_ids as unknown[]).map(String) : null,
|
||||
period: periodOf(r?.period).id,
|
||||
minReports: clamp(r?.min_reports ?? 2, LIMITS.minReports),
|
||||
maxIssues: clamp(r?.max_issues ?? 10, LIMITS.maxIssues),
|
||||
fixedDays: clamp(r?.fixed_days ?? 14, LIMITS.fixedDays),
|
||||
includePrivate: Boolean(r?.include_private),
|
||||
groupByApp: r ? Boolean(r.group_by_app) : true,
|
||||
showCounts: r ? Boolean(r.show_counts) : true,
|
||||
titleText: r?.title_text ?? null,
|
||||
introText: r?.intro_text ?? null,
|
||||
emptyText: r?.empty_text ?? null,
|
||||
statusText: Object.fromEntries(STATUSES.filter((k) => typeof status[k] === 'string' && status[k]).map((k) => [k, String(status[k])])),
|
||||
reportButton: r ? Boolean(r.report_button) : true,
|
||||
reportButtonLabel: r?.report_button_label ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function saveKnownIssuesSettings(q: Queryable, workspaceId: string, s: KnownIssuesSettings): Promise<void> {
|
||||
await q.query(
|
||||
`INSERT INTO known_issues_settings (workspace_id, enabled, channel_id, channel_name, app_ids, period, min_reports, max_issues, fixed_days, include_private,
|
||||
group_by_app, show_counts, title_text, intro_text, empty_text, status_text, report_button, report_button_label, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, now_ms())
|
||||
ON CONFLICT (workspace_id) DO UPDATE SET enabled = excluded.enabled, channel_id = excluded.channel_id, channel_name = excluded.channel_name,
|
||||
app_ids = excluded.app_ids, period = excluded.period, min_reports = excluded.min_reports, max_issues = excluded.max_issues, fixed_days = excluded.fixed_days,
|
||||
include_private = excluded.include_private, group_by_app = excluded.group_by_app, show_counts = excluded.show_counts, title_text = excluded.title_text,
|
||||
intro_text = excluded.intro_text, empty_text = excluded.empty_text, status_text = excluded.status_text, report_button = excluded.report_button,
|
||||
report_button_label = excluded.report_button_label, updated_at = now_ms()`,
|
||||
[workspaceId, s.enabled ? 1 : 0, s.channelId, s.channelName, s.appIds ? JSON.stringify(s.appIds) : null, s.period, s.minReports, s.maxIssues, s.fixedDays,
|
||||
s.includePrivate ? 1 : 0, s.groupByApp ? 1 : 0, s.showCounts ? 1 : 0, s.titleText, s.introText, s.emptyText, JSON.stringify(s.statusText),
|
||||
s.reportButton ? 1 : 0, s.reportButtonLabel],
|
||||
);
|
||||
}
|
||||
|
||||
// ---- Single issues ----------------------------------------------------------------------------------
|
||||
|
||||
export interface IssueOverride {
|
||||
pinned: boolean;
|
||||
hidden: boolean;
|
||||
title: string | null;
|
||||
note: string | null;
|
||||
}
|
||||
|
||||
const key = (repoId: number, n: number) => `${repoId}:${n}`;
|
||||
|
||||
export async function issueOverrides(q: Queryable, workspaceId: string): Promise<Map<string, IssueOverride & { repoId: number; number: number }>> {
|
||||
const { rows } = await q.query<{ repo_id: number; number: number; pinned: boolean; hidden: boolean; title: string | null; note: string | null }>(
|
||||
'SELECT repo_id, number, pinned, hidden, title, note FROM known_issue_overrides WHERE workspace_id = $1',
|
||||
[workspaceId],
|
||||
);
|
||||
return new Map(rows.map((r) => [key(r.repo_id, r.number), { repoId: r.repo_id, number: r.number, pinned: Boolean(r.pinned), hidden: Boolean(r.hidden), title: r.title, note: r.note }]));
|
||||
}
|
||||
|
||||
/** Changes what's set for one issue (fields left out stay); nothing set at all: forgotten. */
|
||||
export async function setIssueOverride(q: Queryable, workspaceId: string, repoId: number, number: number, change: Partial<IssueOverride>): Promise<void> {
|
||||
const current = (await issueOverrides(q, workspaceId)).get(key(repoId, number)) ?? { pinned: false, hidden: false, title: null, note: null };
|
||||
const next = { ...current, ...change };
|
||||
// Pinned and hidden can't both be on: the latest wins.
|
||||
if (change.pinned) next.hidden = false;
|
||||
if (change.hidden) next.pinned = false;
|
||||
if (!next.pinned && !next.hidden && !next.title && !next.note) {
|
||||
await q.query('DELETE FROM known_issue_overrides WHERE workspace_id = $1 AND repo_id = $2 AND number = $3', [workspaceId, repoId, number]);
|
||||
return;
|
||||
}
|
||||
await q.query(
|
||||
`INSERT INTO known_issue_overrides (workspace_id, repo_id, number, pinned, hidden, title, note) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
ON CONFLICT (workspace_id, repo_id, number) DO UPDATE SET pinned = excluded.pinned, hidden = excluded.hidden, title = excluded.title, note = excluded.note, updated_at = now_ms()`,
|
||||
[workspaceId, repoId, number, next.pinned ? 1 : 0, next.hidden ? 1 : 0, next.title, next.note],
|
||||
);
|
||||
}
|
||||
|
||||
// ---- What's on the board -----------------------------------------------------------------------------
|
||||
|
||||
export interface BoardIssue {
|
||||
repoId: number;
|
||||
repo: string;
|
||||
appId: string;
|
||||
appName: string;
|
||||
number: number;
|
||||
/** As shown: the team's title, else GitHub's. */
|
||||
title: string;
|
||||
githubTitle: string;
|
||||
/** null for a private repository (no link is posted). */
|
||||
url: string | null;
|
||||
githubUrl: string;
|
||||
private: boolean;
|
||||
/** Discord tickets about it in the period. */
|
||||
reports: number;
|
||||
state: 'open' | 'closed' | null;
|
||||
status: IssueStatus;
|
||||
/** The release a fix shipped in (for "Fixed in {version}"). */
|
||||
version: string | null;
|
||||
pull: { number: number; url: string } | null;
|
||||
pinned: boolean;
|
||||
hidden: boolean;
|
||||
note: string | null;
|
||||
lastAt: Date | null;
|
||||
}
|
||||
|
||||
export interface Board {
|
||||
/** On the board, in order. */
|
||||
shown: BoardIssue[];
|
||||
/** Reported but not on it (too few reports, or past the limit), most reported first. */
|
||||
below: BoardIssue[];
|
||||
hidden: BoardIssue[];
|
||||
/** Apps whose repositories are left out because they're private. */
|
||||
privateApps: string[];
|
||||
}
|
||||
|
||||
/** The apps the board covers, one per repository (the first in order). */
|
||||
export function boardApps(s: KnownIssuesSettings, apps: AppRow[]): { apps: AppRow[]; privateApps: string[] } {
|
||||
const chosen = [...apps].sort((a, b) => a.position - b.position).filter((a) => !s.appIds || s.appIds.includes(a.id));
|
||||
const byRepo = new Map<number, AppRow>();
|
||||
const privateApps: string[] = [];
|
||||
for (const a of chosen) {
|
||||
if (a.repo_private && !s.includePrivate) {
|
||||
privateApps.push(a.name);
|
||||
continue;
|
||||
}
|
||||
if (!byRepo.has(a.repo_id)) byRepo.set(a.repo_id, a);
|
||||
}
|
||||
return { apps: [...byRepo.values()], privateApps };
|
||||
}
|
||||
|
||||
export async function computeBoard(deps: Pick<Deps, 'db' | 'box'>, workspaceId: string, s: KnownIssuesSettings, now = Date.now()): Promise<Board> {
|
||||
const { db } = deps;
|
||||
const { apps, privateApps } = boardApps(s, await listApps(db, workspaceId));
|
||||
const appOf = new Map(apps.map((a) => [a.repo_id, a]));
|
||||
const repos = apps.map((a) => ({ id: a.repo_id, owner: a.repo_owner, name: a.repo_name }));
|
||||
const reported = await mostReported(db, deps.box, workspaceId, repos, periodStart(s.period, now));
|
||||
const overrides = await issueOverrides(db, workspaceId);
|
||||
type Candidate = { repoId: number; number: number; title: string; url: string; state: 'open' | 'closed' | null; reason: string | null; closedAt: Date | null; reports: number; lastAt: Date | null };
|
||||
const candidates = new Map<string, Candidate>(reported.map((r) => [key(r.repo.id, r.number), {
|
||||
repoId: r.repo.id, number: r.number, title: r.title, url: r.url, state: r.state, reason: r.stateReason, closedAt: r.closedAt, reports: r.reports.length, lastAt: r.lastAt,
|
||||
}]));
|
||||
// Pinned issues without Discord reports in the period still go on.
|
||||
for (const o of overrides.values()) {
|
||||
if (!o.pinned || candidates.has(key(o.repoId, o.number)) || !appOf.has(o.repoId)) continue;
|
||||
const { rows } = await db.query<{ title: string; state: 'open' | 'closed'; state_reason: string | null; html_url: string; closed_at: Date | null }>(
|
||||
'SELECT title, state, state_reason, html_url, closed_at FROM issue_index WHERE repo_id = $1 AND number = $2 AND gone = 0',
|
||||
[o.repoId, o.number],
|
||||
);
|
||||
const a = appOf.get(o.repoId)!;
|
||||
const i = rows[0];
|
||||
candidates.set(key(o.repoId, o.number), {
|
||||
repoId: o.repoId, number: o.number, title: i ? i.title.replace(/^(\s*\[[^\]]*\])+\s*/, '').trim() : `Issue #${o.number}`,
|
||||
url: i?.html_url ?? `https://github.com/${a.repo_owner}/${a.repo_name}/issues/${o.number}`, state: i?.state ?? null, reason: i?.state_reason ?? null, closedAt: i?.closed_at ?? null, reports: 0, lastAt: null,
|
||||
});
|
||||
}
|
||||
|
||||
const issues: BoardIssue[] = [];
|
||||
for (const repoId of new Set([...candidates.values()].map((c) => c.repoId))) {
|
||||
const app = appOf.get(repoId);
|
||||
if (!app) continue;
|
||||
const list = [...candidates.values()].filter((c) => c.repoId === repoId);
|
||||
const [fixes, releases] = await Promise.all([fixesFor(db, repoId, list.map((c) => c.number)), repoReleases(db, repoId)]);
|
||||
for (const c of list) {
|
||||
const o = overrides.get(key(repoId, c.number));
|
||||
const fix = fixes.get(c.number);
|
||||
// Closed as not planned or a duplicate: not a known issue.
|
||||
if (c.state === 'closed' && (c.reason ?? 'completed') !== 'completed') continue;
|
||||
let status: IssueStatus = 'open';
|
||||
let version: string | null = null;
|
||||
if (c.state === 'closed') {
|
||||
// Fixed ones stay a while, so members see it's fixed and update.
|
||||
if (!o?.pinned && (!c.closedAt || now - c.closedAt.getTime() > s.fixedDays * 86_400_000)) continue;
|
||||
if (fix?.status === 'waiting') status = 'coming';
|
||||
else if (fix?.status === 'merged') [status, version] = fix.release ? ['released', fix.release.tag] : ['fixed', null];
|
||||
else {
|
||||
// No merged pull request known: the first release after it was closed (none yet: coming).
|
||||
const release = releases?.length && c.closedAt ? releaseOf(c.closedAt, releases) : undefined;
|
||||
[status, version] = release ? ['released', release.tag] : release === null ? ['coming', null] : ['fixed', null];
|
||||
}
|
||||
} else if (fix) {
|
||||
// Open: a pull request that only mentions it is work on it; a merged one that closes it is a fix.
|
||||
if (fix.status === 'open' || !fix.pull.closes.includes(c.number)) status = 'working';
|
||||
else if (fix.status === 'merged' && fix.release) [status, version] = ['released', fix.release.tag];
|
||||
else status = 'coming';
|
||||
}
|
||||
issues.push({
|
||||
repoId, repo: `${app.repo_owner}/${app.repo_name}`, appId: app.id, appName: app.name, number: c.number,
|
||||
title: o?.title?.trim() || c.title, githubTitle: c.title, url: app.repo_private ? null : c.url, githubUrl: c.url, private: app.repo_private,
|
||||
reports: c.reports, state: c.state, status, version,
|
||||
pull: fix ? { number: fix.pull.number, url: `https://github.com/${app.repo_owner}/${app.repo_name}/pull/${fix.pull.number}` } : null,
|
||||
pinned: Boolean(o?.pinned), hidden: Boolean(o?.hidden), note: o?.note ?? null, lastAt: c.lastAt,
|
||||
});
|
||||
}
|
||||
}
|
||||
const byReports = (a: BoardIssue, b: BoardIssue) => b.reports - a.reports || (b.lastAt?.getTime() ?? 0) - (a.lastAt?.getTime() ?? 0);
|
||||
const visible = issues.filter((i) => !i.hidden);
|
||||
const pinned = visible.filter((i) => i.pinned).sort(byReports);
|
||||
const ranked = visible.filter((i) => !i.pinned && i.reports >= s.minReports).sort(byReports);
|
||||
const shown = [...pinned, ...ranked].slice(0, Math.max(s.maxIssues, pinned.length));
|
||||
const on = new Set(shown.map((i) => key(i.repoId, i.number)));
|
||||
return {
|
||||
shown,
|
||||
below: visible.filter((i) => !on.has(key(i.repoId, i.number))).sort(byReports).slice(0, 15),
|
||||
hidden: issues.filter((i) => i.hidden).sort(byReports),
|
||||
privateApps,
|
||||
};
|
||||
}
|
||||
|
||||
// ---- The message ---------------------------------------------------------------------------------------
|
||||
|
||||
export function statusLine(s: Pick<KnownIssuesSettings, 'statusText'>, i: Pick<BoardIssue, 'status' | 'version'>): string {
|
||||
return (s.statusText[i.status] ?? STATUS_DEFAULTS[i.status]).replace(/\{version\}/g, i.version ?? 'the latest version');
|
||||
}
|
||||
|
||||
const safe = (t: string) => escapeMarkdown(t).replace(/\s+/g, ' ').trim();
|
||||
|
||||
/** One line per issue (and its note under it), grouped by app when that's on. */
|
||||
export function boardText(s: KnownIssuesSettings, shown: BoardIssue[]): string {
|
||||
const line = (i: BoardIssue, withApp: boolean) => {
|
||||
const title = i.url ? `[${safe(i.title)}](${i.url})` : safe(i.title);
|
||||
const parts = [`${withApp ? `**${safe(i.appName)}**: ` : ''}${title}`];
|
||||
if (s.showCounts && i.reports) parts.push(`${i.reports} report${i.reports === 1 ? '' : 's'}`);
|
||||
parts.push(statusLine(s, i));
|
||||
return `- ${parts.join(' · ')}${i.note?.trim() ? `\n ↳ ${i.note.trim().replace(/\s*\n\s*/g, ' ')}` : ''}`;
|
||||
};
|
||||
if (!s.groupByApp) return shown.map((i) => line(i, true)).join('\n');
|
||||
const apps = [...new Set(shown.map((i) => i.appId))];
|
||||
return apps.map((id) => {
|
||||
const mine = shown.filter((i) => i.appId === id);
|
||||
return `**${safe(mine[0]!.appName)}**\n${mine.map((i) => line(i, false)).join('\n')}`;
|
||||
}).join('\n\n');
|
||||
}
|
||||
|
||||
/** The ticket panel's channel, for the "Report a problem" button. */
|
||||
export function reportUrl(conn: Pick<DiscordConnectionRow, 'guild_id' | 'tickets_channel_id'> | null): string | null {
|
||||
return conn?.tickets_channel_id ? `https://discord.com/channels/${conn.guild_id}/${conn.tickets_channel_id}` : null;
|
||||
}
|
||||
|
||||
export function boardPayload(s: KnownIssuesSettings, shown: BoardIssue[], o: { reportUrl: string | null; updatedAt: Date }) {
|
||||
const list = shown.length ? boardText(s, shown) : (s.emptyText?.trim() || TEXT_DEFAULTS.empty);
|
||||
const intro = s.introText?.trim() ?? TEXT_DEFAULTS.intro;
|
||||
const description = truncate([intro, list].filter(Boolean).join('\n\n'), 4096);
|
||||
const button = s.reportButton && o.reportUrl ? [{ type: ComponentType.ActionRow, components: [{ type: ComponentType.Button, style: 5, label: truncate(s.reportButtonLabel?.trim() || TEXT_DEFAULTS.reportButton, 80), url: o.reportUrl }] }] : [];
|
||||
return {
|
||||
content: '',
|
||||
embeds: [{ title: truncate(s.titleText?.trim() || TEXT_DEFAULTS.title, 256), description, color: 0xd99a1e, footer: { text: 'Updated' }, timestamp: o.updatedAt.toISOString() }],
|
||||
components: button,
|
||||
allowed_mentions: NO_MENTIONS,
|
||||
};
|
||||
}
|
||||
|
||||
/** What the message says, leaving out when it was updated (so an unchanged board isn't edited). */
|
||||
function contentHash(payload: ReturnType<typeof boardPayload>): string {
|
||||
return sha256(JSON.stringify({ ...payload, embeds: payload.embeds.map(({ timestamp: _t, ...e }) => e) }));
|
||||
}
|
||||
|
||||
// ---- Posting and keeping it current ----------------------------------------------------------------------
|
||||
|
||||
export interface BoardRow {
|
||||
workspace_id: string;
|
||||
channel_id: string;
|
||||
message_id: string;
|
||||
content_hash: string;
|
||||
issue_count: number;
|
||||
status: 'published' | 'missing';
|
||||
published_at: Date;
|
||||
changed_at: Date;
|
||||
checked_at: Date | null;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export async function getBoardRow(q: Queryable, workspaceId: string): Promise<BoardRow | null> {
|
||||
const { rows } = await q.query<BoardRow>('SELECT * FROM known_issue_boards WHERE workspace_id = $1', [workspaceId]);
|
||||
return rows[0] ?? null;
|
||||
}
|
||||
|
||||
function explain(err: unknown): UserFacingError {
|
||||
if (err instanceof DiscordApiError) {
|
||||
if (err.code === DiscordErrorCode.MissingAccess || err.code === DiscordErrorCode.MissingPermissions) {
|
||||
return new UserFacingError('The bot is missing permissions in that channel. It needs View Channel, Send Messages, Embed Links and Read Message History.');
|
||||
}
|
||||
if (err.code === DiscordErrorCode.UnknownChannel) return new UserFacingError('That channel no longer exists. Choose another one in Settings.');
|
||||
if (err.status === 429) return new UserFacingError('Discord is rate limiting the bot. Try again in a minute.', 429);
|
||||
}
|
||||
return new UserFacingError('Discord did not accept the message. Try again in a moment.', 502);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts the board, or brings the posted one up to date (moved when the channel changed, posted
|
||||
* again when it was deleted). Edits only when what it says changed, unless `force`.
|
||||
*/
|
||||
export async function publishBoard(deps: Deps, workspaceId: string, userId: string | null, o: { force?: boolean } = {}): Promise<'created' | 'updated' | 'unchanged' | 'moved'> {
|
||||
const discord = deps.discord;
|
||||
if (!discord) throw new UserFacingError('Discord is not configured on this deployment.');
|
||||
const s = await getKnownIssuesSettings(deps.db, workspaceId);
|
||||
if (!s.channelId) throw new UserFacingError('Choose a channel for the board in Settings first.');
|
||||
const [board, conn, existing] = await Promise.all([computeBoard(deps, workspaceId, s), getDiscordConnection(deps.db, workspaceId), getBoardRow(deps.db, workspaceId)]);
|
||||
const now = new Date();
|
||||
const payload = boardPayload(s, board.shown, { reportUrl: reportUrl(conn), updatedAt: now });
|
||||
const hash = contentHash(payload);
|
||||
if (existing && existing.status === 'published' && existing.channel_id === s.channelId) {
|
||||
if (existing.content_hash === hash && !o.force) {
|
||||
await deps.db.query('UPDATE known_issue_boards SET checked_at = $2, error = NULL WHERE workspace_id = $1', [workspaceId, now]);
|
||||
return 'unchanged';
|
||||
}
|
||||
try {
|
||||
await discord.editMessage(existing.channel_id, existing.message_id, payload);
|
||||
await deps.db.query('UPDATE known_issue_boards SET content_hash = $2, issue_count = $4, changed_at = $3, checked_at = $3, error = NULL WHERE workspace_id = $1', [workspaceId, hash, now, board.shown.length]);
|
||||
return 'updated';
|
||||
} catch (err) {
|
||||
if (!(err instanceof DiscordApiError && err.code === DiscordErrorCode.UnknownMessage)) throw explain(err);
|
||||
}
|
||||
}
|
||||
let created: { id: string };
|
||||
try {
|
||||
created = await discord.createMessage(s.channelId, payload);
|
||||
} catch (err) {
|
||||
throw explain(err);
|
||||
}
|
||||
await deps.db.query(
|
||||
`INSERT INTO known_issue_boards (workspace_id, channel_id, message_id, content_hash, issue_count, status, published_by, published_at, changed_at, checked_at)
|
||||
VALUES ($1, $2, $3, $4, $7, 'published', $5, $6, $6, $6)
|
||||
ON CONFLICT (workspace_id) DO UPDATE SET channel_id = excluded.channel_id, message_id = excluded.message_id, content_hash = excluded.content_hash, issue_count = excluded.issue_count,
|
||||
status = 'published', published_by = excluded.published_by, published_at = excluded.published_at, changed_at = excluded.changed_at, checked_at = excluded.checked_at, error = NULL`,
|
||||
[workspaceId, s.channelId, created.id, hash, userId, now, board.shown.length],
|
||||
);
|
||||
if (existing && existing.channel_id !== s.channelId) {
|
||||
await discord.deleteMessage(existing.channel_id, existing.message_id).catch(() => {});
|
||||
return 'moved';
|
||||
}
|
||||
return 'created';
|
||||
}
|
||||
|
||||
export type BoardState =
|
||||
| { state: 'not_published' }
|
||||
| { state: 'missing' }
|
||||
| { state: 'published'; channelChanged: boolean; link: string | null; changedAt: Date; checkedAt: Date | null; error: string | null };
|
||||
|
||||
/** The posted board. `live: false` skips asking Discord whether it still exists. */
|
||||
export async function checkBoard(deps: Deps, workspaceId: string, conn: DiscordConnectionRow | null, o: { live: boolean } = { live: true }): Promise<BoardState> {
|
||||
const row = await getBoardRow(deps.db, workspaceId);
|
||||
if (!row) return { state: 'not_published' };
|
||||
if (row.status === 'missing') return { state: 'missing' };
|
||||
if (deps.discord && o.live) {
|
||||
try {
|
||||
await deps.discord.getMessage(row.channel_id, row.message_id);
|
||||
} catch (err) {
|
||||
if (err instanceof DiscordApiError && (err.code === DiscordErrorCode.UnknownMessage || err.code === DiscordErrorCode.UnknownChannel)) {
|
||||
await deps.db.query(`UPDATE known_issue_boards SET status = 'missing' WHERE workspace_id = $1`, [workspaceId]);
|
||||
return { state: 'missing' };
|
||||
}
|
||||
}
|
||||
}
|
||||
const s = await getKnownIssuesSettings(deps.db, workspaceId);
|
||||
return {
|
||||
state: 'published', channelChanged: s.channelId !== row.channel_id,
|
||||
link: conn ? `https://discord.com/channels/${conn.guild_id}/${row.channel_id}/${row.message_id}` : null,
|
||||
changedAt: row.changed_at, checkedAt: row.checked_at, error: row.error,
|
||||
};
|
||||
}
|
||||
|
||||
export async function unpublishBoard(deps: Deps, workspaceId: string): Promise<void> {
|
||||
const row = await getBoardRow(deps.db, workspaceId);
|
||||
if (!row) return;
|
||||
if (deps.discord) await deps.discord.deleteMessage(row.channel_id, row.message_id).catch(() => {});
|
||||
await deps.db.query('DELETE FROM known_issue_boards WHERE workspace_id = $1', [workspaceId]);
|
||||
}
|
||||
|
||||
/** After a change in the console: the posted board catches up right away (a failure waits for the next round). */
|
||||
export async function refreshBoardSoon(deps: Deps, workspaceId: string): Promise<void> {
|
||||
const [s, row] = await Promise.all([getKnownIssuesSettings(deps.db, workspaceId), getBoardRow(deps.db, workspaceId)]);
|
||||
if (!s.enabled || row?.status !== 'published' || row.channel_id !== s.channelId) return;
|
||||
await publishBoard(deps, workspaceId, null).catch((err) => deps.log.warn({ workspace: workspaceId, err: (err as Error).message }, 'known issues board update failed'));
|
||||
}
|
||||
|
||||
/** Runs in the triage worker's polling loop: each posted board is looked at every 10 minutes. */
|
||||
export class KnownIssuesUpdater {
|
||||
constructor(readonly deps: Deps) {}
|
||||
|
||||
async tick(now = Date.now()): Promise<number> {
|
||||
const { db } = this.deps;
|
||||
if (!this.deps.discord) return 0;
|
||||
const { rows } = await db.query<{ workspace_id: string }>(
|
||||
`SELECT b.workspace_id FROM known_issue_boards b JOIN known_issues_settings s ON s.workspace_id = b.workspace_id AND s.enabled = 1 AND s.channel_id = b.channel_id
|
||||
WHERE b.status = 'published' AND (b.checked_at IS NULL OR b.checked_at < $1) ORDER BY b.checked_at LIMIT 5`,
|
||||
[new Date(now - REFRESH_MS)],
|
||||
);
|
||||
let updated = 0;
|
||||
for (const r of rows) {
|
||||
try {
|
||||
if ((await publishBoard(this.deps, r.workspace_id, null)) !== 'unchanged') updated++;
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
await db.query('UPDATE known_issue_boards SET checked_at = $2, error = $3 WHERE workspace_id = $1', [r.workspace_id, new Date(now), message.slice(0, 300)]);
|
||||
this.deps.log.warn({ workspace: r.workspace_id, err: message }, 'known issues board update failed');
|
||||
}
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -24,8 +24,8 @@ export interface Queryable {
|
||||
}
|
||||
|
||||
const DATE_COLUMN = /(^|_)at$/;
|
||||
const JSON_COLUMNS = new Set(['labels', 'warnings', 'data', 'detail', 'triage_config', 'verdict', 'applied_actions', 'suggestions', 'form', 'last_run_summary', 'stats', 'auto_actions', 'before', 'scope', 'config_used', 'filter', 'access', 'auto_sources', 'auto_answers', 'auto_live', 'closes', 'team_answers', 'raw', 'repos', 'mentions', 'release_files', 'buttons']);
|
||||
const BOOLEAN_COLUMNS = new Set(['enabled', 'repo_private', 'contributor_enabled', 'auto_cleanup', 'closed_enabled', 'spam_enabled', 'age_enabled', 'apply_suggestions', 'apply_inbox_only', 'github_enabled', 'draft', 'include_prereleases', 'notes_button', 'ping_enabled', 'manual']);
|
||||
const JSON_COLUMNS = new Set(['labels', 'warnings', 'data', 'detail', 'triage_config', 'verdict', 'applied_actions', 'suggestions', 'form', 'last_run_summary', 'stats', 'auto_actions', 'before', 'scope', 'config_used', 'filter', 'access', 'auto_sources', 'auto_answers', 'auto_live', 'closes', 'team_answers', 'raw', 'repos', 'mentions', 'release_files', 'buttons', 'app_ids', 'status_text']);
|
||||
const BOOLEAN_COLUMNS = new Set(['enabled', 'repo_private', 'contributor_enabled', 'auto_cleanup', 'closed_enabled', 'spam_enabled', 'age_enabled', 'apply_suggestions', 'apply_inbox_only', 'github_enabled', 'draft', 'include_prereleases', 'notes_button', 'ping_enabled', 'manual', 'include_private', 'group_by_app', 'show_counts', 'report_button', 'pinned', 'hidden']);
|
||||
|
||||
function toParam(value: unknown): unknown {
|
||||
if (value === undefined || value === null) return null;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
-- Bot features › Known issues: one Discord message the bot keeps up to date with the problems
|
||||
-- members report most (Discord tickets, duplicates counted for their original) and what's
|
||||
-- happening with each: being worked on, fix coming, fixed in a release. Off until turned on.
|
||||
CREATE TABLE known_issues_settings (
|
||||
workspace_id TEXT PRIMARY KEY REFERENCES workspaces(id) ON DELETE CASCADE,
|
||||
enabled INTEGER NOT NULL DEFAULT 0,
|
||||
channel_id TEXT,
|
||||
channel_name TEXT,
|
||||
app_ids TEXT, -- JSON list of app ids; null: every app
|
||||
period TEXT NOT NULL DEFAULT '30d', -- reports counted over 7d, 30d, 90d or all
|
||||
min_reports INTEGER NOT NULL DEFAULT 2,
|
||||
max_issues INTEGER NOT NULL DEFAULT 10,
|
||||
fixed_days INTEGER NOT NULL DEFAULT 14, -- fixed ones stay this long (0: left off)
|
||||
include_private INTEGER NOT NULL DEFAULT 0, -- issues of private repositories (no links)
|
||||
group_by_app INTEGER NOT NULL DEFAULT 1,
|
||||
show_counts INTEGER NOT NULL DEFAULT 1,
|
||||
title_text TEXT, -- texts; null = the default
|
||||
intro_text TEXT,
|
||||
empty_text TEXT,
|
||||
status_text TEXT, -- JSON { open, working, coming, released, fixed }
|
||||
report_button INTEGER NOT NULL DEFAULT 1, -- a button to the ticket panel's channel
|
||||
report_button_label TEXT,
|
||||
updated_at INTEGER NOT NULL DEFAULT (now_ms())
|
||||
);
|
||||
|
||||
-- The team's say over single issues: always on the board, never on it, shown under another title,
|
||||
-- or with a note (a workaround) under it.
|
||||
CREATE TABLE known_issue_overrides (
|
||||
workspace_id TEXT NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
|
||||
repo_id INTEGER NOT NULL,
|
||||
number INTEGER NOT NULL,
|
||||
pinned INTEGER NOT NULL DEFAULT 0,
|
||||
hidden INTEGER NOT NULL DEFAULT 0,
|
||||
title TEXT,
|
||||
note TEXT,
|
||||
updated_at INTEGER NOT NULL DEFAULT (now_ms()),
|
||||
PRIMARY KEY (workspace_id, repo_id, number)
|
||||
);
|
||||
|
||||
-- The posted message, and when its content last changed (it's edited only then).
|
||||
CREATE TABLE known_issue_boards (
|
||||
workspace_id TEXT PRIMARY KEY REFERENCES workspaces(id) ON DELETE CASCADE,
|
||||
channel_id TEXT NOT NULL,
|
||||
message_id TEXT NOT NULL,
|
||||
content_hash TEXT NOT NULL,
|
||||
issue_count INTEGER NOT NULL DEFAULT 0, -- issues on it when it last changed
|
||||
status TEXT NOT NULL DEFAULT 'published', -- published or missing (deleted in Discord)
|
||||
published_by TEXT REFERENCES users(id) ON DELETE SET NULL,
|
||||
published_at INTEGER NOT NULL DEFAULT (now_ms()),
|
||||
changed_at INTEGER NOT NULL DEFAULT (now_ms()),
|
||||
checked_at INTEGER,
|
||||
error TEXT
|
||||
);
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Role } from './types.js';
|
||||
|
||||
/** The tools in the sidebar, in order. Each one has pages (areas) an admin can open to moderators. */
|
||||
export const TOOLS = ['analytics', 'repos', 'tickets', 'issues', 'triage', 'contributors', 'announcements', 'setup', 'workspace'] as const;
|
||||
export const TOOLS = ['analytics', 'repos', 'tickets', 'issues', 'triage', 'contributors', 'announcements', 'bot', 'setup', 'workspace'] as const;
|
||||
export type Tool = (typeof TOOLS)[number];
|
||||
export type AccessLevel = 'none' | 'view' | 'edit';
|
||||
|
||||
@@ -44,13 +44,14 @@ export const AREAS = {
|
||||
'announcements': { tool: 'announcements', name: 'Posts', desc: 'New releases and their posts in Discord. Edit: post, edit, rewrite and skip them, and announce a release by hand.', levels: ['view', 'edit'] },
|
||||
'announcement-settings': { tool: 'announcements', name: 'Settings', desc: 'On or off, review first or automatic, the channel, the notes, the message and pings.', levels: ['view', 'edit'] },
|
||||
'announcement-pings': { tool: 'announcements', name: 'Pings panel', desc: 'The “Get update pings” message in Discord. Edit: change, publish or remove it.', levels: ['view', 'edit'] },
|
||||
'known-issues': { tool: 'bot', name: 'Known issues', desc: 'The known-issues board in Discord. Edit: its settings, pinning, hiding and notes on issues, and publishing or removing it.', levels: ['view', 'edit'] },
|
||||
'apps': { tool: 'setup', name: 'Apps & repositories', desc: 'Apps and their repositories.', levels: ['view', 'edit'] },
|
||||
'health': { tool: 'workspace', name: 'Server health', desc: 'Processes, memory and alerts. Edit: Dev mode.', levels: ['view', 'edit'] },
|
||||
} as const satisfies Record<string, AreaDef>;
|
||||
export type Area = keyof typeof AREAS;
|
||||
export const AREA_KEYS = Object.keys(AREAS) as Area[];
|
||||
|
||||
export const TOOL_NAMES: Record<Tool, string> = { tickets: 'Discord tickets', issues: 'GitHub issues', repos: 'Repo status', analytics: 'Analytics', triage: 'AI triage', contributors: 'Contributor roles', announcements: 'Announcements', setup: 'Setup', workspace: 'Workspace' };
|
||||
export const TOOL_NAMES: Record<Tool, string> = { tickets: 'Discord tickets', issues: 'GitHub issues', repos: 'Repo status', analytics: 'Analytics', triage: 'AI triage', contributors: 'Contributor roles', announcements: 'Announcements', bot: 'Bot features', setup: 'Setup', workspace: 'Workspace' };
|
||||
|
||||
/** A tool's pages, in order. */
|
||||
export function areasOf(tool: Tool): Area[] {
|
||||
|
||||
@@ -24,6 +24,7 @@ import { ChangeTracker, recentChanges, type AppChange } from './knowledge-change
|
||||
import { RepoStatusTracker } from '../repo-status/tracker.js';
|
||||
import { AnalyticsRecorder } from '../analytics/recorder.js';
|
||||
import { Announcer } from '../announcements/announcer.js';
|
||||
import { KnownIssuesUpdater } from '../bot-features/known-issues.js';
|
||||
import { actionMatcher } from './state.js';
|
||||
import { buildKnowledgeBlock, buildSystemPrompt, buildUserPrompt, extractDescription, searchTerms, type Candidate } from './prompt.js';
|
||||
import { findWork, type WorkItem, type WorkRef } from './work.js';
|
||||
@@ -839,6 +840,8 @@ export class TriageEngine {
|
||||
readonly analytics: AnalyticsRecorder;
|
||||
/** Release announcements: new releases, their notes and their posts in Discord. */
|
||||
readonly announcer: Announcer;
|
||||
/** Bot features › Known issues: keeps each posted board up to date. */
|
||||
readonly knownIssues: KnownIssuesUpdater;
|
||||
|
||||
constructor(
|
||||
readonly deps: Deps,
|
||||
@@ -850,6 +853,7 @@ export class TriageEngine {
|
||||
this.repoStatus = new RepoStatusTracker(deps);
|
||||
this.analytics = new AnalyticsRecorder(deps);
|
||||
this.announcer = new Announcer(deps, ai);
|
||||
this.knownIssues = new KnownIssuesUpdater(deps);
|
||||
}
|
||||
|
||||
/** Queues newly filed tickets, and new issues opened on GitHub, where triage is on for them (only those after it was switched on). */
|
||||
|
||||
@@ -65,6 +65,12 @@ export class TriageWorker {
|
||||
} catch (err) {
|
||||
this.engine.deps.log.error({ err: (err as Error).message }, 'announcements loop error');
|
||||
}
|
||||
// Bot features › Known issues: each posted board, every 10 minutes (edited only when it changed).
|
||||
try {
|
||||
await this.engine.knownIssues.tick();
|
||||
} catch (err) {
|
||||
this.engine.deps.log.error({ err: (err as Error).message }, 'known issues loop error');
|
||||
}
|
||||
await new Promise<void>((resolve) => {
|
||||
const timer = setTimeout(resolve, this.opts.indexMs ?? 15_000);
|
||||
this.wakeIndex = () => {
|
||||
|
||||
@@ -137,6 +137,7 @@ export function layout(ctx: PageContext, opts: { title: string; active: string;
|
||||
${tool(access, 'triage', review)}
|
||||
${tool(access, 'contributors')}
|
||||
${tool(access, 'announcements')}
|
||||
${tool(access, 'bot')}
|
||||
<div class="nav-label">Workspace</div>
|
||||
${manage ? navItem(`${base}/members`, 'Members & permissions', 'users', a === 'members') : lockedNavItem('Members & permissions', 'users')}
|
||||
${manage ? navItem(`${base}/settings`, 'Settings', 'settings', a === 'settings') : lockedNavItem('Settings', 'settings')}
|
||||
|
||||
+11
-1
@@ -45,7 +45,7 @@
|
||||
--discord-bg: #313338; --discord-embed: #2b2d31; --discord-text: #dbdee1; --discord-head: #f2f3f5;
|
||||
--discord-muted: #949ba4; --discord-select: #1e1f22; --discord-blurple: #5865f2; --discord-green-btn: #248046;
|
||||
--discord-embed-green: #2e9e5b; --discord-mention-bg: rgba(88, 101, 242, 0.3); --discord-mention: #c9cdfb; --discord-on: #ffffff; --discord-red: #f23f43;
|
||||
--discord-link: #00a8fc; --discord-grey-btn: #4e5058;
|
||||
--discord-link: #00a8fc; --discord-grey-btn: #4e5058; --discord-embed-amber: #d99a1e;
|
||||
/* data colors (dots only) */
|
||||
--dot-0: #d73a4a; --dot-1: #1a9fa8; --dot-2: #8250df; --dot-3: #0e8a16; --dot-4: #d97706; --dot-5: #3498db; --dot-6: #e4609b; --dot-7: #6b7280;
|
||||
--role-0: #2ecc71; --role-1: #3498db; --role-2: #9b59b6; --role-3: #e67e22; --role-4: #e91e63; --role-5: #1abc9c;
|
||||
@@ -666,6 +666,7 @@ dl.props dd .ic { color: var(--muted); }
|
||||
.dp-tag { background: var(--discord-blurple); color: var(--discord-on); font-size: 10px; font-weight: 600; padding: 0 4px; border-radius: 3px; margin-left: 4px; vertical-align: 1px; }
|
||||
.dp-embed { margin-top: 6px; background: var(--discord-embed); border-left: 4px solid var(--discord-blurple); border-radius: 4px; padding: 10px 14px 12px; }
|
||||
.dp-embed.green { border-left-color: var(--discord-embed-green); }
|
||||
.dp-embed.amber { border-left-color: var(--discord-embed-amber); }
|
||||
.dp-embed h4 { color: var(--discord-head); font-size: 15px; line-height: 22px; margin: 0 0 4px; }
|
||||
.dp-embed p { margin: 0; font-size: 13px; line-height: 19px; }
|
||||
.dp-h { display: block; color: var(--discord-head); font-weight: 600; font-size: 14px; margin-top: 6px; }
|
||||
@@ -1896,3 +1897,12 @@ a.rs-why:hover { border-color: currentColor; }
|
||||
.ann-btn { grid-template-columns: minmax(0, 1fr) 32px; }
|
||||
.ann-btn > input[name="btn_url"], .ann-btn > .select { grid-column: 1 / 2; }
|
||||
}
|
||||
|
||||
/* ---- Bot features › Known issues --------------------------------------------------------------- */
|
||||
|
||||
.ki-views { margin: 0 0 16px; }
|
||||
.ki-meta { gap: 6px; flex-wrap: wrap; }
|
||||
.ki-table td { vertical-align: top; }
|
||||
.ki-status { font-size: 13px; line-height: 18px; color: var(--text); }
|
||||
.ki-status.ok { color: var(--ok-text); }
|
||||
.ki-status.warn { color: var(--warn-text); }
|
||||
@@ -0,0 +1,416 @@
|
||||
/**
|
||||
* Bot features: extra things the bot does in Discord, one tab each. Known issues is the first: the
|
||||
* board as it is now (what's on it, what's just below, what's hidden) with pinning, hiding and a
|
||||
* title or note per issue, its settings, and a preview of the message.
|
||||
*/
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import {
|
||||
boardApps,
|
||||
boardPayload,
|
||||
checkBoard,
|
||||
computeBoard,
|
||||
getKnownIssuesSettings,
|
||||
issueOverrides,
|
||||
LIMITS,
|
||||
publishBoard,
|
||||
refreshBoardSoon,
|
||||
reportUrl,
|
||||
saveKnownIssuesSettings,
|
||||
setIssueOverride,
|
||||
STATUS_DEFAULTS,
|
||||
STATUS_NAMES,
|
||||
STATUSES,
|
||||
statusLine,
|
||||
TEXT_DEFAULTS,
|
||||
TEXT_LIMITS,
|
||||
unpublishBoard,
|
||||
type Board,
|
||||
type BoardIssue,
|
||||
type BoardState,
|
||||
type IssueStatus,
|
||||
type KnownIssuesSettings,
|
||||
} from '../../bot-features/known-issues.js';
|
||||
import { inspectGuild, type GuildAccess } from '../../domain/discord-checks.js';
|
||||
import { can } from '../../domain/permissions.js';
|
||||
import { getDiscordConnection, listApps } from '../../domain/store.js';
|
||||
import { UserFacingError } from '../../domain/types.js';
|
||||
import { html, raw, type SafeHtml } from '../../lib/html.js';
|
||||
import { PERIODS, periodOf } from '../../repo-status/reports.js';
|
||||
import { botIdentity, botMessage, discordMd, previewCaption, type BotIdentity } from '../discord-preview.js';
|
||||
import { setFlash } from '../session.js';
|
||||
import type { Web, WorkspaceRequestContext } from '../server.js';
|
||||
import { csrfField, icon, linkBtn, menu, pageHeader, pill, plural, segLinks, selectWrap, setting, submitBtn, switchInput, tag, timeAgo, type Tone } from '../ui.js';
|
||||
import { checklist, textField } from './panel.js';
|
||||
import { areaHref, toolHeader, toolHref } from './tool.js';
|
||||
import { viewOnlyFooter } from './triage.js';
|
||||
|
||||
type Check = { status: 'ok' | 'warning' | 'error'; title: string; detail?: string; fix?: { label: string; href: string } };
|
||||
|
||||
const STATUS_TONES: Record<IssueStatus, Tone> = { open: 'neutral', working: 'warn', coming: 'ok', released: 'ok', fixed: 'ok' };
|
||||
|
||||
/** A GitHub issue link (or owner/repo#123) to the repository and number. */
|
||||
function parseIssueRef(text: string): { owner: string; name: string; number: number } | null {
|
||||
const t = text.trim();
|
||||
const m = /^https?:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/issues\/(\d+)/i.exec(t) ?? /^([\w.-]+)\/([\w.-]+)#(\d+)$/.exec(t);
|
||||
return m ? { owner: m[1]!, name: m[2]!, number: Number(m[3]) } : null;
|
||||
}
|
||||
|
||||
function boardPreview(bot: BotIdentity, s: KnownIssuesSettings, shown: BoardIssue[], report: string | null, updatedAt: Date): SafeHtml {
|
||||
const payload = boardPayload(s, shown, { reportUrl: report, updatedAt });
|
||||
const embed = payload.embeds[0]!;
|
||||
const intro = s.introText?.trim() ?? TEXT_DEFAULTS.intro;
|
||||
const rest = embed.description.slice(intro.length).replace(/^\n\n/, '');
|
||||
const button = payload.components[0]?.components[0];
|
||||
return botMessage(bot, html`<div class="dp-embed amber"><h4 id="pv-ki-title">${embed.title}</h4>
|
||||
<p><span id="pv-ki-intro">${discordMd(intro)}</span>${intro && rest ? html`<br><br>` : ''}${shown.length ? discordMd(rest) : html`<span id="pv-ki-empty">${discordMd(rest)}</span>`}</p>
|
||||
<div class="dp-time">Updated · ${updatedAt.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', timeZone: 'UTC' })} UTC</div></div>
|
||||
${button ? html`<div class="dp-buttons"><span class="dp-button grey" id="pv-ki-button">${button.label}${icon('arrow-up-right', 14)}</span></div>` : ''}`, 'Preview of the known-issues board in Discord');
|
||||
}
|
||||
|
||||
export function registerBotFeatureRoutes(app: FastifyInstance, web: Web): void {
|
||||
const { deps } = web;
|
||||
const base = (ctx: WorkspaceRequestContext) => `${ctx.base}/bot/known-issues`;
|
||||
|
||||
app.get('/w/:wid/bot', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.view' });
|
||||
if (!ctx) return reply;
|
||||
return reply.redirect(areaHref(ctx, 'known-issues'));
|
||||
});
|
||||
|
||||
function stateStrip(s: KnownIssuesSettings, state: BoardState, edit: boolean): SafeHtml {
|
||||
if (!s.enabled) return html`${pill('Off', 'neutral')}<span class="small muted">${state.state === 'published' ? 'The board is in Discord but isn’t kept up to date.' : 'Turn it on in Settings to post the board.'}</span>`;
|
||||
if (state.state === 'published') {
|
||||
if (state.channelChanged) return html`${pill('Channel changed', 'warn')}<span class="small muted">${edit ? `Update it to move it to #${s.channelName ?? ''}.` : `It’s still in the old channel, not #${s.channelName ?? ''}.`}</span>`;
|
||||
return html`${pill('Live', 'ok')}<span class="small muted">in #${s.channelName ?? ''} · last changed ${timeAgo(state.changedAt)}${state.checkedAt ? ` · checked ${timeAgo(state.checkedAt)}` : ''}. Kept up to date every 10 minutes.</span>${state.error ? html`<span class="small" title="${state.error}">${icon('triangle-alert', 14, 'warn')}</span>` : ''}`;
|
||||
}
|
||||
if (state.state === 'missing') return html`${pill('Deleted in Discord', 'warn')}<span class="small muted">Someone deleted the board message.${edit ? ' Publish it again.' : ''}</span>`;
|
||||
return html`${pill('Not published', 'neutral')}<span class="small muted">${s.channelId ? 'Ready to post.' : 'Choose a channel in Settings first.'}</span>`;
|
||||
}
|
||||
|
||||
/** A table of issues with what can be done to each. */
|
||||
function issueTable(ctx: WorkspaceRequestContext, s: KnownIssuesSettings, list: BoardIssue[], edit: boolean, where: 'shown' | 'below' | 'hidden'): SafeHtml {
|
||||
const b = base(ctx);
|
||||
const act = (i: BoardIssue, action: string) => ({ post: `${b}/issue`, fields: { repo: String(i.repoId), number: String(i.number), action } });
|
||||
return html`<div class="table-wrap"><table class="ki-table">
|
||||
<thead><tr><th class="col-main">Issue</th><th class="num">Reports</th><th>${where === 'hidden' ? 'Would show' : 'Shows'}</th>${edit ? html`<th class="actions"><span class="sr-only">Actions</span></th>` : ''}</tr></thead>
|
||||
<tbody>${list.map((i) => html`<tr>
|
||||
<td><div class="row ki-meta"><span class="small muted">${i.appName}</span>${i.pinned ? tag('Pinned', { icon: 'star' }) : ''}${i.private ? tag('Private', { title: 'Shown without a link: its repository is private' }) : ''}</div>
|
||||
<a class="cell-title" href="${i.githubUrl}" target="_blank" rel="noopener noreferrer">${i.title}</a> <span class="small muted mono">#${String(i.number)}</span>
|
||||
${i.title !== i.githubTitle ? html`<div class="sub">On GitHub: ${i.githubTitle}</div>` : ''}
|
||||
${i.note ? html`<div class="sub">↳ ${i.note}</div>` : ''}</td>
|
||||
<td class="num">${String(i.reports)}</td>
|
||||
<td><span class="ki-status ${STATUS_TONES[i.status]}">${statusLine(s, i)}</span>${i.pull ? html`<div class="sub"><a href="${i.pull.url}" target="_blank" rel="noopener noreferrer">PR #${String(i.pull.number)}</a></div>` : ''}</td>
|
||||
${edit ? html`<td class="actions">${menu([
|
||||
where === 'hidden' ? { ...act(i, 'unhide'), label: 'Show again', icon: 'eye' as const } : i.pinned ? { ...act(i, 'unpin'), label: 'Unpin', icon: 'star' as const } : { ...act(i, 'pin'), label: where === 'below' ? 'Pin to the board' : 'Pin to the top', icon: 'star' as const },
|
||||
{ href: `${b}/issue/${i.repoId}/${i.number}`, label: 'Title and note…', icon: 'pencil' as const },
|
||||
where === 'hidden' ? null : { ...act(i, 'hide'), label: 'Hide from the board', icon: 'eye-off' as const },
|
||||
'sep',
|
||||
{ href: i.githubUrl, label: 'Open on GitHub', icon: 'arrow-up-right' as const, external: true },
|
||||
], { csrf: ctx.csrf, label: `Actions for #${i.number}` })}</td>` : ''}
|
||||
</tr>`)}</tbody></table></div>`;
|
||||
}
|
||||
|
||||
async function healthChecks(ctx: WorkspaceRequestContext, s: KnownIssuesSettings, guild: GuildAccess | null, board: Board): Promise<Check[]> {
|
||||
const conn = await getDiscordConnection(deps.db, ctx.workspace.id);
|
||||
const checks: Check[] = [];
|
||||
if (!conn) checks.push({ status: 'error', title: 'Connect a Discord server first', fix: can(ctx.membership, 'manage') ? { label: 'Connect Discord', href: `${ctx.base}/setup/discord` } : undefined });
|
||||
else if (guild && !guild.ok) checks.push({ status: 'error', title: guild.message });
|
||||
else if (guild?.ok) {
|
||||
const c = s.channelId ? guild.channels.find((x) => x.id === s.channelId) : null;
|
||||
if (!s.channelId) checks.push({ status: 'error', title: 'No channel chosen' });
|
||||
else if (!c) checks.push({ status: 'error', title: 'The chosen channel no longer exists or is hidden from the bot' });
|
||||
else if (c.missing.length) checks.push({ status: 'error', title: `The bot is missing permissions in #${c.name}`, detail: `Missing: ${c.missing.join(', ')}` });
|
||||
else checks.push({ status: 'ok', title: `The bot can post in #${c.name}` });
|
||||
}
|
||||
if (s.reportButton) checks.push(reportUrl(conn) ? { status: 'ok', title: `“${s.reportButtonLabel?.trim() || TEXT_DEFAULTS.reportButton}” opens #${conn?.tickets_channel_name ?? 'the tickets channel'}` } : { status: 'warning', title: 'There’s no ticket panel channel for the button to open', detail: 'Choose one under Discord tickets › Panel, or turn the button off.' });
|
||||
if (board.privateApps.length) checks.push({ status: 'warning', title: `Left out: ${board.privateApps.join(', ')}`, detail: 'Their repositories are private. Turn on “Private repositories” to show their issues without links.' });
|
||||
if (!s.enabled) checks.push({ status: 'warning', title: 'The board is off', detail: 'Turn it on at the top to post it and keep it up to date.' });
|
||||
return checks;
|
||||
}
|
||||
|
||||
app.get('/w/:wid/bot/known-issues', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.view' });
|
||||
if (!ctx) return reply;
|
||||
const wid = ctx.workspace.id;
|
||||
const b = base(ctx);
|
||||
const edit = can(ctx.membership, 'known-issues.edit');
|
||||
const view = (req.query as { view?: string }).view === 'settings' ? 'settings' : 'board';
|
||||
const [s, conn, apps, bot] = await Promise.all([getKnownIssuesSettings(deps.db, wid), getDiscordConnection(deps.db, wid), listApps(deps.db, wid), botIdentity(deps)]);
|
||||
const [board, state] = await Promise.all([computeBoard(deps, wid, s), checkBoard(deps, wid, conn)]);
|
||||
const updatedAt = state.state === 'published' ? state.changedAt : new Date();
|
||||
const preview = html`<div class="panel-preview">
|
||||
${previewCaption(s.channelName, state.state === 'published' ? state.link : null)}
|
||||
${boardPreview(bot, s, board.shown, reportUrl(conn), updatedAt)}
|
||||
<p class="dp-note">${board.shown.length ? `${plural(board.shown.length, 'issue')} on the board.` : 'Nothing on the board right now.'} It’s edited in place when something changes, so the channel doesn’t fill up.</p>
|
||||
</div>`;
|
||||
const views = segLinks('View', [{ href: b, label: 'Board', current: view === 'board' }, { href: `${b}?view=settings`, label: 'Settings', current: view === 'settings' }]);
|
||||
|
||||
let main: SafeHtml;
|
||||
if (view === 'board') {
|
||||
const publishLabel = state.state === 'published' ? (state.channelChanged ? 'Move board' : 'Update now') : state.state === 'missing' ? 'Publish again' : 'Publish board';
|
||||
const boardCard = html`<div class="card">
|
||||
<div class="card-h strip"><div class="row">${stateStrip(s, state, edit)}</div>
|
||||
${edit ? html`<div class="row">${state.state !== 'not_published' ? html`<button type="submit" class="btn ghost danger sm" form="ki-remove"><span class="lead">${icon('trash-2', 14)}</span><span class="lbl">Remove</span></button>` : ''}
|
||||
<form method="post" action="${b}/publish" class="inline-form">${csrfField(ctx.csrf)}${submitBtn(publishLabel, { variant: state.state === 'published' ? undefined : 'primary', size: 'sm', icon: state.state === 'published' ? 'refresh-cw' : 'send', loading: 'Posting…', disabled: !s.enabled || !s.channelId, title: !s.enabled ? 'Turn the board on in Settings first' : undefined })}</form></div>` : ''}</div>
|
||||
<div class="card-b tight"><p class="small muted">The most-reported problems from Discord tickets ${s.period === 'all' ? 'of all time' : `in the last ${periodOf(s.period).label.toLowerCase()}`}, with ${s.minReports}+ reports, up to ${s.maxIssues}. Fixed ones stay ${s.fixedDays ? `${plural(s.fixedDays, 'day')} after they’re closed` : 'off'}. Pinned issues are always on, at the top.</p></div>
|
||||
${board.shown.length ? html`<div class="card-b flush">${issueTable(ctx, s, board.shown, edit, 'shown')}</div>` : html`<div class="card-b"><p class="small muted">Nothing qualifies right now. Members see: “${s.emptyText?.trim() || TEXT_DEFAULTS.empty}”</p></div>`}
|
||||
</div>`;
|
||||
main = html`<div class="stack gap-16">
|
||||
${boardCard}
|
||||
${board.below.length ? html`<div class="card"><div class="card-h"><div><h2>Also reported</h2><div class="desc">Not on the board: fewer reports than ${s.minReports}, or past the ${s.maxIssues} shown. Pin one to put it on.</div></div></div><div class="card-b flush">${issueTable(ctx, s, board.below, edit, 'below')}</div></div>` : ''}
|
||||
${board.hidden.length ? html`<div class="card" id="hidden"><div class="card-h"><div><h2>Hidden</h2><div class="desc">Never on the board, whatever their reports.</div></div></div><div class="card-b flush">${issueTable(ctx, s, board.hidden, edit, 'hidden')}</div></div>` : ''}
|
||||
${edit ? html`<form method="post" action="${b}/add" class="card"><div class="card-h"><div><h2>Add an issue</h2><div class="desc">Put any issue of your apps on the board, pinned, even with no Discord reports.</div></div></div>
|
||||
${csrfField(ctx.csrf)}<div class="card-b"><div class="row"><label class="sr-only" for="ki-add">GitHub issue link</label><input id="ki-add" type="text" class="full" name="issue" placeholder="https://github.com/owner/repo/issues/123" required>${submitBtn('Pin it', { icon: 'star', loading: 'Adding…' })}</div></div></form>` : ''}
|
||||
</div>`;
|
||||
} else {
|
||||
const guild = conn && deps.discord ? await inspectGuild(deps.discord, conn.guild_id) : null;
|
||||
const checks = await healthChecks(ctx, s, guild, board);
|
||||
const sorted = [...apps].sort((x, y) => x.position - y.position);
|
||||
const channelControl = guild?.ok
|
||||
? selectWrap(html`<select id="ki-channel" name="channel_id" aria-label="Board channel">
|
||||
${s.channelId ? '' : html`<option value="" selected disabled>Choose a channel…</option>`}
|
||||
${guild.channels.map((c) => html`<option value="${c.id}" ${c.id === s.channelId ? raw('selected') : ''} ${c.missing.length ? raw('disabled') : ''}>#${c.name}${c.missing.length ? ` (bot missing: ${c.missing.join(', ')})` : c.category ? ` · ${c.category}` : ''}</option>`)}
|
||||
</select>`)
|
||||
: html`<span class="small muted">${conn ? 'Discord can’t be reached right now.' : 'Connect Discord first.'}</span>`;
|
||||
const num = (name: string, value: number, [min, max]: readonly [number, number], label: string) => html`<input type="number" class="wide" name="${name}" value="${String(value)}" min="${String(min)}" max="${String(max)}" aria-label="${label}">`;
|
||||
const { apps: covered } = boardApps({ ...s, appIds: null, includePrivate: true }, apps);
|
||||
const fields = html`
|
||||
<div class="card-h strip"><div class="row">${stateStrip(s, state, edit)}</div></div>
|
||||
<fieldset class="plain${edit ? '' : ' view-only'}" ${edit ? '' : raw('disabled')}>
|
||||
<div class="section">
|
||||
${setting('Known-issues board', 'Post the board and keep it up to date (every 10 minutes, edited only when something changes).', switchInput({ name: 'enabled', checked: s.enabled, label: 'Board turned on', id: 'ki-enabled' }), { flat: true, switchRow: true })}
|
||||
${setting('Channel', 'Where the board is posted. A channel of its own works best, so it stays easy to find.', channelControl, { for: guild?.ok ? 'ki-channel' : undefined, flat: true })}
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="section-h"><div><h3>What goes on it</h3><div class="desc">Issues ranked by their Discord tickets (a duplicate counts for its original), as in Repo status › Most reported.</div></div></div>
|
||||
${setting('Reports counted over', null, selectWrap(html`<select name="period" aria-label="Reports counted over">${PERIODS.map((p) => html`<option value="${p.id}" ${p.id === s.period ? raw('selected') : ''}>${p.id === 'all' ? 'All time' : `The last ${p.label.toLowerCase()}`}</option>`)}</select>`), { flat: true })}
|
||||
${setting('At least', 'Reports an issue needs to go on (pinned ones always do).', html`<div class="row">${num('min_reports', s.minReports, LIMITS.minReports, 'Reports needed')}<span class="small muted">reports</span></div>`, { flat: true })}
|
||||
${setting('Up to', null, html`<div class="row">${num('max_issues', s.maxIssues, LIMITS.maxIssues, 'Issues shown')}<span class="small muted">issues</span></div>`, { flat: true })}
|
||||
${setting('Fixed issues stay', 'So members see it’s fixed and update. 0 takes them off as soon as they’re closed.', html`<div class="row">${num('fixed_days', s.fixedDays, LIMITS.fixedDays, 'Days fixed issues stay')}<span class="small muted">days</span></div>`, { flat: true })}
|
||||
${setting('Private repositories', 'Show their issues too, without links. Off: left out, so nothing private is posted.', switchInput({ name: 'include_private', checked: s.includePrivate, label: 'Include private repositories', id: 'ki-private' }), { flat: true, switchRow: true })}
|
||||
<div class="setting flat top"><div><div class="lbl">Apps</div><div class="desc">All on: apps you add later are included too.</div></div><div class="control"><input type="hidden" name="apps" value="1"><div class="stack gap-8">${sorted.map((a) => html`<label class="row small">${switchInput({ name: 'app_ids', value: a.id, checked: !s.appIds || s.appIds.includes(a.id), label: `Include ${a.name}` })}<span>${a.name}</span>${a.repo_private ? tag('Private') : ''}${covered.some((c) => c.id === a.id) ? '' : html`<span class="small muted">(shares a repository)</span>`}</label>`)}</div></div></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="section-h"><div><h3>Text</h3><div class="desc">Discord formatting works: **bold**, - list, [link](https://…).</div></div>
|
||||
${edit ? html`<button type="button" class="btn ghost sm" data-reset-fields="title_text intro_text empty_text ${STATUSES.map((k) => `status_${k}`).join(' ')} report_button_label"><span class="lead">${icon('undo-2', 14)}</span><span class="lbl">Reset to default</span></button>` : ''}</div>
|
||||
<div class="fields">
|
||||
${textField({ id: 'title_text', label: 'Title', value: s.titleText ?? TEXT_DEFAULTS.title, max: TEXT_LIMITS.title, placeholder: TEXT_DEFAULTS.title, defaultValue: TEXT_DEFAULTS.title, preview: 'pv-ki-title' })}
|
||||
${textField({ id: 'intro_text', label: 'Introduction', value: s.introText ?? TEXT_DEFAULTS.intro, max: TEXT_LIMITS.intro, rows: 2, placeholder: 'Nothing above the list', defaultValue: TEXT_DEFAULTS.intro, preview: 'pv-ki-intro', md: true })}
|
||||
${textField({ id: 'empty_text', label: 'When nothing’s on it', value: s.emptyText ?? TEXT_DEFAULTS.empty, max: TEXT_LIMITS.empty, rows: 2, placeholder: TEXT_DEFAULTS.empty, defaultValue: TEXT_DEFAULTS.empty, preview: board.shown.length ? undefined : 'pv-ki-empty', md: true })}
|
||||
</div>
|
||||
${setting('Group by app', 'Each app’s issues under its name. Off: one list, the app before each issue.', switchInput({ name: 'group_by_app', checked: s.groupByApp, label: 'Group by app', id: 'ki-group' }), { flat: true, switchRow: true })}
|
||||
${setting('Report counts', 'Show how many reports each issue has.', switchInput({ name: 'show_counts', checked: s.showCounts, label: 'Show report counts', id: 'ki-counts' }), { flat: true, switchRow: true })}
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="section-h"><div><h3>Status</h3><div class="desc">What each issue says, from its pull requests and the releases. {version} is the release with the fix.</div></div></div>
|
||||
<div class="fields">${STATUSES.map((k) => textField({ id: `status_${k}`, label: STATUS_NAMES[k], value: s.statusText[k] ?? STATUS_DEFAULTS[k], max: TEXT_LIMITS.status, placeholder: STATUS_DEFAULTS[k], defaultValue: STATUS_DEFAULTS[k] }))}</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
${setting('“Report a problem” button', html`Opens the ticket panel’s channel${conn?.tickets_channel_name ? ` (#${conn.tickets_channel_name})` : ''}.`, switchInput({ name: 'report_button', checked: s.reportButton, label: 'Report a problem button', id: 'ki-report' }), { flat: true, switchRow: true })}
|
||||
<div class="fields ann-notes-label">${textField({ id: 'report_button_label', label: 'Its label', value: s.reportButtonLabel ?? TEXT_DEFAULTS.reportButton, max: TEXT_LIMITS.reportButton, placeholder: TEXT_DEFAULTS.reportButton, defaultValue: TEXT_DEFAULTS.reportButton, preview: 'pv-ki-button' })}</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="section-h"><div><h3>Health</h3><div class="desc">Checked live against Discord when this page loads.</div></div>${linkBtn(`${b}?view=settings`, 'Check again', { variant: 'ghost', size: 'sm', icon: 'refresh-cw' })}</div>
|
||||
${checklist(checks)}
|
||||
</div>
|
||||
</fieldset>`;
|
||||
main = edit
|
||||
? html`<form method="post" action="${b}/settings" class="card" data-dirty>
|
||||
${csrfField(ctx.csrf)}
|
||||
${fields}
|
||||
<div class="card-f"><span class="small muted">${state.state === 'published' ? 'Saving updates the board in Discord.' : ''}</span><div class="end">
|
||||
<span class="row small muted" data-dirty-show hidden><span class="dot c4" aria-hidden="true"></span>Unsaved changes</span>
|
||||
<button type="button" class="btn ghost" data-discard data-dirty-show hidden>Discard</button>
|
||||
${submitBtn('Save changes', { variant: 'primary', loading: 'Saving…', attrs: raw('data-dirty-enable') })}
|
||||
</div></div>
|
||||
</form>`
|
||||
: html`<div class="card">${fields}<div class="card-f">${viewOnlyFooter('the board')}</div></div>`;
|
||||
}
|
||||
|
||||
const body = html`
|
||||
${await toolHeader(web, ctx, 'bot', 'known-issues')}
|
||||
<div class="ki-views">${views}</div>
|
||||
<div class="panel-grid">${main}${preview}</div>
|
||||
${edit && state.state !== 'not_published' ? html`<form method="post" action="${b}/remove" id="ki-remove" hidden data-confirm-title="Remove the board from Discord?" data-confirm-body="The message is deleted. Your settings, pins and notes are kept, so you can post it again." data-confirm-label="Remove board" data-confirm-danger>${csrfField(ctx.csrf)}</form>` : ''}`;
|
||||
return web.render(reply, ctx, view === 'settings' ? 'Settings · Known issues' : 'Known issues · Bot features', 'bot', body, { width: 'full' });
|
||||
});
|
||||
|
||||
app.post('/w/:wid/bot/known-issues/settings', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.edit' });
|
||||
if (!ctx) return reply;
|
||||
const wid = ctx.workspace.id;
|
||||
const body = (req.body ?? {}) as Record<string, unknown>;
|
||||
const str = (k: string) => (typeof body[k] === 'string' ? (body[k] as string) : undefined);
|
||||
try {
|
||||
const current = await getKnownIssuesSettings(deps.db, wid);
|
||||
let channel = { id: current.channelId, name: current.channelName };
|
||||
const chosen = str('channel_id');
|
||||
if (chosen && chosen !== current.channelId) {
|
||||
const conn = await getDiscordConnection(deps.db, wid);
|
||||
if (!conn || !deps.discord) throw new UserFacingError('Connect a Discord server first.');
|
||||
const guild = await inspectGuild(deps.discord, conn.guild_id);
|
||||
if (!guild.ok) throw new UserFacingError('Couldn’t read the server from Discord. Try again in a moment.');
|
||||
// Server-side allowlist: the channel must belong to the connected server.
|
||||
const c = guild.channels.find((x) => x.id === chosen);
|
||||
if (!c) throw new UserFacingError('Choose one of the listed channels.');
|
||||
if (c.missing.length) throw new UserFacingError(`The bot is missing permissions in #${c.name}: ${c.missing.join(', ')}.`);
|
||||
channel = { id: c.id, name: c.name };
|
||||
}
|
||||
const text = (k: string, max: number, def: string) => {
|
||||
const v = str(k);
|
||||
if (v === undefined) return undefined;
|
||||
const t = v.replace(/\r\n/g, '\n').trim().slice(0, max);
|
||||
return t === def ? null : t;
|
||||
};
|
||||
const keep = <T,>(v: T | undefined, old: T) => (v === undefined ? old : v);
|
||||
const apps = await listApps(deps.db, wid);
|
||||
const picked = body.app_ids === undefined ? [] : (Array.isArray(body.app_ids) ? body.app_ids : [body.app_ids]).map(String).filter((id) => apps.some((a) => a.id === id));
|
||||
const statusText = { ...current.statusText };
|
||||
for (const k of STATUSES) {
|
||||
const v = text(`status_${k}`, TEXT_LIMITS.status, STATUS_DEFAULTS[k]);
|
||||
if (v === null || v === '') delete statusText[k];
|
||||
else if (v !== undefined) statusText[k] = v;
|
||||
}
|
||||
const next: KnownIssuesSettings = {
|
||||
...current,
|
||||
enabled: body.enabled !== undefined,
|
||||
channelId: channel.id,
|
||||
channelName: channel.name,
|
||||
appIds: str('apps') === '1' ? (picked.length === apps.length ? null : picked) : current.appIds,
|
||||
period: periodOf(str('period') ?? current.period).id,
|
||||
minReports: Math.min(LIMITS.minReports[1], Math.max(LIMITS.minReports[0], Math.round(Number(str('min_reports') ?? current.minReports)) || current.minReports)),
|
||||
maxIssues: Math.min(LIMITS.maxIssues[1], Math.max(LIMITS.maxIssues[0], Math.round(Number(str('max_issues') ?? current.maxIssues)) || current.maxIssues)),
|
||||
fixedDays: Math.min(LIMITS.fixedDays[1], Math.max(LIMITS.fixedDays[0], Math.round(Number(str('fixed_days') ?? current.fixedDays)) || 0)),
|
||||
includePrivate: body.include_private !== undefined,
|
||||
groupByApp: body.group_by_app !== undefined,
|
||||
showCounts: body.show_counts !== undefined,
|
||||
titleText: keep(text('title_text', TEXT_LIMITS.title, TEXT_DEFAULTS.title), current.titleText) || null,
|
||||
// An empty introduction is kept as empty (nothing above the list).
|
||||
introText: keep(text('intro_text', TEXT_LIMITS.intro, TEXT_DEFAULTS.intro), current.introText),
|
||||
emptyText: keep(text('empty_text', TEXT_LIMITS.empty, TEXT_DEFAULTS.empty), current.emptyText) || null,
|
||||
statusText,
|
||||
reportButton: body.report_button !== undefined,
|
||||
reportButtonLabel: keep(text('report_button_label', TEXT_LIMITS.reportButton, TEXT_DEFAULTS.reportButton), current.reportButtonLabel) || null,
|
||||
};
|
||||
if (next.enabled && !next.channelId) throw new UserFacingError('Choose the channel for the board, then turn it on.');
|
||||
await saveKnownIssuesSettings(deps.db, wid, next);
|
||||
await refreshBoardSoon(deps, wid);
|
||||
setFlash(reply, 'success', next.enabled && !current.enabled ? 'The board is on. Publish it from the Board view.' : 'Settings saved');
|
||||
} catch (err) {
|
||||
if (!(err instanceof UserFacingError)) throw err;
|
||||
setFlash(reply, 'error', err.message);
|
||||
}
|
||||
return reply.redirect(`${base(ctx)}?view=settings`);
|
||||
});
|
||||
|
||||
app.post('/w/:wid/bot/known-issues/publish', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.edit' });
|
||||
if (!ctx) return reply;
|
||||
try {
|
||||
if (!(await getKnownIssuesSettings(deps.db, ctx.workspace.id)).enabled) throw new UserFacingError('Turn the board on in Settings first.');
|
||||
const result = await publishBoard(deps, ctx.workspace.id, ctx.user.id, { force: true });
|
||||
setFlash(reply, 'success', { created: 'Board posted in Discord', updated: 'Board updated', unchanged: 'Board updated', moved: 'Board moved' }[result]);
|
||||
} catch (err) {
|
||||
if (!(err instanceof UserFacingError)) throw err;
|
||||
setFlash(reply, 'error', err.message);
|
||||
}
|
||||
return reply.redirect(base(ctx));
|
||||
});
|
||||
|
||||
app.post('/w/:wid/bot/known-issues/remove', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.edit' });
|
||||
if (!ctx) return reply;
|
||||
await unpublishBoard(deps, ctx.workspace.id);
|
||||
setFlash(reply, 'success', 'Board removed from Discord. Settings, pins and notes are kept.');
|
||||
return reply.redirect(base(ctx));
|
||||
});
|
||||
|
||||
/** The repository of one of the workspace's apps (null when it isn't one). */
|
||||
async function appRepo(wid: string, repoId: number) {
|
||||
return (await listApps(deps.db, wid)).find((a) => a.repo_id === repoId) ?? null;
|
||||
}
|
||||
|
||||
app.post('/w/:wid/bot/known-issues/issue', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.edit' });
|
||||
if (!ctx) return reply;
|
||||
const wid = ctx.workspace.id;
|
||||
const body = (req.body ?? {}) as { repo?: string; number?: string; action?: string };
|
||||
const repoId = Number(body.repo);
|
||||
const number = Number(body.number);
|
||||
const changes: Record<string, [Partial<{ pinned: boolean; hidden: boolean }>, string]> = {
|
||||
pin: [{ pinned: true }, 'Pinned: always on the board, at the top'], unpin: [{ pinned: false }, 'Unpinned'],
|
||||
hide: [{ hidden: true }, 'Hidden from the board'], unhide: [{ hidden: false }, 'Shown again when it qualifies'],
|
||||
};
|
||||
const change = changes[body.action ?? ''];
|
||||
if (!change || !Number.isInteger(number) || number < 1 || !(await appRepo(wid, repoId))) {
|
||||
setFlash(reply, 'error', 'That issue isn’t in one of your apps’ repositories.');
|
||||
return reply.redirect(base(ctx));
|
||||
}
|
||||
await setIssueOverride(deps.db, wid, repoId, number, change[0]);
|
||||
await refreshBoardSoon(deps, wid);
|
||||
setFlash(reply, 'success', change[1]);
|
||||
return reply.redirect(base(ctx));
|
||||
});
|
||||
|
||||
app.post('/w/:wid/bot/known-issues/add', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.edit' });
|
||||
if (!ctx) return reply;
|
||||
const wid = ctx.workspace.id;
|
||||
const ref = parseIssueRef(String((req.body as { issue?: string }).issue ?? ''));
|
||||
const app = ref ? (await listApps(deps.db, wid)).find((a) => a.repo_owner.toLowerCase() === ref.owner.toLowerCase() && a.repo_name.toLowerCase() === ref.name.toLowerCase()) : null;
|
||||
if (!ref || !app) {
|
||||
setFlash(reply, 'error', ref ? `${ref.owner}/${ref.name} isn’t one of your apps’ repositories.` : 'Paste a GitHub issue link, like https://github.com/owner/repo/issues/123.');
|
||||
return reply.redirect(base(ctx));
|
||||
}
|
||||
await setIssueOverride(deps.db, wid, app.repo_id, ref.number, { pinned: true });
|
||||
await refreshBoardSoon(deps, wid);
|
||||
setFlash(reply, 'success', `#${ref.number} is pinned to the board`);
|
||||
return reply.redirect(base(ctx));
|
||||
});
|
||||
|
||||
app.get('/w/:wid/bot/known-issues/issue/:repo/:number', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.view' });
|
||||
if (!ctx) return reply;
|
||||
const wid = ctx.workspace.id;
|
||||
const p = req.params as { repo: string; number: string };
|
||||
const repo = await appRepo(wid, Number(p.repo));
|
||||
if (!repo || !/^\d+$/.test(p.number)) return reply.callNotFound();
|
||||
const s = await getKnownIssuesSettings(deps.db, wid);
|
||||
const board = await computeBoard(deps, wid, s);
|
||||
const issue = [...board.shown, ...board.below, ...board.hidden].find((i) => i.repoId === repo.repo_id && i.number === Number(p.number));
|
||||
const current = (await issueOverrides(deps.db, wid)).get(`${repo.repo_id}:${p.number}`);
|
||||
const edit = can(ctx.membership, 'known-issues.edit');
|
||||
const b = base(ctx);
|
||||
const fields = html`<div class="card-b"><div class="fields">
|
||||
${textField({ id: 'title', label: 'Shown as', value: current?.title ?? '', max: TEXT_LIMITS.issueTitle, placeholder: issue?.githubTitle ?? `Issue #${p.number}`, hint: 'Leave empty to use the title on GitHub. Write it the way members would describe the problem.' })}
|
||||
${textField({ id: 'note', label: 'Note under it (optional)', value: current?.note ?? '', max: TEXT_LIMITS.note, rows: 2, placeholder: 'For example: until it’s fixed, export as PNG instead.', hint: 'A workaround, or what to do meanwhile. Discord formatting works.' })}
|
||||
</div></div>`;
|
||||
const body = html`
|
||||
${pageHeader({
|
||||
crumbs: [{ href: toolHref(ctx, 'bot') ?? undefined, label: 'Bot features' }, { href: b, label: 'Known issues' }, { label: `#${p.number}` }],
|
||||
title: issue?.githubTitle ?? `Issue #${p.number}`,
|
||||
description: html`${repo.name} · <a href="${issue?.githubUrl ?? `https://github.com/${repo.repo_owner}/${repo.repo_name}/issues/${p.number}`}" target="_blank" rel="noopener noreferrer" class="mono">${repo.repo_owner}/${repo.repo_name}#${p.number}</a>${issue ? html` · ${plural(issue.reports, 'report')} · ${statusLine(s, issue)}` : ''}`,
|
||||
})}
|
||||
${edit
|
||||
? html`<form method="post" action="${b}/issue/${repo.repo_id}/${p.number}" class="card">${csrfField(ctx.csrf)}${fields}
|
||||
<div class="card-f"><span></span><div class="end">${linkBtn(b, 'Cancel')}${submitBtn('Save', { variant: 'primary', loading: 'Saving…' })}</div></div></form>`
|
||||
: html`<div class="card"><fieldset class="plain view-only" disabled>${fields}</fieldset><div class="card-f">${viewOnlyFooter('the board')}</div></div>`}`;
|
||||
return web.render(reply, ctx, `#${p.number} · Known issues`, 'bot', body);
|
||||
});
|
||||
|
||||
app.post('/w/:wid/bot/known-issues/issue/:repo/:number', async (req, reply) => {
|
||||
const ctx = await web.requireWorkspace(req, reply, { permission: 'known-issues.edit' });
|
||||
if (!ctx) return reply;
|
||||
const wid = ctx.workspace.id;
|
||||
const p = req.params as { repo: string; number: string };
|
||||
const repo = await appRepo(wid, Number(p.repo));
|
||||
if (!repo || !/^\d+$/.test(p.number)) return reply.callNotFound();
|
||||
const body = (req.body ?? {}) as { title?: string; note?: string };
|
||||
const clean = (v: string | undefined, max: number) => (v ?? '').replace(/\s+/g, ' ').trim().slice(0, max) || null;
|
||||
await setIssueOverride(deps.db, wid, repo.repo_id, Number(p.number), { title: clean(body.title, TEXT_LIMITS.issueTitle), note: clean(body.note, TEXT_LIMITS.note) });
|
||||
await refreshBoardSoon(deps, wid);
|
||||
setFlash(reply, 'success', 'Saved');
|
||||
return reply.redirect(base(ctx));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ const CAPABILITIES: [string, string, string, string][] = [
|
||||
['AI triage: review suggestions and change its pages', 'yes', 'yes', 'maybe'],
|
||||
['Contributor roles', 'yes', 'yes', 'maybe'],
|
||||
['Announcements: post releases and change their settings', 'yes', 'yes', 'maybe'],
|
||||
['Bot features: the known-issues board', 'yes', 'yes', 'maybe'],
|
||||
['Apps & repositories', 'yes', 'yes', 'maybe'],
|
||||
['Server health', 'yes', 'yes', 'maybe'],
|
||||
['File cleanup rules and storage limit', 'yes', 'yes', 'no'],
|
||||
@@ -63,7 +64,7 @@ const CAPABILITIES: [string, string, string, string][] = [
|
||||
];
|
||||
|
||||
/** Short tool names for the access tags in the members table. */
|
||||
const TOOL_TAGS: Record<Tool, string> = { tickets: 'Tickets', issues: 'Issues', repos: 'Repos', analytics: 'Analytics', triage: 'Triage', contributors: 'Roles', announcements: 'Announce', setup: 'Apps', workspace: 'Health' };
|
||||
const TOOL_TAGS: Record<Tool, string> = { tickets: 'Tickets', issues: 'Issues', repos: 'Repos', analytics: 'Analytics', triage: 'Triage', contributors: 'Roles', announcements: 'Announce', bot: 'Bot', setup: 'Apps', workspace: 'Health' };
|
||||
const LEVEL_NAMES: Record<AccessLevel, string> = { none: 'No access', view: 'View', edit: 'Edit' };
|
||||
const SET_NAMES: Record<AccessLevel, string> = { none: 'No access', view: 'View all', edit: 'Edit all' };
|
||||
|
||||
|
||||
+15
-2
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { announcementCounts, getAnnouncementSettings } from '../../announcements/settings.js';
|
||||
import { checkBoard, getKnownIssuesSettings } from '../../bot-features/known-issues.js';
|
||||
import { checkContributorPanel, getContributorSettings } from '../../domain/contributors.js';
|
||||
import type { Queryable } from '../../db/database.js';
|
||||
import { checkPanel, type PanelState } from '../../domain/panel.js';
|
||||
@@ -17,10 +18,10 @@ import type { Web, WorkspaceRequestContext } from '../server.js';
|
||||
import { chip, pageHeader, pill, plural, postBtn, tabs, timeAgo, viewOnlyTag, type IconName } from '../ui.js';
|
||||
|
||||
/** The tools that have their own item in the sidebar, in order. */
|
||||
export type ToolName = 'tickets' | 'issues' | 'repos' | 'analytics' | 'triage' | 'contributors' | 'announcements';
|
||||
export type ToolName = 'tickets' | 'issues' | 'repos' | 'analytics' | 'triage' | 'contributors' | 'announcements' | 'bot';
|
||||
|
||||
/** Each tool's icon, in the sidebar, on the overview and on Members. */
|
||||
export const TOOL_ICONS: Record<Tool, IconName> = { tickets: 'ticket', issues: 'circle-dot', repos: 'chart-no-axes-column-increasing', analytics: 'chart-line', triage: 'sparkles', contributors: 'award', announcements: 'megaphone', setup: 'boxes', workspace: 'activity' };
|
||||
export const TOOL_ICONS: Record<Tool, IconName> = { tickets: 'ticket', issues: 'circle-dot', repos: 'chart-no-axes-column-increasing', analytics: 'chart-line', triage: 'sparkles', contributors: 'award', announcements: 'megaphone', bot: 'bot', setup: 'boxes', workspace: 'activity' };
|
||||
|
||||
/** Every page's address under /w/:wid. */
|
||||
export const AREA_PATHS: Record<Area, string> = {
|
||||
@@ -47,6 +48,7 @@ export const AREA_PATHS: Record<Area, string> = {
|
||||
'announcements': '/announcements',
|
||||
'announcement-settings': '/announcements/settings',
|
||||
'announcement-pings': '/announcements/pings',
|
||||
'known-issues': '/bot/known-issues',
|
||||
'apps': '/apps',
|
||||
'health': '/health',
|
||||
};
|
||||
@@ -141,6 +143,7 @@ const VIEW_ONLY: Partial<Record<Area, string>> = {
|
||||
'announcements': 'You can see the releases and their posts. Posting, editing and skipping them need Edit on Posts. Ask an admin if you need it.',
|
||||
'announcement-settings': 'You can see how announcements are set up. Ask an admin if you need to change it.',
|
||||
'announcement-pings': 'You can see the pings message and its preview. Ask an admin if you need to change, publish or remove it.',
|
||||
'known-issues': 'You can see the known-issues board and its settings. Changing them, pinning or hiding issues, and publishing need Edit on Known issues. Ask an admin if you need it.',
|
||||
'health': 'You can see how the server is doing. Switching Dev mode needs Edit on Server health. Ask an admin if you need it.',
|
||||
};
|
||||
|
||||
@@ -206,6 +209,16 @@ async function toolState(web: Web, ctx: WorkspaceRequestContext, tool: ToolName,
|
||||
counts: { 'triage.review': ctx.progress?.review ?? 0, 'triage.knowledge': [...(questions?.values() ?? [])].reduce((n, q) => n + q.fresh, 0) },
|
||||
};
|
||||
}
|
||||
if (tool === 'bot') {
|
||||
const [ki, conn] = await Promise.all([getKnownIssuesSettings(db, wid), getDiscordConnection(db, wid)]);
|
||||
const board = await checkBoard(web.deps, wid, conn, { live: false });
|
||||
return {
|
||||
status: !ki.enabled ? pill('Off', 'neutral') : board.state === 'published' ? pill('Live', 'ok') : board.state === 'missing' ? pill('Board deleted', 'warn') : pill('Not published', 'neutral'),
|
||||
description: 'Extra things the bot does in your Discord, each turned on when you want it. First: a known-issues board.',
|
||||
actions: [],
|
||||
counts: {},
|
||||
};
|
||||
}
|
||||
if (tool === 'announcements') {
|
||||
const [s, counts] = await Promise.all([getAnnouncementSettings(db, wid), announcementCounts(db, wid)]);
|
||||
return {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { getTriageSettings, monthlyUsage } from '../../triage/settings.js';
|
||||
import { getStatusSettings, statusRepos, statusRows } from '../../repo-status/tracker.js';
|
||||
import { analyticsRepos, getAnalyticsSettings } from '../../analytics/recorder.js';
|
||||
import { announcedRepos, announcementCounts, appAnnounceSettings, getAnnouncementSettings } from '../../announcements/settings.js';
|
||||
import { checkBoard, getBoardRow, getKnownIssuesSettings, issueOverrides } from '../../bot-features/known-issues.js';
|
||||
import type { StepState } from '../layout.js';
|
||||
import { setFlash } from '../session.js';
|
||||
import type { Web, WorkspaceRequestContext } from '../server.js';
|
||||
@@ -42,7 +43,7 @@ import { areaHref, canOpen, canOpenIssue, firstPage, panelPill, repoSyncState, T
|
||||
// ---- Overview -----------------------------------------------------------------------------------
|
||||
|
||||
/** The tools with a card on the overview, in sidebar order. */
|
||||
const OVERVIEW_TOOLS: readonly ToolName[] = ['analytics', 'repos', 'tickets', 'issues', 'triage', 'contributors', 'announcements'];
|
||||
const OVERVIEW_TOOLS: readonly ToolName[] = ['analytics', 'repos', 'tickets', 'issues', 'triage', 'contributors', 'announcements', 'bot'];
|
||||
|
||||
const DAY_MS = 86_400_000;
|
||||
/** Latest goes back this far for issues opened on GitHub (the others are newest first by index). */
|
||||
@@ -325,7 +326,29 @@ async function announcementsCard({ web, ctx }: Shared): Promise<ToolCard> {
|
||||
};
|
||||
}
|
||||
|
||||
const CARDS: Record<ToolName, (s: Shared) => Promise<ToolCard>> = { tickets: ticketsCard, issues: issuesCard, repos: reposCard, analytics: analyticsCard, triage: triageCard, contributors: contributorsCard, announcements: announcementsCard };
|
||||
async function botCard({ web, ctx, dc }: Shared): Promise<ToolCard> {
|
||||
const { db } = web.deps;
|
||||
const b = ctx.base;
|
||||
const [s, row, overrides] = await Promise.all([getKnownIssuesSettings(db, ctx.workspace.id), getBoardRow(db, ctx.workspace.id), issueOverrides(db, ctx.workspace.id)]);
|
||||
const board = await checkBoard(web.deps, ctx.workspace.id, dc, { live: false });
|
||||
const kept = [...overrides.values()];
|
||||
return {
|
||||
tool: 'bot',
|
||||
meta: s.enabled ? `Known issues${s.channelName ? ` in #${s.channelName}` : ''}${board.state === 'published' ? ` · changed ${timeAgo(board.changedAt)}` : ''}` : 'Known issues board: off',
|
||||
status: !s.enabled ? pill('Off', 'neutral') : board.state === 'published' ? pill('Live', 'ok') : board.state === 'missing' ? pill('Board deleted', 'warn') : pill('Not published', 'neutral'),
|
||||
stats: [
|
||||
{ label: 'On the board', value: board.state === 'published' ? row?.issue_count ?? 0 : 0, area: 'known-issues', href: `${b}/bot/known-issues` },
|
||||
{ label: 'Pinned', value: kept.filter((o) => o.pinned).length, area: 'known-issues', href: `${b}/bot/known-issues` },
|
||||
{ label: 'Hidden', value: kept.filter((o) => o.hidden).length, area: 'known-issues', href: `${b}/bot/known-issues#hidden` },
|
||||
],
|
||||
go: [
|
||||
...(!s.enabled && can(ctx.membership, 'known-issues.edit') ? [{ area: 'known-issues' as const, label: 'Set up the board', href: `${b}/bot/known-issues?view=settings`, primary: true }] : []),
|
||||
{ area: 'known-issues', label: 'Known issues' },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const CARDS: Record<ToolName, (s: Shared) => Promise<ToolCard>> = { tickets: ticketsCard, issues: issuesCard, repos: reposCard, analytics: analyticsCard, triage: triageCard, contributors: contributorsCard, announcements: announcementsCard, bot: botCard };
|
||||
|
||||
// ---- Latest: what just happened, across the tools ------------------------------------------------
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import { registerTriageActivityRoutes } from './routes/triage-activity.js';
|
||||
import { registerTriageBulkRoutes } from './routes/triage-bulk.js';
|
||||
import { registerContributorRoutes } from './routes/contributors.js';
|
||||
import { registerAnnouncementRoutes } from './routes/announcements.js';
|
||||
import { registerBotFeatureRoutes } from './routes/bot-features.js';
|
||||
import { registerTicketTypeRoutes } from './routes/ticket-types.js';
|
||||
import { registerFileRoutes, UPLOAD_ROUTE } from './routes/files.js';
|
||||
import { registerIssueRoutes } from './routes/issues.js';
|
||||
@@ -282,6 +283,7 @@ export async function buildServer(deps: Deps, processor: Processor, opts: { logg
|
||||
registerMemberRoutes(app, web);
|
||||
registerContributorRoutes(app, web);
|
||||
registerAnnouncementRoutes(app, web);
|
||||
registerBotFeatureRoutes(app, web);
|
||||
registerTicketTypeRoutes(app, web);
|
||||
registerFileRoutes(app, web);
|
||||
registerIssueRoutes(app, web);
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ export function testDb(): Db {
|
||||
|
||||
export async function resetDb(db: Db = testDb()): Promise<void> {
|
||||
db.exec('DELETE FROM sessions; DELETE FROM oauth_states; DELETE FROM workspaces; DELETE FROM users; DELETE FROM issue_index; DELETE FROM issue_index_repos; DELETE FROM process_status;');
|
||||
db.exec('DELETE FROM pull_index; DELETE FROM repo_status; DELETE FROM download_counts; DELETE FROM download_days; DELETE FROM download_assets; DELETE FROM download_sync; DELETE FROM repo_star_changes; DELETE FROM announcement_checks;');
|
||||
db.exec('DELETE FROM pull_index; DELETE FROM repo_status; DELETE FROM download_counts; DELETE FROM download_days; DELETE FROM download_assets; DELETE FROM download_sync; DELETE FROM repo_star_changes; DELETE FROM announcement_checks; DELETE FROM known_issue_overrides;');
|
||||
db.exec('UPDATE server_settings SET dev_mode_on_at = NULL, dev_mode_by = NULL, dev_mode_off_at = NULL;');
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
import { afterAll, beforeEach, describe, expect, it } from 'vitest';
|
||||
import { boardPayload, computeBoard, getKnownIssuesSettings } from '../src/bot-features/known-issues.js';
|
||||
import { IssueIndexer, setDuplicateOf } from '../src/domain/issue-index.js';
|
||||
import { acceptSubmission } from '../src/domain/submissions.js';
|
||||
import { createInvite } from '../src/domain/workspaces.js';
|
||||
import { form, get, grant, makeAdmin, makeApp, makeWorkspace, resetDb, testDb, type Admin, type ConfiguredWorkspace, type TestEnv } from './helpers.js';
|
||||
|
||||
let env: TestEnv;
|
||||
let ws: ConfiguredWorkspace;
|
||||
let boardChannel: string;
|
||||
const w = () => `/w/${ws.workspace.id}`;
|
||||
const page = (url: string, who: Admin = ws.owner) => env.server.inject({ method: 'GET', url: `${w()}${url}`, ...get(who) });
|
||||
const post = (url: string, fields: Record<string, string | string[]> = {}, who: Admin = ws.owner) => env.server.inject({ method: 'POST', url: `${w()}${url}`, ...form(who, fields) });
|
||||
const repo = (i = 0) => env.github.repos.get(ws.repoIds[i]!)!;
|
||||
const sync = async () => {
|
||||
await env.db.query('UPDATE issue_index_repos SET sync_requested_at = now_ms(), pulls_checked_at = NULL, releases_checked_at = NULL');
|
||||
await new IssueIndexer(env.deps).tick();
|
||||
};
|
||||
const board = async () => computeBoard(env.deps, ws.workspace.id, await getKnownIssuesSettings(env.db, ws.workspace.id));
|
||||
const posted = () => [...env.discord.messages.entries()].filter(([, m]) => m.channelId === boardChannel).map(([id, m]) => ({ id, ...m.payload }));
|
||||
const ago = (days: number) => new Date(Date.now() - days * 86_400_000).toISOString();
|
||||
|
||||
let k = 0;
|
||||
/** A Discord ticket for an app, filed as an issue. */
|
||||
async function ticket(title: string, appIndex = 0) {
|
||||
k++;
|
||||
const r = await acceptSubmission(env.deps, {
|
||||
workspace: ws.workspace, app: ws.apps[appIndex]!, installationId: ws.installationId, source: 'discord', interactionId: `int-ki${k}`, interactionToken: null,
|
||||
guildId: ws.guildId, guildName: 'G', channelId: ws.channelId, reporter: { id: `m${k}`, displayName: `Member ${k}`, username: `m${k}` },
|
||||
title, description: `It happens every time (${k}).`, ticketType: null,
|
||||
});
|
||||
if (r.kind !== 'accepted') throw new Error(r.kind);
|
||||
await env.worker.drain();
|
||||
return (await env.db.query('SELECT id, issue_number FROM submissions WHERE id = $1', [r.submission.id])).rows[0] as { id: string; issue_number: number };
|
||||
}
|
||||
/** An issue reported `n` times: the first ticket, and n - 1 marked as its duplicates on GitHub. */
|
||||
async function reported(title: string, n: number, appIndex = 0) {
|
||||
const first = await ticket(title, appIndex);
|
||||
const copies = [];
|
||||
for (let i = 1; i < n; i++) copies.push(await ticket(`${title} (${i})`, appIndex));
|
||||
return { number: first.issue_number, copies: copies.map((c) => c.issue_number) };
|
||||
}
|
||||
const issue = (n: number, i = 0) => repo(i).issues.find((x) => x.number === n)!;
|
||||
|
||||
async function turnOn(fields: Record<string, string | string[]> = {}) {
|
||||
const res = await post('/bot/known-issues/settings', {
|
||||
enabled: '1', channel_id: boardChannel, period: '30d', min_reports: '2', max_issues: '10', fixed_days: '14', group_by_app: '1', show_counts: '1', report_button: '1', apps: '1',
|
||||
app_ids: ws.apps.map((a) => a.id), ...fields,
|
||||
});
|
||||
expect(res.statusCode).toBe(302);
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
await resetDb();
|
||||
env = await makeApp();
|
||||
ws = await makeWorkspace(env, {
|
||||
repos: [{ id: 9501, name: 'photocraft', private: false }, { id: 9502, name: 'vectorcraft', private: true }],
|
||||
apps: [{ name: 'PhotoCraft', repoIndex: 0 }, { name: 'VectorCraft', repoIndex: 1 }],
|
||||
});
|
||||
boardChannel = String(BigInt(ws.channelId) + 7n);
|
||||
env.discord.guilds.get(ws.guildId)!.channels.push({ id: boardChannel, type: 0, name: 'known-issues', position: 2 });
|
||||
});
|
||||
afterAll(async () => {
|
||||
await testDb().end();
|
||||
});
|
||||
|
||||
describe('Known issues: what goes on the board', () => {
|
||||
it('ranks reported issues and says what’s happening with each, from pull requests and releases', async () => {
|
||||
const crash = await reported('Export crashes the app', 3);
|
||||
const lag = await reported('Brush lags on big canvases', 2);
|
||||
const once = await reported('Ruler shows the wrong units', 1);
|
||||
const fixed = await reported('Undo forgets the last step', 2);
|
||||
const wontfix = await reported('Add a dark mode for the splash', 2);
|
||||
const secret = await reported('Private app crash', 2, 1);
|
||||
// Being worked on (open pull request), fixed in a release (merged before v1.2.0), not planned.
|
||||
repo().pulls = [
|
||||
{ number: 50, title: 'Faster brush', body: `Fixes #${lag.number}`, user: 'dev', created_at: ago(1), updated_at: ago(1) },
|
||||
{ number: 51, title: 'Keep undo history', body: `Fixes #${fixed.number}`, user: 'dev', created_at: ago(3), updated_at: ago(2), merged_at: ago(2) },
|
||||
];
|
||||
repo().releases = [{ tag: 'v1.2.0', published_at: ago(1) }];
|
||||
Object.assign(issue(fixed.number), { state: 'closed', state_reason: 'completed', closed_at: ago(2) });
|
||||
Object.assign(issue(wontfix.number), { state: 'closed', state_reason: 'not_planned', closed_at: ago(1) });
|
||||
await sync();
|
||||
for (const [i, x] of [[0, crash], [0, lag], [0, fixed], [0, wontfix], [1, secret]] as const) for (const c of x.copies) await setDuplicateOf(env.db, repo(i).id, c, x.number);
|
||||
await turnOn();
|
||||
|
||||
const b = await board();
|
||||
// Most reports first; a tie goes to the one reported most recently.
|
||||
expect(b.shown.map((i) => [i.number, i.reports, i.status, i.version])).toEqual([
|
||||
[crash.number, 3, 'open', null],
|
||||
[fixed.number, 2, 'released', 'v1.2.0'],
|
||||
[lag.number, 2, 'working', null],
|
||||
]);
|
||||
expect(b.below.map((i) => i.number)).toEqual([once.number]);
|
||||
// The private repository's issue isn't posted, and not planned isn't a known issue.
|
||||
expect(b.privateApps).toEqual(['VectorCraft']);
|
||||
expect([...b.shown, ...b.below].some((i) => i.number === wontfix.number)).toBe(false);
|
||||
|
||||
// Pin the one with a single report, hide the one being worked on.
|
||||
await post('/bot/known-issues/issue', { repo: String(repo().id), number: String(once.number), action: 'pin' });
|
||||
await post('/bot/known-issues/issue', { repo: String(repo().id), number: String(lag.number), action: 'hide' });
|
||||
const b2 = await board();
|
||||
expect(b2.shown.map((i) => i.number)).toEqual([once.number, crash.number, fixed.number]);
|
||||
expect(b2.hidden.map((i) => i.number)).toEqual([lag.number]);
|
||||
|
||||
// Private repositories on: shown, without a link.
|
||||
await turnOn({ include_private: '1' });
|
||||
const priv = (await board()).shown.find((i) => i.appName === 'VectorCraft')!;
|
||||
expect(priv).toMatchObject({ number: secret.number, url: null, private: true });
|
||||
const text = boardPayload(await getKnownIssuesSettings(env.db, ws.workspace.id), [priv], { reportUrl: null, updatedAt: new Date() }).embeds[0]!.description;
|
||||
expect(text).toContain('- Private app crash · 2 reports · 🔍 Looking into it');
|
||||
expect(text).not.toContain('github.com');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Known issues: the board in Discord', () => {
|
||||
it('posts the board, edits it only when it changes, and follows pins, titles and notes', async () => {
|
||||
const crash = await reported('Export crashes the app', 2);
|
||||
await sync();
|
||||
await setDuplicateOf(env.db, repo().id, crash.copies[0]!, crash.number);
|
||||
// Off: can't be posted.
|
||||
await post('/bot/known-issues/publish');
|
||||
expect(posted()).toEqual([]);
|
||||
await turnOn();
|
||||
await post('/bot/known-issues/publish');
|
||||
const [msg] = posted();
|
||||
const embed = msg!.embeds[0];
|
||||
expect(embed.title).toBe('Known issues');
|
||||
expect(embed.description).toContain(`**PhotoCraft**\n- [Export crashes the app](https://github.com/${repo().owner}/photocraft/issues/${crash.number}) · 2 reports · 🔍 Looking into it`);
|
||||
expect(msg!.components[0].components[0]).toMatchObject({ style: 5, label: 'Report a problem', url: `https://discord.com/channels/${ws.guildId}/${ws.channelId}` });
|
||||
expect(msg!.allowed_mentions).toEqual({ parse: [] });
|
||||
const row = async () => (await env.db.query('SELECT * FROM known_issue_boards')).rows[0];
|
||||
const first = await row();
|
||||
expect(first).toMatchObject({ status: 'published', message_id: msg!.id, issue_count: 1 });
|
||||
|
||||
// Nothing changed: the updater leaves the message alone.
|
||||
await env.db.query('UPDATE known_issue_boards SET checked_at = $1', [new Date(Date.now() - 11 * 60_000)]);
|
||||
await env.triage.engine.knownIssues.tick();
|
||||
expect((await row()).changed_at).toEqual(first.changed_at);
|
||||
|
||||
// A title the way members say it and a workaround: the board catches up right away.
|
||||
await post(`/bot/known-issues/issue/${repo().id}/${crash.number}`, { title: 'Exporting crashes', note: 'Until it’s fixed, export as PNG.' });
|
||||
const edited = env.discord.messages.get(msg!.id)!.payload.embeds[0].description;
|
||||
expect(edited).toContain('[Exporting crashes](');
|
||||
expect(edited).toContain('\n ↳ Until it’s fixed, export as PNG.');
|
||||
expect(posted()).toHaveLength(1);
|
||||
|
||||
// Custom texts and statuses, one list with the app before each issue.
|
||||
await turnOn({ group_by_app: [], title_text: 'Bekannte Probleme', status_open: '👀 Wir schauen es uns an', report_button: [] });
|
||||
const now = env.discord.messages.get(msg!.id)!.payload;
|
||||
expect(now.embeds[0].title).toBe('Bekannte Probleme');
|
||||
expect(now.embeds[0].description).toContain('- **PhotoCraft**: [Exporting crashes](');
|
||||
expect(now.embeds[0].description).toContain('👀 Wir schauen es uns an');
|
||||
expect(now.components).toEqual([]);
|
||||
|
||||
// Deleted in Discord: the page says so, and publishing posts it again.
|
||||
env.discord.messages.delete(msg!.id);
|
||||
expect((await page('/bot/known-issues')).body).toContain('Deleted in Discord');
|
||||
await post('/bot/known-issues/publish');
|
||||
expect(posted()).toHaveLength(1);
|
||||
expect((await row()).message_id).not.toBe(msg!.id);
|
||||
// Removed: gone from Discord, settings kept.
|
||||
await post('/bot/known-issues/remove');
|
||||
expect(posted()).toEqual([]);
|
||||
expect((await getKnownIssuesSettings(env.db, ws.workspace.id)).titleText).toBe('Bekannte Probleme');
|
||||
});
|
||||
|
||||
it('adds an issue by its link, and refuses one of another repository', async () => {
|
||||
repo().issues.push({ number: 321, title: 'Fonts look blurry', body: '', labels: [], created_at: ago(1), user: 'someone' });
|
||||
await sync();
|
||||
await turnOn();
|
||||
await post('/bot/known-issues/add', { issue: `https://github.com/${repo().owner}/photocraft/issues/321` });
|
||||
expect((await board()).shown.map((i) => [i.number, i.pinned, i.reports])).toEqual([[321, true, 0]]);
|
||||
await post('/bot/known-issues/add', { issue: 'https://github.com/someone/else/issues/1' });
|
||||
expect((await env.db.query('SELECT count(*) AS n FROM known_issue_overrides')).rows[0].n).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Known issues: pages and access', () => {
|
||||
it('has a page and settings with a preview; moderators need access, and Edit to change it', async () => {
|
||||
await reported('Export crashes the app', 2);
|
||||
await turnOn();
|
||||
const board1 = await page('/bot/known-issues');
|
||||
expect(board1.statusCode).toBe(200);
|
||||
expect(board1.body).toContain('Preview of the known-issues board in Discord');
|
||||
expect(board1.body).toContain('Publish board');
|
||||
const settings = await page('/bot/known-issues?view=settings');
|
||||
expect(settings.body).toContain('Left out: VectorCraft');
|
||||
expect(settings.body).toContain('The bot can post in #known-issues');
|
||||
expect((await page('/bot')).headers.location).toBe(`${w()}/bot/known-issues`);
|
||||
expect((await page('')).body).toContain('Bot features');
|
||||
|
||||
const mod = await makeAdmin(env, 'ki-mod');
|
||||
await env.server.inject({ method: 'POST', url: `/invite/${await createInvite(env.db, ws.workspace.id, ws.owner.user.id, 'moderator')}`, ...form(mod) });
|
||||
await grant(env, ws.workspace.id, mod.user.id, {});
|
||||
expect((await page('/bot/known-issues', mod)).statusCode).toBe(403);
|
||||
await grant(env, ws.workspace.id, mod.user.id, { 'known-issues': 'view' });
|
||||
const view = await page('/bot/known-issues', mod);
|
||||
expect(view.statusCode).toBe(200);
|
||||
expect(view.body).not.toContain('Publish board');
|
||||
expect((await post('/bot/known-issues/publish', {}, mod)).statusCode).toBe(403);
|
||||
});
|
||||
});
|
||||
@@ -117,7 +117,7 @@ describe('Members › Moderator access', () => {
|
||||
expect(body).toContain(`<form id="acc-${mod.user.id}" method="post" action="${w()}/members/${mod.user.id}/access" data-async hidden>`);
|
||||
expect(body).toContain(`<section class="acc-editor" id="mod-${mod.user.id}" data-mod="${mod.user.id}"`);
|
||||
expect(body).toContain(`<span class="nm" id="acc-name-${mod.user.id}">mia</span>`);
|
||||
expect(body).toContain('2 of 25 pages open · 1 editable');
|
||||
expect(body).toContain('2 of 26 pages open · 1 editable');
|
||||
// No Access / View / Edit per page: the Inbox can't be turned off, Activity has nothing to edit.
|
||||
const radios = (name: string) => [...body.matchAll(new RegExp(`<input type="radio" name="${name.replace('.', '\\.')}" value="(\\w+)" form="acc-${mod.user.id}"[^>]*?( checked)?>`, 'g'))].map((m) => `${m[1]}${m[2] ? '*' : ''}`);
|
||||
for (const a of AREA_KEYS) expect(radios(a).length, a).toBeGreaterThan(1);
|
||||
|
||||
@@ -78,10 +78,10 @@ function buttons(body: string, tool: string): string[] {
|
||||
const latest = (body: string) => [...body.matchAll(/<span class="feed-t">([^<]+)<\/span>/g)].map((x) => x[1]);
|
||||
|
||||
describe('Overview: a card per tool', () => {
|
||||
it('admins see all seven tools, with buttons to their pages', async () => {
|
||||
it('admins see all eight tools, with buttons to their pages', async () => {
|
||||
const res = await page('', ws.owner);
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(cards(res.body)).toEqual(['Analytics', 'Repo status', 'Discord tickets', 'GitHub issues', 'AI triage', 'Contributor roles', 'Announcements']);
|
||||
expect(cards(res.body)).toEqual(['Analytics', 'Repo status', 'Discord tickets', 'GitHub issues', 'AI triage', 'Contributor roles', 'Announcements', 'Bot features']);
|
||||
// What needs doing comes first: the ticket panel isn't in Discord yet, triage and verification are off.
|
||||
expect(buttons(res.body, 'tickets')).toEqual(['/tickets/panel', '/tickets']);
|
||||
expect(res.body).toMatch(/<a class="btn primary sm" href="[^"]+\/tickets\/panel"[^>]*><span class="lbl">Publish panel<\/span>/);
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ describe('sidebar', () => {
|
||||
const labels = [...overview.matchAll(/<div class="nav-label">([^<]+)<\/div>/g)].map((m) => m[1]);
|
||||
expect(labels).toEqual(['Setup', 'Tools', 'Workspace']);
|
||||
const tools = [...overview.matchAll(/class="nav-item"[^>]*>.*?<span>([^<]+)<\/span>/g)].map((m) => m[1]);
|
||||
expect(tools).toEqual(['Overview', 'GitHub', 'Discord', 'Apps & repositories', 'Analytics', 'Repo status', 'Discord tickets', 'GitHub issues', 'AI triage', 'Contributor roles', 'Announcements', 'Members & permissions', 'Settings', 'Deployment', 'Server health']);
|
||||
expect(tools).toEqual(['Overview', 'GitHub', 'Discord', 'Apps & repositories', 'Analytics', 'Repo status', 'Discord tickets', 'GitHub issues', 'AI triage', 'Contributor roles', 'Announcements', 'Bot features', 'Members & permissions', 'Settings', 'Deployment', 'Server health']);
|
||||
const active: [string, string][] = [
|
||||
['/tickets', '/tickets'], ['/tickets/files', '/tickets'], ['/tickets/settings', '/tickets'],
|
||||
['/issues/sync', '/issues'], ['/issues/github', '/issues'], ['/repos', '/repos'], ['/repos/settings', '/repos'], ['/analytics', '/analytics'],
|
||||
|
||||
Reference in new issue
Block a user