feat(ui): display per-account status for multi-account Telegram
When multiple Telegram accounts are configured, the Connections UI now displays individual status cards for each account showing: - Bot username and account ID - Running/configured status - Last inbound message time - Per-account errors Falls back to the existing summary view for single-account configs. No changes needed to types (already added upstream).
This commit is contained in:
@@ -4,6 +4,7 @@ import { formatAgo } from "../format";
|
|||||||
import type {
|
import type {
|
||||||
DiscordStatus,
|
DiscordStatus,
|
||||||
IMessageStatus,
|
IMessageStatus,
|
||||||
|
ProviderAccountSnapshot,
|
||||||
ProvidersStatusSnapshot,
|
ProvidersStatusSnapshot,
|
||||||
SignalStatus,
|
SignalStatus,
|
||||||
SlackStatus,
|
SlackStatus,
|
||||||
@@ -132,6 +133,7 @@ export function renderConnections(props: ConnectionsProps) {
|
|||||||
slack,
|
slack,
|
||||||
signal,
|
signal,
|
||||||
imessage,
|
imessage,
|
||||||
|
providerAccounts: props.snapshot?.providerAccounts ?? null,
|
||||||
}),
|
}),
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
@@ -216,6 +218,7 @@ function renderProvider(
|
|||||||
slack?: SlackStatus | null;
|
slack?: SlackStatus | null;
|
||||||
signal?: SignalStatus | null;
|
signal?: SignalStatus | null;
|
||||||
imessage?: IMessageStatus | null;
|
imessage?: IMessageStatus | null;
|
||||||
|
providerAccounts?: Record<string, ProviderAccountSnapshot[]> | null;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@@ -321,11 +324,53 @@ function renderProvider(
|
|||||||
}
|
}
|
||||||
case "telegram": {
|
case "telegram": {
|
||||||
const telegram = data.telegram;
|
const telegram = data.telegram;
|
||||||
|
const telegramAccounts = data.providerAccounts?.telegram ?? [];
|
||||||
|
const hasMultipleAccounts = telegramAccounts.length > 1;
|
||||||
|
|
||||||
|
const renderAccountCard = (account: ProviderAccountSnapshot) => {
|
||||||
|
const probe = account.probe as { bot?: { username?: string } } | undefined;
|
||||||
|
const botUsername = probe?.bot?.username;
|
||||||
|
const label = account.name || account.accountId;
|
||||||
|
return html`
|
||||||
|
<div style="border: 1px solid var(--border); border-radius: 6px; padding: 12px; margin-bottom: 8px;">
|
||||||
|
<div style="font-weight: 500; margin-bottom: 8px;">
|
||||||
|
${botUsername ? `@${botUsername}` : label}
|
||||||
|
<span class="muted" style="font-weight: normal;">(${account.accountId})</span>
|
||||||
|
</div>
|
||||||
|
<div class="status-list" style="font-size: 13px;">
|
||||||
|
<div>
|
||||||
|
<span class="label">Running</span>
|
||||||
|
<span>${account.running ? "Yes" : "No"}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span class="label">Configured</span>
|
||||||
|
<span>${account.configured ? "Yes" : "No"}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span class="label">Last inbound</span>
|
||||||
|
<span>${account.lastInboundAt ? formatAgo(account.lastInboundAt) : "n/a"}</span>
|
||||||
|
</div>
|
||||||
|
${account.lastError ? html`
|
||||||
|
<div style="color: var(--danger); margin-top: 4px;">
|
||||||
|
${account.lastError}
|
||||||
|
</div>
|
||||||
|
` : nothing}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
};
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-title">Telegram</div>
|
<div class="card-title">Telegram</div>
|
||||||
<div class="card-sub">Bot token and delivery options.</div>
|
<div class="card-sub">Bot token and delivery options.</div>
|
||||||
|
|
||||||
|
${hasMultipleAccounts ? html`
|
||||||
|
<div style="margin-top: 16px; margin-bottom: 8px;">
|
||||||
|
<div style="font-weight: 500; margin-bottom: 8px; color: var(--muted);">Accounts (${telegramAccounts.length})</div>
|
||||||
|
${telegramAccounts.map((account) => renderAccountCard(account))}
|
||||||
|
</div>
|
||||||
|
` : html`
|
||||||
<div class="status-list" style="margin-top: 16px;">
|
<div class="status-list" style="margin-top: 16px;">
|
||||||
<div>
|
<div>
|
||||||
<span class="label">Configured</span>
|
<span class="label">Configured</span>
|
||||||
@@ -348,6 +393,7 @@ function renderProvider(
|
|||||||
<span>${telegram?.lastProbeAt ? formatAgo(telegram.lastProbeAt) : "n/a"}</span>
|
<span>${telegram?.lastProbeAt ? formatAgo(telegram.lastProbeAt) : "n/a"}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
`}
|
||||||
|
|
||||||
${telegram?.lastError
|
${telegram?.lastError
|
||||||
? html`<div class="callout danger" style="margin-top: 12px;">
|
? html`<div class="callout danger" style="margin-top: 12px;">
|
||||||
|
|||||||
Reference in New Issue
Block a user