From 39a72078686ebf20a0d12c19e7b0bf92460ebb72 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Mon, 16 Nov 2026 08:41:51 -0700 Subject: [PATCH] Logs: explain a server with no log files instead of "No log entries yet" A server with no Log tracer has no files for the Logs page to read, and every installer setup starts that way. The query failed with "invalidArguments", which the list showed as a bare word, followed by the generic "No log entries yet. When one is added, it shows up here." The Logs page now says the log is going to the system journal, gives the commands to follow it, and links to Tracers to add a Log tracer. Lists in general show the server's description of an error rather than its type, and no empty state while the list couldn't be read. Fixes #217 --- src/components/lists/DynamicList.tsx | 21 +++++++++-- src/components/lists/NoLogTracerNote.tsx | 47 ++++++++++++++++++++++++ src/components/lists/listError.test.ts | 33 +++++++++++++++++ src/components/lists/listError.ts | 24 ++++++++++++ src/i18n/en.json | 8 ++++ 5 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 src/components/lists/NoLogTracerNote.tsx create mode 100644 src/components/lists/listError.test.ts create mode 100644 src/components/lists/listError.ts diff --git a/src/components/lists/DynamicList.tsx b/src/components/lists/DynamicList.tsx index 38c3bb1..1c23609 100644 --- a/src/components/lists/DynamicList.tsx +++ b/src/components/lists/DynamicList.tsx @@ -9,6 +9,8 @@ import { pageAbout } from '@/help/texts'; import { ListEmptyState } from '@/components/lists/ListEmptyState'; +import { listErrorOf } from '@/components/lists/listError'; +import { NoLogTracerNote } from '@/components/lists/NoLogTracerNote'; import { PageHeader } from '@/components/common/PageHeader'; import { HelpPanel } from '@/help/HelpPanel'; import { ObjectHoverCard } from '@/features/hovercards/ObjectHoverCard'; @@ -418,6 +420,8 @@ export function DynamicList({ viewName }: DynamicListProps) { const [total, setTotal] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); + // inbuxa: the Logs list on a server with no log files (#217) + const [noLogTracer, setNoLogTracer] = useState(false); const displayNames = useCacheStore((s) => s.displayNames); const setDisplayNames = useCacheStore((s) => s.setDisplayNames); @@ -477,6 +481,7 @@ export function DynamicList({ viewName }: DynamicListProps) { const { obj, list } = resolved; setLoading(true); setError(null); + setNoLogTracer(false); try { const accountId = getAccountId(obj.objectName); @@ -509,7 +514,13 @@ export function DynamicList({ viewName }: DynamicListProps) { if (queryResp[0].includes('/error') || getResp[0].includes('/error')) { const errData = queryResp[0].includes('/error') ? queryResp[1] : getResp[1]; - setError(String((errData as Record).type ?? t('list.unknownError', 'Unknown error'))); + const listError = listErrorOf( + obj.objectName, + errData as Record, + t('list.unknownError', 'Unknown error'), + ); + if (listError.kind === 'noLogTracer') setNoLogTracer(true); + else setError(listError.message); return; } @@ -1354,6 +1365,8 @@ export function DynamicList({ viewName }: DynamicListProps) { )} + {noLogTracer && } + {hasMassActions && selectedIds.size === items.length && items.length > 0 && @@ -1388,7 +1401,9 @@ export function DynamicList({ viewName }: DynamicListProps) { ) : items.length === 0 ? ( -
{emptyState}
+ error || noLogTracer ? null : ( +
{emptyState}
+ ) ) : (
{hasMassActions && ( @@ -1477,7 +1492,7 @@ export function DynamicList({ viewName }: DynamicListProps) { colSpan={list.columns.length + (hasMassActions ? 1 : 0) + (hasRowCell ? 1 : 0)} className="px-3" > - {emptyState} + {error || noLogTracer ? null : emptyState} ) : ( diff --git a/src/components/lists/NoLogTracerNote.tsx b/src/components/lists/NoLogTracerNote.tsx new file mode 100644 index 0000000..d8d372c --- /dev/null +++ b/src/components/lists/NoLogTracerNote.tsx @@ -0,0 +1,47 @@ +/* + * SPDX-FileCopyrightText: 2026 Coffey Labs LLC + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { useTranslation } from 'react-i18next'; +import { Link } from 'react-router-dom'; + +const code = 'rounded bg-muted px-1 py-0.5 font-mono text-xs'; + +/** + * The Logs page on a server with no Log tracer (#217). The server's log is + * still there, in the system journal or the container's output, which this + * page can't read; it reads the files a Log tracer writes. The installer + * sets servers up that way, so this is the usual first sight of the page, + * not a fault. + */ +export function NoLogTracerNote() { + const { t } = useTranslation(); + return ( +
+

{t('logs.noTracerTitle', 'This server isn’t writing log files yet')}

+

+ {t( + 'logs.noTracerJournal', + 'This page reads log files, and the server is only sending its log to the system journal. On a server set up by the installer, you can follow it with:', + )} +

+
    +
  • + {t('logs.onHost', 'Installed on the host:')} journalctl -u inbuxa-server -f +
  • +
  • + {t('logs.inContainers', 'In containers, from the install folder:')}{' '} + docker compose logs -f server +
  • +
+

+ {t('logs.noTracerAdd', 'To read the log here, add a tracer of type Log with a folder the server can write to.')}{' '} + + {t('logs.openTracers', 'Open Tracers')} + +

+
+ ); +} diff --git a/src/components/lists/listError.test.ts b/src/components/lists/listError.test.ts new file mode 100644 index 0000000..d2d880c --- /dev/null +++ b/src/components/lists/listError.test.ts @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2026 Coffey Labs LLC + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { describe, expect, it } from 'vitest'; + +import { listErrorOf } from './listError'; + +const noTracer = { type: 'invalidArguments', description: 'No log tracers configured on the server' }; + +describe('listErrorOf', () => { + it('explains a server with no log files on the Logs list', () => { + expect(listErrorOf('x:Log', noTracer, 'Unknown error')).toEqual({ kind: 'noLogTracer' }); + }); + + it('shows the same error on any other list as the server worded it', () => { + expect(listErrorOf('x:Domain', noTracer, 'Unknown error')).toEqual({ + kind: 'message', + message: 'No log tracers configured on the server', + }); + }); + + it('prefers the description to the type, and falls back to the type', () => { + expect(listErrorOf('x:Log', { type: 'forbidden', description: 'Not allowed' }, '?')).toEqual({ + kind: 'message', + message: 'Not allowed', + }); + expect(listErrorOf('x:Log', { type: 'serverFail' }, '?')).toEqual({ kind: 'message', message: 'serverFail' }); + expect(listErrorOf('x:Log', {}, 'Unknown error')).toEqual({ kind: 'message', message: 'Unknown error' }); + }); +}); diff --git a/src/components/lists/listError.ts b/src/components/lists/listError.ts new file mode 100644 index 0000000..637782d --- /dev/null +++ b/src/components/lists/listError.ts @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: 2026 Coffey Labs LLC + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +/** What a list shows when the server turns its query down. */ +export type ListError = { kind: 'noLogTracer' } | { kind: 'message'; message: string }; + +/** + * Reads a JMAP method error for a list. The server's description says what + * went wrong; its type ("invalidArguments") only says which kind of thing, so + * it's the fallback. The Logs list has one error of its own: a server with no + * Log tracer has no log files to read (inbuxa-admin #217), which is how every + * installer setup starts, so that gets its own explanation instead. + */ +export function listErrorOf(objectName: string, err: Record, unknown: string): ListError { + const type = typeof err.type === 'string' ? err.type : ''; + const description = typeof err.description === 'string' ? err.description.trim() : ''; + if (objectName === 'x:Log' && type === 'invalidArguments' && /no log tracers/i.test(description)) { + return { kind: 'noLogTracer' }; + } + return { kind: 'message', message: description || type || unknown }; +} diff --git a/src/i18n/en.json b/src/i18n/en.json index 377131e..686da62 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -3062,5 +3062,13 @@ "staySignedIn": { "hint": "Stay signed in when the app or browser closes. Leave this off on a shared computer.", "label": "Stay signed in on this device" + }, + "logs": { + "noTracerTitle": "This server isn’t writing log files yet", + "noTracerJournal": "This page reads log files, and the server is only sending its log to the system journal. On a server set up by the installer, you can follow it with:", + "onHost": "Installed on the host:", + "inContainers": "In containers, from the install folder:", + "noTracerAdd": "To read the log here, add a tracer of type Log with a folder the server can write to.", + "openTracers": "Open Tracers" } } -- 2.54.0