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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(ui): call the user by the learned name and list scheduled routines in the sidebar
rubenluetke10-beep949193d210e8
diff --git a/jarvis/brain/identity_card.py b/jarvis/brain/identity_card.pyindex 9d16da26bc..37e278c84f 100644--- a/jarvis/brain/identity_card.py+++ b/jarvis/brain/identity_card.py@@ -72,6 +72,7 @@ __all__ = ["distill_identity_card","identity_card_block","identity_card_text",+ "learned_user_name","render_identity_block","reset_identity_card_cache",]@@ -413,6 +414,53 @@ def _vault_profile_path(config: Any) -> Path | None:return root / "entities" / f"{_user_entity_slug(config)}.md"+_NAME_FACT_RE = re.compile(r"^\s*[-*]\s*name\s*:\s*(.+?)\s*$", re.IGNORECASE | re.MULTILINE)+_ALIASES_RE = re.compile(r"^aliases\s*:\s*\[([^\]]*)\]", re.IGNORECASE | re.MULTILINE)+_TITLE_RE = re.compile(r"^#\s+(.+?)\s*$", re.MULTILINE)+_GENERIC_NAMES = frozenset({"user", "the user", "me", "owner"})+++def _plausible_name(raw: str) -> str | None:+ name = raw.strip().strip("\"'").strip()+ if not name or len(name) > 40 or name.casefold() in _GENERIC_NAMES:+ return None+ if not any(ch.isalpha() for ch in name) or re.search(r"[\d@/\\<>|{}]", name):+ return None+ return name+++def learned_user_name(config: Any = None) -> str | None:+ """The user's name as the memory has learned it, or None.++ Read from the user's own entity page in the wiki vault — a ``- Name:``+ fact first, then the page's first alias, then its title. This is what the+ assistant has picked up over time; ``USER.md`` stays the place a name is+ *set*, and callers prefer that one. A missing vault, a page that only+ says "User", or anything that does not look like a name yields None —+ never a guess.+ """+ path = _vault_profile_path(config)+ if path is None:+ return None+ text = _read_text(path)+ if not text.strip():+ return None+ match = _NAME_FACT_RE.search(_strip_frontmatter(text))+ if match and (name := _plausible_name(match.group(1))):+ return name+ front = _FRONTMATTER_RE.match(text)+ if front:+ aliases = _ALIASES_RE.search(front.group(0))+ if aliases:+ first = aliases.group(1).split(",")[0]+ if name := _plausible_name(first):+ return name+ heading = _TITLE_RE.search(_strip_frontmatter(text))+ if heading:+ return _plausible_name(heading.group(1))+ return None++def _core_memory_path(config: Any) -> Path | None:# ``[wiki_context].core_memory_path`` is an optional relocation seam for# hosts that keep state outside the data directory (and for tests). Absentdiff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsxindex f11abbf6df..2d53044556 100644--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx@@ -23,6 +23,7 @@ import { cn } from "@/lib/utils";import { lazy, Suspense, useMemo, useState, type ReactNode } from "react";import { useT } from "@/i18n";import { RecentChats } from "@/components/home/RecentChats";+import { SidebarScheduled } from "@/components/layout/SidebarScheduled";import { useHomeStore } from "@/store/home";import { IdeProjectTree } from "@/components/agentic/IdeProjectTree";import { useIdeProjectsStore } from "@/store/ideProjects";@@ -552,7 +553,7 @@ export function Sidebar({</nav>}{!railed && (onIdeSection? <IdeProjectTree />- : <section className="mt-6 px-2 pb-3" aria-label={t("sidebar.recent_chats")}><RecentChats /></section>)}+ : <><SidebarScheduled /><section className="mt-5 px-2 pb-3" aria-label={t("sidebar.recent_chats")}><RecentChats /></section></>)}</div>{/* The footer is one button now, not a popup: it opens the Settings hubdiff --git a/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.test.ts b/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.test.tsnew file mode 100644index 0000000000..8848c12e78--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.test.ts@@ -0,0 +1,42 @@+import { describe, expect, it } from "vitest";++import { routineTitle, upcomingRoutines, SIDEBAR_SCHEDULED_MAX } from "./SidebarScheduled";+import type { TaskSummary } from "@/views/automations/automationsModel";++function task(id: string, next: number, extra: Partial<TaskSummary> = {}): TaskSummary {+ return {+ id,+ title: id,+ state: "scheduled",+ trigger_type: "calendar",+ due_at_ns: next,+ next_due_at_ns: next,+ created_at_ns: 1,+ started_at_ns: null,+ finished_at_ns: null,+ attempts: 0,+ last_error: null,+ ...extra,+ } as TaskSummary;+}++describe("SidebarScheduled", () => {+ it("names the job, not the agent that owns it", () => {+ expect(routineTitle("[agent:GitHub Issue sortieren.] Daily GitHub issue triage")).toBe(+ "Daily GitHub issue triage",+ );+ expect(routineTitle("Morning brief")).toBe("Morning brief");+ });++ it("lists the soonest runs first, skips finished and paused ones, and stops at the cap", () => {+ const rows = upcomingRoutines([+ task("late", 400),+ task("done", 100, { state: "completed" }),+ task("paused", 50, { state: "paused" }),+ task("soon", 200),+ task("mid", 300),+ task("later", 500),+ ]);+ expect(rows.map((r) => r.id)).toEqual(["soon", "mid", "late"].slice(0, SIDEBAR_SCHEDULED_MAX));+ });+});diff --git a/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.tsx b/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.tsxnew file mode 100644index 0000000000..20137242dc--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/layout/SidebarScheduled.tsx@@ -0,0 +1,95 @@+import { useMemo } from "react";+import { useQuery } from "@tanstack/react-query";+import { Clock } from "lucide-react";++import { fetchTasks, TASKS_QUERY_KEY } from "@/hooks/useAutomations";+import { useT } from "@/i18n";+import { useEventStore } from "@/store/events";+import {+ localTimeHHMM,+ selectAutomations,+ selectSchedules,+ type TaskSummary,+} from "@/views/automations/automationsModel";++/** How many routines the sidebar names before the Automations page takes over. */+export const SIDEBAR_SCHEDULED_MAX = 3;++/**+ * "Scheduled" in the sidebar — the routines that run next, between the+ * sections and the chat history, the way the Claude app lists its scheduled+ * tasks there.+ *+ * Real rows only: the user's recurring automations and waiting one-off+ * schedules from `/api/tasks`, soonest first. With nothing scheduled (or no+ * answer yet) the section is absent — an empty heading would be filler.+ * The list shares the Automations page's query key, read at a slow cadence+ * here because the sidebar is on screen all day.+ */+export function SidebarScheduled() {+ const t = useT();+ const setActive = useEventStore((s) => s.setActiveSection);+ const { data } = useQuery({+ queryKey: TASKS_QUERY_KEY,+ queryFn: fetchTasks,+ refetchInterval: 60_000,+ staleTime: 30_000,+ retry: false,+ });+ const upcoming = useMemo(() => upcomingRoutines(data?.tasks ?? []), [data]);+ if (upcoming.length === 0) return null;++ return (+ <section className="mt-5 px-2" aria-label={t("sidebar.scheduled")} data-testid="sidebar-scheduled">+ <h2 className="px-3 pb-1.5 text-sm text-muted-foreground">{t("sidebar.scheduled")}</h2>+ <ul className="space-y-px">+ {upcoming.map((task) => {+ const title = routineTitle(task.title);+ const next = nextRunNs(task);+ return (+ <li key={task.id}>+ <button+ type="button"+ onClick={() => setActive("tasks")}+ title={title}+ data-testid="sidebar-scheduled-row"+ className="flex h-8 w-full items-center gap-3 rounded-lg px-3 text-left text-base text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <Clock aria-hidden strokeWidth={1.75} className="h-[18px] w-[18px] shrink-0" />+ <span className="min-w-0 flex-1 truncate">{title}</span>+ {next !== null && (+ <span className="shrink-0 text-xs tabular-nums text-muted-foreground">{whenLabel(next)}</span>+ )}+ </button>+ </li>+ );+ })}+ </ul>+ </section>+ );+}++function nextRunNs(task: TaskSummary): number | null {+ const ns = task.next_due_at_ns ?? task.due_at_ns;+ return typeof ns === "number" && Number.isFinite(ns) ? ns : null;+}++/** Recurring automations and waiting one-offs, soonest run first. */+export function upcomingRoutines(tasks: TaskSummary[]): TaskSummary[] {+ return [...selectAutomations(tasks), ...selectSchedules(tasks)]+ .filter((task) => task.state !== "paused")+ .sort((a, b) => (nextRunNs(a) ?? Number.MAX_SAFE_INTEGER) - (nextRunNs(b) ?? Number.MAX_SAFE_INTEGER))+ .slice(0, SIDEBAR_SCHEDULED_MAX);+}++/** An agent's routine carries its owner as a "[agent:Name] " prefix; the row shows the job. */+export function routineTitle(title: string): string {+ return title.replace(/^\s*\[agent:[^\]]*\]\s*/i, "").trim() || title.trim();+}++/** The clock for today, a short weekday for anything later. */+function whenLabel(ns: number, now: Date = new Date()): string {+ const at = new Date(ns / 1e6);+ if (at.toDateString() === now.toDateString()) return localTimeHHMM(ns);+ return at.toLocaleDateString(undefined, { weekday: "short" });+}diff --git a/jarvis/ui/web/frontend/src/hooks/useUserName.ts b/jarvis/ui/web/frontend/src/hooks/useUserName.tsindex 1964264cbd..1de39e4cbb 100644--- a/jarvis/ui/web/frontend/src/hooks/useUserName.ts+++ b/jarvis/ui/web/frontend/src/hooks/useUserName.ts@@ -1,12 +1,12 @@import { useQuery } from "@tanstack/react-query";interface ProfileUser {- user?: { name?: string | null } | null;+ user?: { name?: string | null; display_name?: string | null } | null;}/**- * The person's own name, as the Profile section knows it — for the front- * page greeting. Same query key as the Profile view, so the two share one+ * The person's own name, as the Profile section knows it or the memory has+ * learned it — for the front page greeting and the sidebar footer. Same query key as the Profile view, so the two share one* fetch and one cache. Null while loading, on a headless host, or when the* profile simply has no name yet; the greeting then drops the name rather* than inventing one.@@ -22,6 +22,8 @@ export function useUserName(): string | null {staleTime: 60_000,retry: false,});- const name = data?.user?.name;+ // The name set in the Profile, else the one the memory has learned+ // (`display_name`, from the user's wiki entity page — profile_routes.py).+ const name = data?.user?.name || data?.user?.display_name;return typeof name === "string" && name.trim() ? name.trim() : null;}diff --git a/jarvis/ui/web/profile_routes.py b/jarvis/ui/web/profile_routes.pyindex 0711d6ee3f..0acd44fe2d 100644--- a/jarvis/ui/web/profile_routes.py+++ b/jarvis/ui/web/profile_routes.py@@ -190,6 +190,16 @@ def _candidate_to_dict(cand: Any, reason: str, idx: int) -> dict[str, Any]:# ----------------------------------------------------------------------+def _learned_name(request: Request) -> str | None:+ try:+ from jarvis.brain.identity_card import learned_user_name # noqa: PLC0415++ return learned_user_name(getattr(request.app.state, "config", None))+ except Exception: # noqa: BLE001 — no learned name is the honest answer+ log.debug("learned user name unavailable", exc_info=True)+ return None++@router.get("")async def get_profile(request: Request) -> dict[str, Any]:"""Returns the complete snapshot for the profile view.@@ -224,6 +234,11 @@ async def get_profile(request: Request) -> dict[str, Any]:return {"user": {"name": profile.name,+ # What to CALL the person: the name set in USER.md, else the one+ # the memory has learned (the user's wiki entity page). Kept apart+ # from `name` so the Profile editor never shows a learned name as+ # if it had been saved.+ "display_name": profile.name or _learned_name(request),"meta": profile.meta,"path": profile.path.name,},diff --git a/tests/unit/brain/test_identity_card.py b/tests/unit/brain/test_identity_card.pyindex 9b75d8ba1a..1fa0618094 100644--- a/tests/unit/brain/test_identity_card.py+++ b/tests/unit/brain/test_identity_card.py@@ -333,3 +333,49 @@ def test_accessors_never_raise_on_a_hostile_config() -> None:assert ic.identity_card_block(Hostile()) == ""ic.reset_identity_card_cache()assert isinstance(ic.identity_card_text(Hostile()), str)+++# ---------------------------------------------------------------------------+# The learned name — what the front page calls the person when USER.md is empty+# ---------------------------------------------------------------------------+++class _SluggedConfig(_FakeConfig):+ def __init__(self, *, vault_root: Path, slug: str) -> None:+ super().__init__(vault_root=vault_root)++ class _Rollup:+ user_entity_slug = slug++ class _Wiki:+ session_rollup = _Rollup()++ class _Memory:+ wiki = _Wiki()++ self.memory = _Memory()+++def test_learned_name_prefers_a_name_fact(tmp_path: Path) -> None:+ vault = tmp_path / "vault"+ _write_vault_profile(vault, "nova", "---\naliases: [Nova]\n---\n# Nova\n\n- Name: Nova User\n")+ assert ic.learned_user_name(_SluggedConfig(vault_root=vault, slug="nova")) == "Nova User"+++def test_learned_name_falls_back_to_alias_then_title(tmp_path: Path) -> None:+ vault = tmp_path / "vault"+ page = "---\naliases: [Nova]\n---\n# Someone\n\n## Facts\n- Likes tea.\n"+ _write_vault_profile(vault, "nova", page)+ assert ic.learned_user_name(_SluggedConfig(vault_root=vault, slug="nova")) == "Nova"+ _write_vault_profile(vault, "nova", "# Nova\n\nNo frontmatter here.\n")+ assert ic.learned_user_name(_SluggedConfig(vault_root=vault, slug="nova")) == "Nova"+++def test_learned_name_never_guesses(tmp_path: Path) -> None:+ vault = tmp_path / "vault"+ # No page at all, a generic "User" page, and something that is no name.+ assert ic.learned_user_name(_SluggedConfig(vault_root=vault, slug="nova")) is None+ _write_vault_profile(vault, "user", "# User\n")+ assert ic.learned_user_name(_FakeConfig(vault_root=vault)) is None+ _write_vault_profile(vault, "nova", "# [email protected]\n")+ assert ic.learned_user_name(_SluggedConfig(vault_root=vault, slug="nova")) is None