Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(profile): polish after a live check in the dev window

rubenluetke10-beep49b247fe9a3d
diff --git a/jarvis/ui/web/frontend/src/views/ProfileView.tsx b/jarvis/ui/web/frontend/src/views/ProfileView.tsx
index 535707d0ef..ac6c5f3641 100644
--- a/jarvis/ui/web/frontend/src/views/ProfileView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ProfileView.tsx
@@ -24,7 +24,7 @@
* views need it: the sub-page renders it, and the main page parses its audit
* trail for provenance and its Do Not Record list.
*/
-import { useMemo, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { AlertTriangle, ArrowLeft, RefreshCw, UserCircle2 } from "lucide-react";
@@ -43,11 +43,17 @@ import { PAGE_GROUPS } from "@/views/profile/ledger";
import { parseObservations } from "@/views/profile/provenance";
/** The reading column: wide enough for a row, narrow enough to scan. */
-const COLUMN = "mx-auto w-full max-w-[880px]";
+const COLUMN = "mx-auto w-full max-w-[760px]";
export function ProfileView() {
const t = useT();
const [showSource, setShowSource] = useState(false);
+ // Switching between the page and the file sub-page starts at the top; the
+ // scroll position of a long page would otherwise hide the back link.
+ const scrollRef = useRef<HTMLDivElement | null>(null);
+ useEffect(() => {
+ scrollRef.current?.scrollTo?.({ top: 0 });
+ }, [showSource]);
const { data, isLoading, error, refetch, isRefetching } = useQuery<ProfileResponse, Error>({
queryKey: ["profile"],
@@ -63,7 +69,10 @@ export function ProfileView() {
const meta = (data?.user.meta ?? {}) as Record<string, unknown>;
return (
- <div className="flex h-full flex-col overflow-y-auto bg-background px-8 pb-10 scrollbar-jarvis">
+ <div
+ ref={scrollRef}
+ className="flex h-full flex-col overflow-y-auto bg-background px-8 pb-10 scrollbar-jarvis"
+ >
<div className={COLUMN}>
<PageHeader
icon={<UserCircle2 />}
diff --git a/jarvis/ui/web/frontend/src/views/profile/FieldGroup.tsx b/jarvis/ui/web/frontend/src/views/profile/FieldGroup.tsx
index ed60d8b55d..4ea54ccdfb 100644
--- a/jarvis/ui/web/frontend/src/views/profile/FieldGroup.tsx
+++ b/jarvis/ui/web/frontend/src/views/profile/FieldGroup.tsx
@@ -69,9 +69,6 @@ export function FieldGroup({
{chips.length > 0 && (
<div data-testid={`missing-${id}`} className="px-5 py-4">
- {known.length === 0 && !addingRef && (
- <p className="mb-3 text-base text-muted-foreground">{t("profile_view.group_empty")}</p>
- )}
<div className="flex flex-wrap items-center gap-1.5">
<span className="mr-1 text-sm text-muted-foreground">{t("profile_view.add_label")}</span>
{chips.map((ref) => (
diff --git a/jarvis/ui/web/frontend/src/views/profile/FieldRow.tsx b/jarvis/ui/web/frontend/src/views/profile/FieldRow.tsx
index 46b06e2805..6c1cc8eaaa 100644
--- a/jarvis/ui/web/frontend/src/views/profile/FieldRow.tsx
+++ b/jarvis/ui/web/frontend/src/views/profile/FieldRow.tsx
@@ -18,16 +18,18 @@ import { Check, Pencil, Plus, Quote, X } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
-import { useT } from "@/i18n";
+import { useT, useUiLanguage } from "@/i18n";
import { cn } from "@/lib/utils";
import { useEventStore } from "@/store/events";
import { useFieldEdit, type FieldOp } from "@/views/profile/api";
import {
CHOICE_FIELDS,
+ LANGUAGE_FIELDS,
LIST_SUGGESTIONS,
SCALE_FIELDS,
fieldKind,
isEmptyValue,
+ languageName,
scaleValue,
type ClusterId,
} from "@/views/profile/ledger";
@@ -42,11 +44,23 @@ export function readableDate(iso: string): string {
return d.toLocaleDateString(undefined, { day: "numeric", month: "short", year: "numeric" });
}
-/** The label a choice value shows, or the raw value when it is off-vocabulary. */
-function choiceLabel(t: T, field: string, value: string): string {
- return CHOICE_FIELDS[field]?.includes(value) ? t(`profile_view.choices.${field}.${value}`) : value;
+/**
+ * What a stored value shows: a choice by its label, a language code by its
+ * name, anything else (including off-vocabulary curator text) verbatim.
+ */
+function choiceLabel(t: T, field: string, value: string, ui = "en"): string {
+ if (CHOICE_FIELDS[field]?.includes(value) || LIST_CHOICE_FIELDS.has(field)) {
+ const key = `profile_view.choices.${field}.${value}`;
+ const label = t(key);
+ if (label !== key) return label;
+ }
+ if (LANGUAGE_FIELDS.has(field)) return languageName(value, ui);
+ return value;
}
+/** List fields whose suggested items carry translated labels. */
+const LIST_CHOICE_FIELDS: ReadonlySet<string> = new Set(Object.keys(LIST_SUGGESTIONS));
+
function ScaleMeter({ value }: { value: number }) {
return (
<span aria-hidden className="flex items-center gap-0.5">
@@ -63,6 +77,7 @@ function ScaleMeter({ value }: { value: number }) {
/** The resting value, right-aligned in the row. */
function ValueView({ field, value }: { field: string; value: unknown }) {
const t = useT();
+ const ui = useUiLanguage();
const kind = fieldKind(field);
if (kind === "list") {
@@ -73,7 +88,7 @@ function ValueView({ field, value }: { field: string; value: unknown }) {
key={String(item)}
className="rounded-md border border-border bg-secondary px-2 py-0.5 text-sm text-foreground"
>
- {choiceLabel(t, field, String(item))}
+ {choiceLabel(t, field, String(item), ui)}
</span>
))}
</span>
@@ -99,7 +114,7 @@ function ValueView({ field, value }: { field: string; value: unknown }) {
}
return (
<span className="text-right text-base text-foreground [overflow-wrap:anywhere]">
- {choiceLabel(t, field, String(value))}
+ {choiceLabel(t, field, String(value), ui)}
</span>
);
}
@@ -331,37 +346,41 @@ export function FieldRow({
return (
<div data-testid={`field-${field}`} className="bg-secondary/40 px-5 py-4">
- <div className="flex items-baseline justify-between gap-4">
- <p className="text-base font-medium text-foreground-strong">{label}</p>
- {scaleHint && <p className="text-sm text-muted-foreground">{scaleHint}</p>}
- </div>
- <div className="mt-3">{editor}</div>
- <div className="mt-3 flex items-center justify-between gap-2">
- {!empty ? (
- <Button
- type="button"
- size="sm"
- variant="ghost"
- className="text-muted-foreground hover:text-destructive"
- disabled={busy}
- onClick={() => mutate("clear")}
- >
- {t("profile_view.field_clear")}
- </Button>
- ) : (
- <span />
- )}
- <span className="flex items-center gap-2">
+ <div className="flex items-start justify-between gap-4">
+ <div className="min-w-0">
+ <p className="text-base font-medium text-foreground-strong">{label}</p>
+ {scaleHint && <p className="mt-0.5 text-sm text-muted-foreground">{scaleHint}</p>}
+ </div>
+ <span className="-my-1 flex shrink-0 items-center gap-1">
+ {!empty && (
+ <Button
+ type="button"
+ size="sm"
+ variant="ghost"
+ className="text-muted-foreground hover:text-destructive"
+ disabled={busy}
+ onClick={() => mutate("clear")}
+ >
+ {t("profile_view.field_clear")}
+ </Button>
+ )}
<Button type="button" size="sm" variant="ghost" disabled={busy} onClick={close}>
{typed ? t("profile_view.raw_cancel") : t("profile_view.field_done")}
</Button>
- {typed && (
+ </span>
+ </div>
+ <div className="mt-3">
+ {typed ? (
+ <div className="flex items-center gap-2">
+ {editor}
<Button type="button" size="sm" disabled={busy} onClick={saveText}>
<Check aria-hidden />
{t("profile_view.raw_save")}
</Button>
- )}
- </span>
+ </div>
+ ) : (
+ editor
+ )}
</div>
</div>
);
diff --git a/jarvis/ui/web/frontend/src/views/profile/ProfileHero.tsx b/jarvis/ui/web/frontend/src/views/profile/ProfileHero.tsx
index bdd97f52f8..d9f92d27c4 100644
--- a/jarvis/ui/web/frontend/src/views/profile/ProfileHero.tsx
+++ b/jarvis/ui/web/frontend/src/views/profile/ProfileHero.tsx
@@ -21,7 +21,13 @@ import { useT, useUiLanguage } from "@/i18n";
import { useEventStore } from "@/store/events";
import { AvatarButton } from "@/views/profile/AvatarButton";
import { clusterDataOf, useFieldEdit, type ProfileResponse } from "@/views/profile/api";
-import { TOTAL_FIELDS, countFilled, daysSince, isEmptyValue } from "@/views/profile/ledger";
+import {
+ TOTAL_FIELDS,
+ countFilled,
+ daysSince,
+ isEmptyValue,
+ languageName,
+} from "@/views/profile/ledger";
/** A date stamp as a short local date; null when unparseable. */
function shortDate(value: unknown): string | null {
@@ -31,16 +37,6 @@ function shortDate(value: unknown): string | null {
return d.toLocaleDateString(undefined, { day: "numeric", month: "short", year: "numeric" });
}
-/** "de" → "German" in the interface language; the code itself when unknown. */
-function languageName(code: string, ui: string): string {
- try {
- return new Intl.DisplayNames([ui], { type: "language" }).of(code) ?? code;
- } catch {
- // Intl rejects malformed tags; the raw value is the honest fallback.
- return code;
- }
-}
-
function Stat({ label, value, sub }: { label: string; value: string | null; sub?: string | null }) {
return (
<div className="min-w-0 px-5 py-4">
@@ -167,7 +163,7 @@ export function ProfileHero({
<NameForm onDone={name ? () => setRenaming(false) : undefined} />
</>
)}
- {facts.length > 0 && !renaming && (
+ {facts.length > 0 && name && !renaming && (
<p className="mt-1 truncate text-base text-muted-foreground">{facts.join(" · ")}</p>
)}
</div>
diff --git a/jarvis/ui/web/frontend/src/views/profile/ledger.ts b/jarvis/ui/web/frontend/src/views/profile/ledger.ts
index e1224ecc50..ce4885db4e 100644
--- a/jarvis/ui/web/frontend/src/views/profile/ledger.ts
+++ b/jarvis/ui/web/frontend/src/views/profile/ledger.ts
@@ -217,3 +217,18 @@ export function daysSince(iso: unknown, now: Date = new Date()): number | null {
if (Number.isNaN(then.getTime())) return null;
return Math.max(0, Math.floor((now.getTime() - then.getTime()) / 86_400_000));
}
+
+/** Fields whose values are language codes ("de"), shown by name ("German"). */
+export const LANGUAGE_FIELDS: ReadonlySet<string> = new Set(["primary_language", "languages"]);
+
+/** "de" -> "German" in the interface language; the value itself when unknown. */
+export function languageName(code: string, ui: string): string {
+ const tag = code.trim();
+ if (!/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/i.test(tag)) return code;
+ try {
+ return new Intl.DisplayNames([ui], { type: "language" }).of(tag) ?? code;
+ } catch {
+ // Intl rejects some well-formed but unknown tags; the raw value is honest.
+ return code;
+ }
+}