Logs: explain a server with no log files instead of "No log entries yet" #220

Merged
jcoffey-dev merged 1 commits from fix/217-logs-empty-state into main 2026-11-16 15:56:01 +00:00
5 changed files with 130 additions and 3 deletions

No files matched your search

+18 -3
View File
@@ -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<number | null>(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(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<string, unknown>).type ?? t('list.unknownError', 'Unknown error')));
const listError = listErrorOf(
obj.objectName,
errData as Record<string, unknown>,
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) {
</div>
)}
{noLogTracer && <NoLogTracerNote />}
{hasMassActions &&
selectedIds.size === items.length &&
items.length > 0 &&
@@ -1388,7 +1401,9 @@ export function DynamicList({ viewName }: DynamicListProps) {
<Loader2 className="mx-auto h-6 w-6 animate-spin" />
</div>
) : items.length === 0 ? (
<div className="rounded-xl border bg-card shadow-soft">{emptyState}</div>
error || noLogTracer ? null : (
<div className="rounded-xl border bg-card shadow-soft">{emptyState}</div>
)
) : (
<div className="space-y-3">
{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}
</td>
</tr>
) : (
+47
View File
@@ -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 (
<div role="status" className="space-y-3 rounded-md border bg-muted/40 p-4 text-sm">
<p className="font-medium">{t('logs.noTracerTitle', 'This server isn’t writing log files yet')}</p>
<p className="text-muted-foreground">
{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:',
)}
</p>
<ul className="space-y-1 text-muted-foreground">
<li>
{t('logs.onHost', 'Installed on the host:')} <code className={code}>journalctl -u inbuxa-server -f</code>
</li>
<li>
{t('logs.inContainers', 'In containers, from the install folder:')}{' '}
<code className={code}>docker compose logs -f server</code>
</li>
</ul>
<p className="text-muted-foreground">
{t('logs.noTracerAdd', 'To read the log here, add a tracer of type Log with a folder the server can write to.')}{' '}
<Link to="/Settings/x:Tracer" className="underline underline-offset-2 hover:text-foreground">
{t('logs.openTracers', 'Open Tracers')}
</Link>
</p>
</div>
);
}
+33
View File
@@ -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' });
});
});
+24
View File
@@ -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<string, unknown>, 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 };
}
+8
View File
@@ -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"
}
}