Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
review: CSV file-picker accept, non-diverging channel summary, participant guard (#2160)
Adam Eivy7a7e22e78b99
diff --git a/client/src/components/timeline/ActivityImportPanel.jsx b/client/src/components/timeline/ActivityImportPanel.jsxindex a942171bff..582c2df38f 100644--- a/client/src/components/timeline/ActivityImportPanel.jsx+++ b/client/src/components/timeline/ActivityImportPanel.jsx@@ -16,7 +16,12 @@ import toast from '../ui/Toast';// help — JSX help text (where to get the export)// importFn — (file, { preview, silent }) => Promise<result>// renderPreview— (summary) => JSX for the preview details block-export default function ActivityImportPanel({ icon: Icon, title, noun, help, importFn, renderPreview, onImported }) {+// accept — file-input accept list; defaults to ZIP/JSON. A source that+// also takes another single-file shape (e.g. Discord's older+// `messages.csv`) widens it so the OS file picker doesn't hide+// a file the server would actually accept.+const DEFAULT_ACCEPT = '.zip,.json,application/zip,application/json';+export default function ActivityImportPanel({ icon: Icon, title, noun, help, importFn, renderPreview, onImported, accept = DEFAULT_ACCEPT }) {const [open, setOpen] = useState(false);const [file, setFile] = useState(null);const [busy, setBusy] = useState(false);@@ -88,7 +93,7 @@ export default function ActivityImportPanel({ icon: Icon, title, noun, help, imp<label className={`inline-flex items-center gap-2 rounded border border-port-border bg-port-bg px-3 py-1.5 text-sm text-gray-200 ${busy ? 'cursor-not-allowed opacity-40' : 'cursor-pointer hover:border-port-accent'}`}><Upload size={14} /><span>{file ? 'Change file' : 'Choose file'}</span>- <input type="file" accept=".zip,.json,application/zip,application/json" onChange={pickFile} disabled={busy} className="hidden" />+ <input type="file" accept={accept} onChange={pickFile} disabled={busy} className="hidden" /></label>{file && <span className="truncate text-xs text-gray-400">{file.name}</span>}</div>diff --git a/client/src/components/timeline/DiscordImportPanel.jsx b/client/src/components/timeline/DiscordImportPanel.jsxindex 2a1d657b38..6f4d464311 100644--- a/client/src/components/timeline/DiscordImportPanel.jsx+++ b/client/src/components/timeline/DiscordImportPanel.jsx@@ -13,6 +13,7 @@ export default function DiscordImportPanel({ onImported }) {noun="message"importFn={api.importDiscordHistory}onImported={onImported}+ accept=".zip,.json,.csv,application/zip,application/json,text/csv"help={(<>Request your <span className="text-gray-300">data package</span> from Discorddiff --git a/server/services/discordImport.js b/server/services/discordImport.jsindex f679016ddc..86b012a672 100644--- a/server/services/discordImport.js+++ b/server/services/discordImport.js@@ -138,7 +138,9 @@ export function discordMessageToCandidate(record, channel = null) {summary: shortSummary(summaryText),participants: normalizeParticipants((Array.isArray(channel?.recipients) ? channel.recipients : [])- .map((r) => (typeof r === 'string' ? { name: r } : { name: r?.username || r?.name })),+ .map((r) => (typeof r === 'string' ? r : r?.username || r?.name))+ .filter(Boolean)+ .map((name) => ({ name })),),dedupeKey: `discord:${messageId}`,metadata: {@@ -165,27 +167,28 @@ export function summarizeDiscordCandidates(candidates = []) {const list = Array.isArray(candidates) ? candidates : [];let earliest = null;let latest = null;- const channels = new Set();- const channelCounts = new Map();+ // Key BOTH the unique count and the top-channels tally by the same channel+ // identity (id when present, else the label) so they can't diverge — two+ // distinct channels that happen to share a display label stay two entries.+ // The display label is carried alongside the count for rendering.+ const channelStats = new Map(); // identity → { name, count }for (const c of list) {if (c.happenedAt) {if (!earliest || c.happenedAt < earliest) earliest = c.happenedAt;if (!latest || c.happenedAt > latest) latest = c.happenedAt;}- // Group by channel identity (id when present, else the label) so the unique- // count can't diverge from the top-channels tally below.const identity = c.metadata?.channelId || c.metadata?.channelName || c.title;- channels.add(identity);- const label = c.metadata?.channelName || c.title;- channelCounts.set(label, (channelCounts.get(label) || 0) + 1);+ const name = c.metadata?.channelName || c.title;+ const stat = channelStats.get(identity);+ if (stat) stat.count += 1;+ else channelStats.set(identity, { name, count: 1 });}- const topChannels = [...channelCounts.entries()]- .sort((a, b) => b[1] - a[1])- .slice(0, 10)- .map(([name, count]) => ({ name, count }));+ const topChannels = [...channelStats.values()]+ .sort((a, b) => b.count - a.count)+ .slice(0, 10);return {messages: list.length,- uniqueChannels: channels.size,+ uniqueChannels: channelStats.size,from: earliest,to: latest,topChannels,diff --git a/server/services/discordImport.test.js b/server/services/discordImport.test.jsindex ba13a0604a..dd382ac330 100644--- a/server/services/discordImport.test.js+++ b/server/services/discordImport.test.js@@ -185,6 +185,21 @@ describe('summarizeDiscordCandidates', () => {expect(s.to).toBe('2023-06-01T10:00:00.000Z');expect(s.topChannels[0]).toEqual({ name: 'Dev Server — #general', count: 2 });});+ it('keeps two same-labelled but distinct channels as two unique channels', () => {+ // Two guild channels named "#general" in different guilds → same display+ // label, different ids. uniqueChannels must not collapse them.+ const chA = { id: 'a', name: 'general', guild: { id: 'g1', name: 'Alpha' } };+ const chB = { id: 'b', name: 'general', guild: { id: 'g2', name: 'Beta' } };+ const candidates = discordActivityCandidates([+ { record: { ID: '1', Timestamp: '2023-01-01 00:00:00', Contents: 'x' }, channel: chA },+ { record: { ID: '2', Timestamp: '2023-01-02 00:00:00', Contents: 'y' }, channel: chB },+ ]);+ const s = summarizeDiscordCandidates(candidates);+ expect(s.uniqueChannels).toBe(2);+ // Labels differ here (guild-prefixed), so two top-channel rows appear.+ expect(s.topChannels).toHaveLength(2);+ });+it('handles an empty batch', () => {const s = summarizeDiscordCandidates([]);expect(s).toMatchObject({ messages: 0, uniqueChannels: 0, from: null, to: null });