From 75e4c790299fc3148c89ff6a3ce49d427c8285fd Mon Sep 17 00:00:00 2001 From: Hu Hongwei <46087189+jadelike-wine@users.noreply.github.com> Date: Sat, 28 Nov 2026 16:40:52 +0800 Subject: [PATCH] docs(tui): explain when terminal threads appear on the web (#8753) * docs(tui): explain when terminal threads appear on the web * docs(tui): require a shared PostgreSQL schema --- backend/docs/TUI.md | 23 +++++++++++++---------- docs/guide/tui.md | 11 ++++++++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/backend/docs/TUI.md b/backend/docs/TUI.md index 3b35fc46f4..b1fd44a50c 100644 --- a/backend/docs/TUI.md +++ b/backend/docs/TUI.md @@ -166,17 +166,20 @@ have no Textual dependency and are unit-tested directly with synthetic `StreamEv ## Web UI visibility (shared persistence) -The Web UI lists conversations from the `threads_meta` SQL table (filtered by -`user_id`), **not** from the checkpointer. An embedded run only writes the -checkpointer, so a TUI thread would otherwise be invisible in the sidebar. +With SQLite or PostgreSQL, the Web UI lists conversations from `threads_meta`, +filtered by user. The TUI writes a row for the local `default` user on the first +turn and syncs the generated title afterward. The write is best effort and can +happen while the Gateway is stopped. The sidebar shows the thread when the +Gateway reads the same database for the `default` user. With the `memory` +backend, the TUI still works and skips this metadata write. -`persistence.py` closes that gap: on the first turn of a thread it writes a -`threads_meta` row — owned by the local default user (`"default"`) — into the -**same** database the Gateway reads, and syncs the generated title afterward. -This requires only the shared `threads_meta` store (built via -`deerflow.persistence.engine.init_engine_from_config`), **not** the Gateway -process. When the database backend is `memory` (no SQL store) the writer -degrades to a silent no-op and the TUI still works. +With PostgreSQL, the TUI and Gateway must also use the same schema +(`database.postgres_schema`). + +SQLite resolves a relative `database.sqlite_dir` from each process's working +directory. `make dev` starts the Gateway from `backend/`, so launch the TUI from +`backend/` as well to use the same relative path. You can also configure an +absolute `database.sqlite_dir` that both processes can access. All DB work runs on one long-lived background event loop, because a SQLAlchemy async engine is bound to the loop that created it. diff --git a/docs/guide/tui.md b/docs/guide/tui.md index 5a08a01478..a80218cf0f 100644 --- a/docs/guide/tui.md +++ b/docs/guide/tui.md @@ -25,7 +25,16 @@ deerflow --recursion-limit 250 --print "task" # override the headless agent-loop Headless `--print` and `--json` exit with status `1` when the run fails, including provider errors returned as fallback messages. `--print` still writes the fallback text to stdout; `--json` appends a terminal error record. -A keyboard-driven chat surface with a streaming transcript (Markdown-rendered answers), compact tool-activity cards, a `/` slash-command palette, display-only `/clear`, `/goal` goal management, `/model` and `/threads` pickers, input history, PageUp/PageDown transcript navigation, and `Esc` / `Ctrl+C` interrupt. The composer preserves line breaks and indentation in pasted code, stack traces, and multi-paragraph prompts; `Enter` sends the complete document. Transcript refreshes preserve your reading position after you scroll upward and resume following new output when you return to the bottom. `/clear` removes rows from the current terminal display without deleting the thread or its persisted conversation; `/new` and `/clear` ask you to wait during an active run instead of resetting in-flight display state. Sessions opened in the TUI also appear in the Web UI sidebar — it writes the shared thread store under the local default user, so terminal and web stay in sync **without running the Gateway**. +A keyboard-driven chat surface with a streaming transcript (Markdown-rendered answers), compact tool-activity cards, a `/` slash-command palette, display-only `/clear`, `/goal` goal management, `/model` and `/threads` pickers, input history, PageUp/PageDown transcript navigation, and `Esc` / `Ctrl+C` interrupt. The composer preserves line breaks and indentation in pasted code, stack traces, and multi-paragraph prompts; `Enter` sends the complete document. Transcript refreshes preserve your reading position after you scroll upward and resume following new output when you return to the bottom. `/clear` removes rows from the current terminal display without deleting the thread or its persisted conversation; `/new` and `/clear` ask you to wait during an active run instead of resetting in-flight display state. + +TUI conversations can appear in the Web UI sidebar when the Gateway uses the +same SQLite or PostgreSQL database and the Web UI is using the local `default` +user. For a local `make dev` Gateway with a relative SQLite path, launch the TUI +from `backend/` so both processes find the same database. See +[Web UI visibility](../../backend/docs/TUI.md#web-ui-visibility-shared-persistence). + +With PostgreSQL, the TUI and Gateway must also use the same schema +(`database.postgres_schema`). TUI slash commands accept Unicode whitespace before their arguments, including spaces, tabs, line breaks, and nonbreaking spaces. A separator closes the slash