AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(ai): fold Agent thinking and tools into one collapsible card
tianma-if3890dfc00bae
diff --git a/apps/web/src/components/CompanionChat.tsx b/apps/web/src/components/CompanionChat.tsxindex e10f6495..9dd5edee 100644--- a/apps/web/src/components/CompanionChat.tsx+++ b/apps/web/src/components/CompanionChat.tsx@@ -10,7 +10,6 @@ import { api, ApiRequestError } from "@/lib/api";import { companionLocale } from "@/lib/companion-locale";import { CompanionActionCard } from "./CompanionActionCard";import { CompanionNoteText } from "./CompanionNoteText";-import { CompanionProcess } from "./CompanionProcess";import { CompanionQuestionForm } from "./CompanionQuestionForm";import { CompanionRunTimeline } from "./CompanionRunTimeline";@@ -310,9 +309,15 @@ export function CompanionChat({})}</ul>) : null}- <CompanionProcess text={turn.process ?? ""} expanded={turn.status === "running" && !turn.response} />- <CompanionRunTimeline tools={turn.tools ?? []} todos={turn.todos ?? []} busy={busy || Boolean(running)}- onOpenNote={onOpenNote} onNotesChanged={onNotesChanged} />+ <CompanionRunTimeline+ process={turn.process ?? ""}+ tools={turn.tools ?? []}+ todos={turn.todos ?? []}+ expanded={turn.status === "running"}+ busy={busy || Boolean(running)}+ onOpenNote={onOpenNote}+ onNotesChanged={onNotesChanged}+ />{turn.response ? <CompanionNoteText text={turn.response} sources={turn.sources} onOpenNote={onOpenNote} /> : null}{turn.status === "interrupted" && turn.questions?.length && !running ? (<CompanionQuestionForm questions={turn.questions} busy={busy} onSubmit={answers => resume(turn, answers)} />diff --git a/apps/web/src/components/CompanionProcess.tsx b/apps/web/src/components/CompanionProcess.tsxdeleted file mode 100644index 37be9061..00000000--- a/apps/web/src/components/CompanionProcess.tsx+++ /dev/null@@ -1,27 +0,0 @@-import { useState } from "react";-import { useTranslation } from "react-i18next";-import { ChevronDown } from "lucide-react";--export function CompanionProcess({ text, expanded }: { text: string; expanded?: boolean }) {- const { t } = useTranslation();- const [open, setOpen] = useState(Boolean(expanded));- if (!text.trim()) return null;- return (- <div className="rounded-md border border-slate-200/80 bg-slate-50/80">- <button- type="button"- className="flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px] font-medium text-slate-500"- aria-expanded={open}- onClick={() => setOpen(value => !value)}- >- <ChevronDown className={`h-3 w-3 shrink-0 transition-transform ${open ? "rotate-0" : "-rotate-90"}`} />- {t("companion.process")}- </button>- {open ? (- <p className="whitespace-pre-wrap break-words border-t border-slate-200/70 px-2.5 py-2 text-xs leading-relaxed text-slate-500">- {text.trim()}- </p>- ) : null}- </div>- );-}diff --git a/apps/web/src/components/CompanionRunTimeline.tsx b/apps/web/src/components/CompanionRunTimeline.tsxindex 430cacfa..9040f807 100644--- a/apps/web/src/components/CompanionRunTimeline.tsx+++ b/apps/web/src/components/CompanionRunTimeline.tsx@@ -1,11 +1,11 @@import type { CompanionTodo, CompanionToolCall, CompanionToolEffect } from "@edgeever/shared";-import { Check, Circle, FileText, Loader2, RotateCcw, Undo2 } from "lucide-react";-import { useState } from "react";+import { Check, ChevronDown, Circle, FileText, Loader2, RotateCcw, Undo2 } from "lucide-react";+import { useEffect, useState } from "react";import { useTranslation } from "react-i18next";import { Button } from "@/components/ui/button";import { api } from "@/lib/api";-export function CompanionRunTimeline({+function CompanionToolList({tools, todos, busy, onOpenNote, onNotesChanged,}: {tools: CompanionToolCall[]; todos: CompanionTodo[]; busy: boolean;@@ -31,65 +31,93 @@ export function CompanionRunTimeline({setMessage(t("companion.timeline.restoreFailed"));} finally { setPending(null); }};- if (!tools.length && !todos.length) return null;return (- <div className="space-y-2 rounded-md border border-slate-200/80 bg-slate-50/70 p-2.5">+ <div className="space-y-2">{todos.length ? (- <div>- <p className="text-[11px] font-semibold text-slate-500">{t("companion.todos.title")}</p>- <ul className="mt-1 space-y-1">- {todos.map(todo => (- <li key={todo.id} className="flex items-start gap-1.5 text-xs text-slate-700">- {todo.status === "completed" ? <Check className="mt-0.5 h-3 w-3 shrink-0 text-emerald-600" /> : todo.status === "in_progress"- ? <Loader2 className="mt-0.5 h-3 w-3 shrink-0 animate-spin text-emerald-600" />- : <Circle className="mt-0.5 h-3 w-3 shrink-0 text-slate-400" />}- <span className={todo.status === "completed" ? "text-slate-500 line-through" : ""}>{todo.content}</span>- </li>- ))}- </ul>- </div>+ <ul className="space-y-1">+ {todos.map(todo => (+ <li key={todo.id} className="flex items-start gap-1.5 text-xs text-slate-700">+ {todo.status === "completed" ? <Check className="mt-0.5 h-3 w-3 shrink-0 text-emerald-600" /> : todo.status === "in_progress"+ ? <Loader2 className="mt-0.5 h-3 w-3 shrink-0 animate-spin text-emerald-600" />+ : <Circle className="mt-0.5 h-3 w-3 shrink-0 text-slate-400" />}+ <span className={todo.status === "completed" ? "text-slate-500 line-through" : ""}>{todo.content}</span>+ </li>+ ))}+ </ul>) : null}{tools.length ? (- <div>- <p className="text-[11px] font-semibold text-slate-500">{t("companion.timeline.title")}</p>- <ul className="mt-1 space-y-1.5">- {tools.map(tool => (- <li key={tool.id} className="text-xs text-slate-700">- <p className="font-medium">- {t(`companion.actions.tools.${tool.name}`, { defaultValue: tool.name })}- {tool.status === "running" ? <span className="ml-1 font-normal text-slate-400">{t("companion.timeline.running")}</span> : null}- {tool.status === "error" ? <span className="ml-1 font-normal text-rose-600">{tool.error || t("companion.timeline.error")}</span> : null}- </p>- {tool.effects.filter(effect => effect.memoId).map((effect, index) => {- const key = `${tool.id}-${effect.memoId}-${index}`;- return (- <div key={key} className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 pl-0.5">- <button type="button" disabled={busy} className="inline-flex max-w-full items-center gap-1 font-medium hover:text-emerald-600 hover:underline"- onClick={() => onOpenNote(effect.memoId!, effect.notebookId || "")}>- <FileText className="h-3 w-3 shrink-0 text-slate-400" />- <span className="truncate">{effect.title || t("common.untitledMemo")}</span>- </button>- {effect.kind === "trashed" ? (- <Button type="button" size="sm" variant="ghost" className="h-6 px-1.5 text-[11px]" disabled={busy || pending === key}- onClick={() => void restore(effect, key)}>- <RotateCcw className="h-3 w-3" />{t("companion.timeline.restore")}- </Button>- ) : null}- {effect.kind === "updated" && effect.previousRevision != null ? (- <Button type="button" size="sm" variant="ghost" className="h-6 px-1.5 text-[11px]" disabled={busy || pending === key}- onClick={() => void restore(effect, key)}>- <Undo2 className="h-3 w-3" />{t("companion.timeline.restoreRevision")}- </Button>- ) : null}- </div>- );- })}- </li>- ))}- </ul>- </div>+ <ul className="space-y-1.5">+ {tools.map(tool => (+ <li key={tool.id} className="text-xs text-slate-700">+ <p className="font-medium">+ {t(`companion.actions.tools.${tool.name}`, { defaultValue: tool.name })}+ {tool.status === "running" ? <span className="ml-1 font-normal text-slate-400">{t("companion.timeline.running")}</span> : null}+ {tool.status === "error" ? <span className="ml-1 font-normal text-rose-600">{tool.error || t("companion.timeline.error")}</span> : null}+ </p>+ {tool.effects.filter(effect => effect.memoId).map((effect, index) => {+ const key = `${tool.id}-${effect.memoId}-${index}`;+ return (+ <div key={key} className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 pl-0.5">+ <button type="button" disabled={busy} className="inline-flex max-w-full items-center gap-1 font-medium hover:text-emerald-600 hover:underline"+ onClick={() => onOpenNote(effect.memoId!, effect.notebookId || "")}>+ <FileText className="h-3 w-3 shrink-0 text-slate-400" />+ <span className="truncate">{effect.title || t("common.untitledMemo")}</span>+ </button>+ {effect.kind === "trashed" ? (+ <Button type="button" size="sm" variant="ghost" className="h-6 px-1.5 text-[11px]" disabled={busy || pending === key}+ onClick={() => void restore(effect, key)}>+ <RotateCcw className="h-3 w-3" />{t("companion.timeline.restore")}+ </Button>+ ) : null}+ {effect.kind === "updated" && effect.previousRevision != null ? (+ <Button type="button" size="sm" variant="ghost" className="h-6 px-1.5 text-[11px]" disabled={busy || pending === key}+ onClick={() => void restore(effect, key)}>+ <Undo2 className="h-3 w-3" />{t("companion.timeline.restoreRevision")}+ </Button>+ ) : null}+ </div>+ );+ })}+ </li>+ ))}+ </ul>) : null}{message ? <p className="text-[11px] text-slate-500">{message}</p> : null}</div>);}++export function CompanionRunTimeline({+ process, tools, todos, expanded, busy, onOpenNote, onNotesChanged,+}: {+ process?: string; tools: CompanionToolCall[]; todos: CompanionTodo[]; expanded?: boolean; busy: boolean;+ onOpenNote: (id: string, notebookId: string) => void; onNotesChanged: () => Promise<void>;+}) {+ const { t } = useTranslation();+ const [open, setOpen] = useState(Boolean(expanded));+ const narration = process?.trim() ?? "";+ useEffect(() => { setOpen(Boolean(expanded)); }, [expanded]);+ if (!tools.length && !todos.length && !narration) return null;+ const label = tools.length+ ? t("companion.trace", { count: tools.length })+ : t("companion.process");+ return (+ <div className="rounded-md border border-slate-200/80 bg-slate-50/70">+ <button+ type="button"+ className="flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left text-[11px] font-medium text-slate-500"+ aria-expanded={open}+ onClick={() => setOpen(value => !value)}+ >+ <ChevronDown className={`h-3 w-3 shrink-0 transition-transform ${open ? "rotate-0" : "-rotate-90"}`} />+ {label}+ </button>+ {open ? (+ <div className="space-y-2 border-t border-slate-200/70 px-2.5 py-2">+ {narration ? <p className="whitespace-pre-wrap break-words text-xs leading-relaxed text-slate-500">{narration}</p> : null}+ <CompanionToolList tools={tools} todos={todos} busy={busy} onOpenNote={onOpenNote} onNotesChanged={onNotesChanged} />+ </div>+ ) : null}+ </div>+ );+}diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 26fb0d6a..c993d16c 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -184,6 +184,7 @@ export const enUS = {},continue: "Continue unfinished work",process: "Thinking",+ trace: "Run · {{count}} steps",},common: {appName: "EdgeEver",diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.tsindex 4938988f..c0b6f5be 100644--- a/packages/shared/src/i18n/ja.ts+++ b/packages/shared/src/i18n/ja.ts@@ -184,6 +184,7 @@ export const ja = {},continue: "未完了の作業を続ける",process: "思考過程",+ trace: "過程 · {{count}} 手",},common: {appName: "EdgeEver",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 9cebd984..20df15bb 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -184,6 +184,7 @@ export const zhCN = {},continue: "继续未完成的工作",process: "思考过程",+ trace: "过程 · {{count}} 步",},common: {appName: "EdgeEver",