Commit Graph

579 Commits

Author SHA1 Message Date
wizardchen 0f5dc41f4e feat(searxng): enhance SearXNG configuration and validation
- Updated .env.example to clarify SEARXNG_SECRET generation and added SSRF_WHITELIST_EXTRA for improved security.
- Modified docker-compose files to bind SearXNG to localhost by default and introduced a one-time initialization service to set up settings.yml correctly.
- Enhanced SearxngProvider with stricter URL validation, ensuring no query or fragment is present in the base URL.
- Added unit tests for SearXNG validation and date parsing to ensure robustness.
- Updated frontend WebSearchSettings to reflect changes in SearXNG instance URL handling.

This commit improves the security and usability of the SearXNG integration, addressing potential misconfigurations and enhancing the developer experience.
2026-05-11 16:53:47 +08:00
wizardchen d2a1006beb fix(web-search): address review fixups for SearXNG provider
- utils: 合并 SSRF_WHITELIST 与 SSRF_WHITELIST_EXTRA,避免部署侧默认值
  (如 docker-compose 注入的 searxng 主机名)被用户的 SSRF_WHITELIST
  自定义值覆盖。
- docker-compose.yml: 把 searxng 默认值挪到 SSRF_WHITELIST_EXTRA。
- searxng: 抽出导出函数 ValidateSearxngBaseURL,让 service 层保存校验
  和 provider 构造校验完全一致;service 改为调用同一函数。
- searxng: language 由非法的 "auto" 改为 "all";移除强制 safesearch=1
  让实例 settings.yml 决定。
- searxng: publishedDate 增加多格式 fallback(RFC3339Nano/无时区/
  日期-only/RFC1123 等),无法解析时 debug 日志记录。
- searxng: 解析 unresponsive_engines;结果为空时打 warn 日志,便于排查
  "配置正确却搜不到结果"的情况。
- frontend: WebSearchSettings 的 Instance URL 标签/占位符走 i18n,
  zh-CN / en-US / ru-RU / ko-KR 四个 locale 补齐 baseUrlLabel /
  baseUrlPlaceholder。
2026-05-11 16:53:47 +08:00
wizardchen 1110615300 feat(web-search): add SearXNG provider (#1166)
支持对接自建/公共 SearXNG 实例作为网络搜索引擎,缓解免费搜索引擎在国内
网络环境下访问受限的问题。

- types: 新增 WebSearchProviderTypeSearxng 与 BaseURL 参数字段;
  类型元数据新增 RequiresBaseURL,前端可动态渲染 Instance URL 表单。
- infrastructure/web_search/searxng.go: 调用 /search?format=json,强制
  utils.ValidateURLForSSRF 校验 base_url,可选 api_key 透传给反代鉴权。
- service: isValidProviderType 与参数校验接入 searxng。
- container: 注册 NewSearxngProvider 工厂。
- frontend: WebSearchSettings 表单根据 requires_base_url 渲染 Instance
  URL 输入框;编辑回填、free 判定同步更新。
- docker: 新增可选 searxng 服务(profile=searxng/full),附带最小化
  settings.yml(启用 JSON 格式、关闭 limiter、关闭遥测),
  docker-compose 默认 SSRF_WHITELIST 包含 searxng 容器名。
- .env.example: 补充 SEARXNG_PORT / SEARXNG_SECRET 说明。

Closes #1166
2026-05-11 16:53:47 +08:00
wizardchen 9dcb61fb45 feat(frontend): enable gzip compression for static resources in nginx configuration
- Added gzip compression settings to improve loading times for static assets, significantly reducing the size of files served and enhancing performance for users, especially in low bandwidth regions.
2026-05-11 15:51:11 +08:00
wizardchen 5510ea8f5a feat(agent): human-in-the-loop approval for MCP tool calls (#1173)
Add an opt-in human approval gate so Agent runs pause before executing
MCP tools that operators flag as dangerous, surface an approval card in
the chat UI, and only resume after the user approves (optionally with
edited args) or rejects.

Backend
- New mcp_tool_approvals table + repo/service to mark per-tool approval
  required (PG migration 000042 + sqlite init).
- approval.Gate coordinates RequestAndWait / Resolve with sync.Once
  delivery, configurable timeout, and Redis Pub/Sub fan-out so multi-
  replica deployments work without sticky sessions.
- MCPTool.Execute integrates the gate; uses a round-level ApprovalCtx
  (without the per-tool 60s timeout) for the wait, and re-derives a
  fresh 60s exec ctx after approval so CallTool keeps a full window.
- New SSE response types (tool_approval_required / _resolved) and
  EventBus events plumb approval state to AgentStreamDisplay.
- REST: list/set per-tool approval flag, resolve pending approval.
- Configurable via agent.tool_approval_timeout_seconds (yaml) or
  WEKNORA_AGENT_TOOL_APPROVAL_TIMEOUT env (accepts seconds or Go
  duration).

Frontend
- MCP settings: per-tool "require approval" switch on the test panel.
- Chat: ToolApprovalCard renders the pause point with editable JSON
  args, validation feedback, mm:ss countdown that turns warning/danger
  near deadline, and a resolved state that retains context.
- i18n strings added for zh-CN / en-US / ko-KR / ru-RU.

Docs
- docs/zh/mcp-approval.md covering behavior, config, API, deployment
  considerations (Redis cross-instance, restart limitations).
2026-05-10 22:57:12 +08:00
wizardchen c1826030ab fix(frontend): 修正 LLM 调用超时文案与实际行为一致,上限放宽至 3600s
前端原文案'0 表示无限等待(不推荐)'与后端实际行为不符——
internal/agent/const.go 中 getLLMCallTimeout 在配置为 0 时回退到
defaultLLMCallTimeout (120s),并不会无限等待,文案误导用户。

- 同步 zh-CN/en-US/ru-RU/ko-KR 四种语言 hint 为'0 表示使用默认值(120s)'
- placeholder 推荐范围由 60-600 调整为 60-1800,与后端兜底超时上调保持一致
- AgentEditorModal 输入框 :max 由 600 放宽到 3600,避免长推理模型场景被卡住
2026-05-10 00:26:53 +08:00
dependabot[bot] a842e2335b chore(deps): bump dompurify and @types/dompurify in /frontend
Bumps [dompurify](https://github.com/cure53/DOMPurify) and [@types/dompurify](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/dompurify). These dependencies needed to be updated together.

Updates `dompurify` from 3.4.1 to 3.4.2
- [Release notes](https://github.com/cure53/DOMPurify/releases)
- [Commits](https://github.com/cure53/DOMPurify/compare/3.4.1...3.4.2)

Updates `@types/dompurify` from 3.0.5 to 3.2.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/dompurify)

---
updated-dependencies:
- dependency-name: "@types/dompurify"
  dependency-version: 3.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: dompurify
  dependency-version: 3.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-09 13:00:58 +08:00
dependabot[bot] f4c2934499 chore(deps): bump vue from 3.5.17 to 3.5.34 in /frontend
Bumps [vue](https://github.com/vuejs/core) from 3.5.17 to 3.5.34.
- [Release notes](https://github.com/vuejs/core/releases)
- [Changelog](https://github.com/vuejs/core/blob/main/CHANGELOG.md)
- [Commits](https://github.com/vuejs/core/compare/v3.5.17...v3.5.34)

---
updated-dependencies:
- dependency-name: vue
  dependency-version: 3.5.34
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-09 13:00:07 +08:00
dependabot[bot] fb47d84d98 chore(deps): bump @types/papaparse from 5.5.0 to 5.5.2 in /frontend
Bumps [@types/papaparse](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/papaparse) from 5.5.0 to 5.5.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/papaparse)

---
updated-dependencies:
- dependency-name: "@types/papaparse"
  dependency-version: 5.5.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-09 12:58:48 +08:00
dependabot[bot] 0bbb41de27 chore(deps-dev): bump less-loader from 12.3.0 to 12.3.2 in /frontend
Bumps [less-loader](https://github.com/webpack/less-loader) from 12.3.0 to 12.3.2.
- [Release notes](https://github.com/webpack/less-loader/releases)
- [Changelog](https://github.com/webpack/less-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/webpack/less-loader/compare/v12.3.0...v12.3.2)

---
updated-dependencies:
- dependency-name: less-loader
  dependency-version: 12.3.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-09 12:56:51 +08:00
dependabot[bot] 466dcc1c65 chore(deps-dev): bump less from 4.3.0 to 4.6.4 in /frontend
Bumps [less](https://github.com/less/less.js) from 4.3.0 to 4.6.4.
- [Release notes](https://github.com/less/less.js/releases)
- [Changelog](https://github.com/less/less.js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/less/less.js/commits)

---
updated-dependencies:
- dependency-name: less
  dependency-version: 4.6.4
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-09 12:52:29 +08:00
wizardchen 21a4259fc5 feat(wiki/graph): 优化操作帮助入口与图例视觉
- 把"操作帮助"按钮从图例底部挪到搜索框右侧,使用 placeholder
  色的图标按钮,hover 高亮主题色,更易被发现且不与图例操作项
  混在一起
- 状态卡片(全库概览/当前焦点)简化排版:去掉大写字母+字间距,
  主标题降字号去粗体,分隔改为 1px 虚线,整体视觉更轻
- 抽屉打开时图例自动向左平移 480px(抽屉宽度),避免被覆盖,
  使用与 TDesign drawer 一致的 cubic-bezier 缓动
2026-05-09 00:49:28 +08:00
wizardchen d0144f3586 perf(wiki): move ingest log to event table and index to on-demand API
Fixes O(n²) write amplification during wiki ingest on large KBs. Previously
every ingest/retract op re-wrote the single `slug='log'` row end-to-end and
every batch re-wrote the entire `slug='index'` directory markdown. On a 40k-
doc KB the log row grew to tens of MB and the index row to several MB, so
each batch triggered giant TOAST updates that dominated ingest wall time.

Log: new `wiki_log_entries` event table (`id DESC` indexed per KB) replaces
the single TEXT row. Batch ingest now collects entries and flushes them
once per batch via `AppendBatch`. Each entry stores `pages_affected` as
JSONB `[{slug,title}]` so the UI can render real titles; custom Scan falls
back to legacy `[]string` so older rows still deserialize.

Index: `wiki_pages[slug=index].content` keeps only the LLM-generated intro
(a few KB). The directory is now served by a structured paginated API
(`GetIndexView`) that reads `slug/title/summary` per type with cursor
pagination, so the agent and the frontend only pull the slice they need.
`RebuildIndexPage` degrades to a no-op; agent `wiki_read_page('index')`
synthesizes a small top-K overview and points callers at `wiki_search`.

Ingest resilience: LLM calls wrap with 3-attempt exponential backoff on
transient errors (5xx/408/429, transport resets/timeouts). Summary/extract
failures now bubble up so the batch's failed-op requeue path runs instead
of silently dropping the doc.

Frontend: sidebar Index/Log entries switch to dedicated views. Index view
streams intro → Summary → Entity → Concept → Synthesis → Comparison via
IntersectionObserver (with a nextTick re-check so small KBs still load
every section). Log view uses cursor pagination; pages_affected renders
titles with slug tooltip.

- new migration: migrations/versioned/000040_wiki_log_entries.{up,down}.sql
- tests: log repo pagination + legacy Scan, ListByTypeLight windowing,
  renderIndexOverviewForAgent output, isTransientLLMError classifier

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 21:48:52 +08:00
DuYunfan 16d31cb87b fix(frontend): use npm to match committed lockfile
The Dockerfile invoked corepack + pnpm install, but the repo only
ships package-lock.json (no pnpm-lock.yaml). On node:24-alpine
corepack resolves to pnpm v10, whose default --strict-dep-builds
rejects unbuilt postinstall scripts (esbuild, vue-demi,
@vue-office/pptx) and aborts with ERR_PNPM_IGNORED_BUILDS, breaking
docker compose build.

Switching to npm ci / npm run build aligns the image build with
CLAUDE.md and the local dev workflow that already uses npm.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 20:10:04 +08:00
wizardchen 86f11d98e8 fix(frontend): configure pnpm v11 build approvals in workspace file
pnpm v11 no longer supports onlyBuiltDependencies in package.json and does not
accept install-time --allow-build flags. Move build-script approvals to
pnpm-workspace.yaml and copy it before install in Dockerfile so CI Docker builds
can apply allowBuilds during pnpm install.
2026-05-08 16:34:33 +08:00
wizardchen de7a241f8b fix(frontend): pass allow-build flags to pnpm install in Docker build
Some CI runners still fail with ERR_PNPM_IGNORED_BUILDS even with package-level
configuration. Pass explicit allow-build flags to `pnpm install` in Dockerfile so
required postinstall scripts are always permitted during image builds.
2026-05-08 16:28:12 +08:00
wizardchen 483576a9b6 fix(frontend): allow build scripts for pnpm to unblock Docker build
pnpm 10+ refuses to run dependency build scripts by default and exits
with ERR_PNPM_IGNORED_BUILDS, causing `pnpm install` to fail in the
frontend Docker image. Whitelist the packages that legitimately need
their install scripts (esbuild native binary, @vue-office/pptx,
vue-demi) via `pnpm.onlyBuiltDependencies`.
2026-05-08 16:17:52 +08:00
wizardchen a4c3c39556 perf(wiki): lazy-load sidebar page list with virtual-scroll tabs
?tab=wiki used to call listWikiPages({page_size: 500}) in a loop up to
50 times, loading ~25k pages into memory before rendering the sidebar
on knowledge bases with tens of thousands of pages. All rows were then
materialized as DOM nodes inside collapsible groups stacked vertically.

This commit reshapes the sidebar around per-type buckets that are
fetched on demand and rendered through a single virtual scroller:

* pagesByType holds one bucket per page_type (summary / entity /
  concept / synthesis / comparison), each with its own items list,
  pagination cursor, KB-wide total, and loading flag. Initial load
  fires one 50-item request per type in parallel.
* Index and Log are fetched directly via getWikiIndex / getWikiLog
  instead of scanning the full page list to find them.
* Groups are surfaced as a horizontal tab bar; switching tabs swaps
  the RecycleScroller's items. Only one bucket is visible at a time,
  so we never stack multiple virtual viewports.
* The scroller runs in page-mode with the outer .wiki-page-list as the
  scrollable ancestor; a 1px sentinel after the list is watched by
  IntersectionObserver to trigger the next page fetch. After each
  batch lands we call scroller.updateVisibleItems(true) on the next
  tick so appended rows render in order without requiring the user
  to jiggle the scroll.
* Switching tabs resets scrollTop so the retained position of the
  previous tab can't re-trigger the sentinel and cascade loads on
  the new (shorter) list.
* Search enters a dedicated flat-result mode (searchResults ref);
  clearing the query flips back to the bucketed view without
  refetching the buckets the user already had open.

Adds vue-virtual-scroller dependency and imports its stylesheet.
2026-05-08 15:07:59 +08:00
wizardchen df1e9a1bfd perf(wiki): subgraph API and interactive exploration for large graphs
Wikis with tens of thousands of pages used to crash the browser trying
to render the entire link graph at once (30MB+ JSON, 100k+ SVG elements).
This change moves the graph viewer from "fetch everything, render
everything" to "fetch a slice, expand on demand" with several matching
UX improvements.

Backend

* GET /wiki/graph now accepts `mode` (overview | ego), `center`, `depth`,
  `types`, `limit` query params. Default is overview top-500 by
  link_count, capped at 2000. Response includes a Meta object so the
  frontend can render a truncation hint and drive the UI.
* Pure helper `computeGraphSubset` extracted for testability; six unit
  tests cover overview truncation / type filter / ego BFS / missing
  center error.
* WikiLintService passes Limit=0 (uncapped) so link integrity checks
  still walk every page.
* Repo `Search` adds CASE-based relevance ranking (title 4, slug 3,
  summary 2, content 1) so full-text results put the most obvious
  matches first instead of whatever was updated most recently.

Frontend

* Graph viewer fetches overview on entry; ego pivot on double-click,
  search, wiki-link click, URL ?slug=, global issues jump.
* Shift+click or hover ⊕ button blooms neighbors onto the current
  canvas additively. Bloom tracks generations and LRU-evicts oldest
  when total exceeds 1500 nodes; ego center / selected node / latest
  anchor are always protected.
* "Grow frontier (N)" legend action expands every dashed-ring node in
  one click (6-way concurrency) while skipping Index/Log super-nodes
  that would otherwise dump the whole wiki onto the canvas.
* Node dashed expansion ring + drawer "X/Y neighbors shown" hint tell
  users which nodes still have neighbors to load.
* Search dropdown uses remote full-text search (debounced, sequence-
  numbered to drop stale responses) and falls back to the overview
  top-500 snapshot when the input is empty.
* Type filters now round-trip to the server so top-N is always
  computed from the user's active type set rather than hiding nodes
  client-side and shrinking the view.
* Status card replaces the cramped "centered on X · N hops · M nodes"
  line with a structured focus/overview summary, resolving slugs to
  page titles.
* Help popover in the legend lists every canvas shortcut.

i18n entries added for zh-CN / en-US / ko-KR / ru-RU.
2026-05-08 13:32:54 +08:00
wizardchen 6019c4b661 fix(frontend): polish model settings UI and fix disabled brand color
- Fix global `--td-brand-color-disabled` to use correct muted green instead of bright green
- Unify `variant="text"` buttons (refresh, download, check dimension) in model settings to inherit standard TDesign styles
- Adjust WeKnora Cloud credential status layout and change reconfigure button to outline
- Fix font size of external doc links in model settings hint blocks
- Increase font weight of KB chunking debug trigger for better visibility
2026-05-07 21:51:22 +08:00
wizardchen c77cef5a69 feat(frontend): unify external doc-link style and outline add buttons
- Add global .doc-link utility in theme.css (brand color text + link icon, underline on hover).

- Convert all external doc/console links across settings to use .doc-link with a trailing <t-icon name="link" />, matching the Ollama browse-library style.

- Switch primary section-toolbar 'Add X' buttons (Model/WebSearch/VectorStore/MCP/DataSource) to outline variant for a lighter, more consistent look.

- Drop redundant per-component CSS for builtin-hint-link, weknoracloud-hint-link, engine-doc-link, engine-link, hint-link, section-doc-link, ds-doc-link-inline, model-link, etc.
2026-05-07 21:51:22 +08:00
wizardchen cc6ac6ac50 fix(frontend): unify radio button theme and disabled selection
- Add global t-radio-button outline styles in theme.css (brand fill when checked).

- Align ModelEditor, share KB, datasource, agent/MCP settings with t-radio-button.

- Remove redundant :deep overrides in AgentEditorModal, KB editor, FAQEntryManager, etc.

- Use brand disabled tone for disabled+checked radio buttons so selection stays visible.
2026-05-07 21:51:22 +08:00
wizardchen 627e9e436d fix(frontend): render markdown tables in chat wiki drawer
The wiki page drawer opened from the chat view rendered tables without
borders or padding because the global `.wiki-graph-drawer .wiki-reader-body`
style block was missing GFM table rules. Add the same table styles already
used by `WikiBrowser.vue` so tables show consistent borders, header
background, and hover states across both entry points.
2026-05-07 18:29:36 +08:00
wizardchen 56058287dd fix(agent): drop whitespace-only thinking events from the steps tree
Some LLMs (e.g. qwen3 series) emit blank lines like "\n\n" before tool
calls. The backend faithfully forwards these as thought_chunk events
because streamThinkingToEventBus only filters chunk.Content == "" and
treats whitespace as content. The frontend then merges them into a
thinking event whose content is non-empty in JS truthiness terms but
visually empty, producing a "思考" card with a chevron and no text.

Filter such events out at the end of buildFullEventList so neither the
intermediate-steps tree nor the displayEvents fallback path renders
them.
2026-05-07 17:33:03 +08:00
wizardchen 921e4c015a fix(agent): hide trailing thinking event when it duplicates final answer
The natural-stop path on the backend (observe.go Case 1) emits the same
content twice: once as streaming thinking chunks (from
streamThinkingToEventBus's per-chunk callback) which the frontend merges
into a single thinking event, and once as one big EventAgentFinalAnswer.
The result is that the intermediate-steps tree contains a thinking card
whose content is identical to the answer card rendered below it.

Detect this duplication and hide the offending thinking event from the
tree:

- New utils `normaliseForComparison` and `thinkingEqualsAnswer` perform
  a tolerant comparison: strip <think>…</think> blocks (which leak into
  raw thinking chunks but not into the post-StripThinkBlocks answer),
  strip final-answer wrappers, collapse whitespace, then exact-equal or
  ±2% length with matching head/tail.
- `hiddenThinkingEventIds` (replacing the previous single-id
  `promotedThinkingEventId`) now collects two cases of duplicate
  thinking: the legacy promotion fallback (no answer event present) and
  the natural-stop content-match case.

The final_answer-tool path is unaffected because reasoning thinking
events ("我找到了…让我整理…") and the answer payload have different
content and don't match the equivalence check.
2026-05-07 17:33:03 +08:00
wizardchen 4677caba01 fix(agent): unify answer rendering when model skips final_answer tool
Many models (especially smaller or non-OpenAI-style ones) do not reliably
call the structured final_answer tool, even when the system prompt
explicitly requires it. Two visible symptoms in the agent UI:

1. The natural-stop path emits the answer as a final_answer event whose
   content is wrapped in <answer>...</answer>, <final_answer>...</final_answer>,
   or prefixed with "Final Answer:" / "最终答案:". These wrappers were
   rendered verbatim into the answer card.

2. When no answer event arrives at all, the trailing thinking event was
   surfaced via the legacy fallback but kept its collapsed "思考" card
   styling instead of rendering as a proper answer.

This change adds a small unwrap helper and wires it through the answer
rendering path:

- New util `unwrapFinalAnswerWrappers` strips conservative outer wrappers
  (XML-style answer tags, fenced ```final_answer code blocks, and leading
  "Final Answer:" / "最终答案:" prefixes) only when they cover the entire
  trimmed content, so user markdown that happens to contain similar text
  is left alone.
- `renderAnswerContent` and `getActualContent` apply the unwrap before the
  markdown renderer / clipboard copy, so users see and copy clean text.
- The legacy "promote trailing thinking to final answer" fallback now
  synthesizes a virtual answer event so it renders with the answer card
  UI (expanded markdown + copy/add toolbar) instead of the collapsed
  thinking card. The promoted thinking event is hidden from the
  intermediate-steps tree to avoid duplication.
2026-05-07 17:33:03 +08:00
bingxiang.cheng a3c3ba5acf fix(markdown): 修复小概率情况下公式加载失败问题 2026-05-07 16:34:20 +08:00
bingxiang.cheng a232b12ff0 fix(agent): 修复WeKnora对话完前端未显示结束标记问题
fix(agent): 修复流式回答think内容与answer混淆问题
2026-05-07 16:34:20 +08:00
wizardchen 4a5caf54af fix(frontend): make general-settings font picker actually work
The font picker in 常规设置 silently failed in three distinct ways:

1. Font family changes were invisible on macOS because 6 of the 7 options
   (Inter / Roboto / Segoe UI / Cascadia Code / JetBrains Mono / Fira
   Code) aren't installed by default and fell back to system SF. Swap
   the picker to a platform-aware list — Mac / Windows / Linux each see
   only the fonts their OS actually ships. The "third sans slot" now
   always serves a serif face (Georgia / Times New Roman / DejaVu
   Serif) so the difference is unambiguously visible instead of being
   three near-identical sans families.

2. Font size flipped --app-font-scale on <html>, but that variable was
   only consumed by a handful of TDesign tokens and the body reset, so
   the ~1000+ hard-coded font-size: NNpx rules across the frontend
   stayed put. Apply the multiplier via `zoom` on <html> so the whole
   document scales, then fix the 15 `100vh` rules that would overflow
   under zoom (html / body / #app are already height: 100%, so the
   descendants can use 100% too).

3. The monospace picker had no visible effect even on a working stack
   because `<t-input style="font-family: ...">` is forwarded to the
   inner <input>, but TDesign applies `font: var(--td-font-body-medium)`
   — a shorthand that resets font-family. Reach the real <input> /
   <textarea> via `:deep()` instead of inline style.

Additional polish:
- Add a live preview row under each picker so users can see the effect
  without hunting for a code block or API Info screen
- Rename "等宽字体 / Monospace Font" → "代码字体 / Code Font" to match
  VSCode / GitHub / Notion convention; the old label was jargon
- Rewrite descriptions to explain the actual purpose and scope
2026-05-07 15:07:24 +08:00
wizardchen fb9ae11aa8 fix: 为前端静态资源设置正确的 Cache-Control 响应头
修复升级前端版本后,用户必须退出重新登录才能看到新版页面的问题。

根因:nginx 和 Lite 版 Go 静态服务均未设置 Cache-Control,浏览器按
启发式策略长期缓存 index.html,导致刷新仍加载旧版入口 HTML,旧版
引用的 hash 文件名也就不会变更。

改动:
- frontend/nginx.conf: index.html 及 SPA fallback 设 no-cache,
  must-revalidate;/assets/* (Vite 产物带 hash 文件名)设一年
  immutable 长缓存。location 内重复声明原有安全头,避免 nginx
  add_header 不继承导致安全头丢失。
- internal/router/router.go: Lite 版 serveFrontendStatic 按同样
  策略设置 Cache-Control。
2026-05-07 12:08:02 +08:00
wizardchen c577d0e474 fix(knowledge): polish chunking-settings debug trigger and strategy hint
The chunking-settings debug trigger and strategy picker had two UX
issues reported by real usage:

- The test button used theme=primary + variant=outline, a combo that
  appears nowhere else in the project. A green-bordered green-text
  pill in the corner of the section header read as a misplaced
  promotional element rather than a secondary action.
- The strategy select's placeholder was "选择策略(默认使用经典递归分块)"
  / "Select strategy (defaults to classic recursive splitting)". Naming
  the fallback strategy inside the placeholder made the empty select
  look as if the user had already picked "classic recursive" — even
  though the value is actually empty.

- Move the debug trigger from the section header into the strategy
  row's right column, stacked below the select. Users meet the test
  action exactly when they're deciding which strategy to use.
- Switch the trigger to a text-style button and override TDesign's
  default hover/focus/active surfaces so the button reads as an inline
  link (text colour shift only, no filled background block).
- Rename the trigger to "测试分块效果" / "Preview chunking" so it
  describes what will be inspected rather than the input source.
- Drop the reference to the fallback strategy inside the placeholder.
  "不填则按长度切分" / "splits by length if left empty" preserves the
  original information about empty-value behaviour without looking
  like a selected option.
- Remove the now-unused 80px right padding the section header reserved
  to keep the old inline trigger clear of the modal close button.
2026-05-07 11:08:29 +08:00
wizardchen 49cd392308 fix(frontend): rework chunking debug UX in KB editor
The chunking debug panel was an inline section that crowded the
strategy form, broke its own layout with negative margins, and crashed
on result.rejected being null. The trigger button required scrolling to
the form's bottom to reach.

- Move debug into a right-side t-drawer pinned above the modal stacking
  context (attach=body, z-index 3000) so it overlays cleanly.
- Promote the trigger to a sticky header sibling next to the section
  title, with right padding to clear the modal close button.
- Replace unicode arrows / + / − with tdesign-icons (Chevron, Play,
  ErrorCircle) and rebuild the result layout: pill-shaped breadcrumb
  tags, line-clamped previews with gradient fade on collapse, ordered
  chunk list, structured error block.
- Drop custom char counter (t-textarea already has one).
- Add four sample fixtures (markdown / faq / chapter / plain) loadable
  as preset chips so users have realistic content to test against.
- Guard `result.rejected` nullability that crashed the panel.
- Normalize the recursive tier label to legacy in the UI since both
  tiers behave identically — pairs with the backend cleanup.
- Rename strategy labels in zh-CN/en-US/ko-KR/ru-RU from internal jargon
  ("auto", "heading", "heuristic", "legacy") to descriptive names
  ("Automatic", "Heading-aware", "Structure-aware", "Length-based") and
  add presetLabel + sample i18n keys.
2026-05-06 20:23:21 +08:00
Claude 55bc5dcbe2 fix(chunking): post-review polish — error surfacing + doc accuracy
Three small follow-ups from the QA review of 13f57ca:

1. KBChunkingDebug error surfacing
   Previously a 200 OK response with { success: false, error: "..." }
   would have been swallowed under a generic "unexpected response shape"
   message. The strict-shape check now distinguishes empty response,
   success=false (surfaces resp.error directly), and missing data — so
   any future backend-side validation message reaches the user.

2. Token approximation in docs/CHUNKING.md
   Child Chunk Size default 384 ≈ 95 EN tokens (was rounded to 80).
   384 / 4 chars-per-token = 96; "~95" is the honest figure.

3. API surface in docs/CHUNKING.md
   The example only documented PUT /initialization/config/:kbId
   (camelCase, documentSplitting envelope). Added explicit notes that
   POST/PUT /knowledge-bases use snake_case under chunking_config, and
   that POST /chunker/preview also uses the snake_case form plus a text
   field. Readers picking the wrong endpoint won't be surprised by the
   case mismatch anymore.

https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-06 17:17:07 +08:00
Claude 49adf0d73c docs(chunking): align overlap default + sharpen UI/source/repo docs
Three documentation passes around the adaptive chunking work:

UI
- Frontend ChunkOverlap default consolidated to 80 (was 100), matching
  chunker.DefaultChunkOverlap on the backend. Both DEFAULT_CHUNKING_PRESET
  and initFormData updated. The KB-load fallback also uses 80 when a
  loaded KB has no chunk_overlap stored.
- All four locales (en-US, zh-CN, ko-KR, ru-RU) get rewritten chunking
  setting descriptions: each now states the validated range, the default,
  and the situations where you'd deviate (FAQ vs narrative, embedder
  token limits, language-specific corpora).

Source code
- splitter.go: DefaultChunkSize / DefaultChunkOverlap constants get a
  longer block-comment explaining the per-language token math and the
  use-case sweet spots, plus the migration note on what the old
  inconsistent defaults were.
- KBChunkingSettings.vue: new comment block above ChunkingConfig
  documents the slider min/max for each setting, why those bounds
  exist, and the recommended TokenLimit values per embedding model.

Repo docs
- New docs/CHUNKING.md: end-to-end guide covering why chunking matters,
  the adaptive 3-tier architecture, per-setting reference with ranges
  and sweet spots, parent-child explanation, the token-limit table per
  embedder (OpenAI / Voyage / Cohere / BGE / MiniLM / Jina), 7 use-case
  presets, the debug panel workflow, the API surface, and known
  trade-offs (recursive strategy hidden from UI, no auto-reindex on
  strategy switch, OCR limitations).
- CHANGELOG.md gets a new [Unreleased] section consolidating all the
  adaptive-chunking work shipped on this branch: 5 features, 8
  improvements, 6 fixes, 1 docs entry. The entry references
  docs/CHUNKING.md for deeper explanation.

https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-06 17:17:07 +08:00
Claude 2cc0322004 fix(frontend): chunking debug panel — visible loading + error states, prevent submit
User report: clicking "Run preview" made the debug section appear to
disappear. Three independent problems contributed; fix all of them.

1. t-button rendered without explicit type="button". TDesign defaults
   vary across versions; if the panel ever lives inside a parent
   <form> (the editor modal does not currently, but this is defense
   in depth), the click would submit the form and reload the page.
   Added type="button" plus @click.prevent.stop on the run button.

2. No loading visual. While the request was in flight, result was
   set back to null, so the result block disappeared with nothing
   in its place. The textarea was still on screen but the spacing
   shifted enough that users could read it as "section gone". Added
   a loading panel with t-loading spinner + status text.

3. Error display was too quiet. A tiny one-line error block could be
   missed entirely behind the modal's scrollable content. Made it
   visually prominent (bold prefix, full-width error background) so
   it can't be overlooked.

Bonus hardening:
- Stricter response-shape check (resp.success !== true || !resp.data
  catches malformed responses, not just non-200s).
- console.error with [KBChunkingDebug] prefix so the failure is
  debuggable from DevTools without enabling verbose logging.
- New i18n key chunking.debug.loading across all 4 locales.

https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-06 17:17:07 +08:00
Claude 8388a50c23 fix(chunker): post-review fixes for preview endpoint robustness
Resolves issues from the review of be326aa..119f5e4. Each fix has a
regression test attached and overclaimed findings (parserEngineRules
defensive copy, runTier dead-code branch, init-vars architecture)
were intentionally not touched after re-evaluation.

Goroutine leak mitigation
- previewMaxChars dropped from 256k to 64k runes. The splitter does
  not accept a context.Context, so when previewTimeout fires the
  worker keeps running. Bounding input size keeps worst-case CPU
  per request well under a second on commodity hardware. Sized so
  10 concurrent timeouts don't pile up faster than they finish.
- Frontend MAX_CHARS lowered to match.
- Comment in handler explains the trade-off and points at the
  follow-up: real cancellation needs the splitter to take a ctx.

Performance
- ApproxTokenCountFromRuneLen variant lets the preview handler
  reuse a single rune-count per chunk for stats + size + token
  estimation. Eliminates the previous triple []rune allocation per
  chunk in the response loop.
- computeChunkSizeStats now takes []int (pre-computed rune lens)
  instead of []chunker.Chunk; sumSq computed in float64 to avoid
  the int*int overflow at l > ~46k.

Correctness / UX
- Preview panel sends strategy / token_limit / languages
  unconditionally, mirroring the buildSubmitData convention so the
  preview faithfully reflects what would happen on save.
- Empty-text returns a friendly 400 ("paste a sample…") instead of
  gin's cryptic 'Field validation failed on the required tag'.

Tests
- TestSplit_DelegatesToSplitWithDiagnostics renamed to
  TestSplit_AndDiagnostics_AgreeOnChunks (the post-audit refactor
  made the original name a misnomer; the test still asserts the
  right invariant under the new name).
- New TestSplitWithDiagnostics_ProfileSetForAuto and
  TestSplitWithDiagnostics_ProfileNilForExplicit lock in the
  profile-reuse contract that the preview endpoint depends on.
- New chunker_debug_test.go covers computeChunkSizeStats edge
  cases (empty / single / varying / no-variance underflow) plus
  PreviewChunking httptest scenarios (auto path, legacy strategy,
  empty-text rejection, oversize rejection, chunk truncation with
  full-set stats).

Doc cleanup
- runTier comment updated; the "stubbed in this scaffold" line was
  obsolete since the heading and heuristic splitters shipped.

https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-06 17:17:07 +08:00
Claude beb7d005e9 fix(chunker): QA audit — pointer DTOs, profile reuse, stats correctness
Resolves the issues surfaced by the post-Phase-3 self-review.

High severity
- Strategy / TokenLimit / Languages can now be reset. The KB-config
  handler uses pointer DTOs so the absence of a field in the payload
  means "no change" while an explicit empty string / 0 / [] clears
  the value. The frontend now sends the fields unconditionally so
  the user can revert to defaults via the clear icon — previously
  these fields were write-once.
- DocProfile is no longer computed twice in the preview endpoint.
  Diagnostics carries the profile that drove tier selection (when
  auto-strategy ran); the handler only re-profiles for explicit
  strategies that bypass the profiler.
- Chunk-size stats (avg / min / max / stddev) are now computed over
  the FULL chunk set before the response is truncated to
  previewMaxChunks. Avoids systematically misleading metrics for
  large documents.
- SplitWithDiagnostics defaults SelectedTier to TierLegacy so an
  empty-text request never leaves the diag with a blank tier string.

Medium severity
- Split() reverts to its own loop instead of delegating to
  SplitWithDiagnostics. Diagnostics struct allocation is reserved
  for callers that actually want the trace (preview endpoint).
  Matters in SplitParentChild where Split runs once per parent.
- Preview endpoint runs the splitter on a goroutine wrapped in a
  5s context.WithTimeout. CJK input at the 256k-rune ceiling
  could otherwise tie up the worker for several seconds.

Low severity
- KBChunkingSettings emits arrays via spread copies so parent-side
  mutation cannot drift the form's reactive state.
- KBChunkingDebug font-family includes a monospace fallback so the
  chunk content stays monospaced even when the TDesign CSS variable
  is missing.

Documentation
- DocProfile JSON shape is now annotated as part of the public
  preview API; field renames would be breaking.

https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-06 17:17:07 +08:00
Claude 6864a9f9e2 feat(frontend): chunking debug panel with live preview
Adds a collapsible "Test with sample text" panel underneath the
chunking settings in the KB editor. Users paste a Markdown / plain-text
snippet, hit "Run preview", and see exactly how the current chunking
configuration would split it — without re-uploading any document.

The panel calls POST /api/v1/chunker/preview and renders:
- Selected tier (heading / heuristic / recursive / legacy) as a tag,
  with a warning when the chain fell through to legacy fallback
- Rejected tiers + reasons (so users see why "auto" picked tier X)
- DocProfile stats grid: lines, chars, headings, page-breaks,
  chapter markers, detected languages
- Chunk-size summary: count / avg / stddev / min / max
- Per-chunk cards with seq, size (chars + ~tokens), position range,
  context header (when set), content preview (expand/collapse)

The panel reads its config from the live form state so edits to
strategy / chunk-size / overlap / etc. are reflected on the next
preview run — no save needed.

Pieces:
- types/chunker.ts: TS types mirroring the backend response shape
- api/chunker/index.ts: previewChunking(body) wrapper
- views/knowledge/settings/KBChunkingDebug.vue: the panel component
- KBChunkingSettings.vue: embeds the panel + exposes a debugConfig
  computed prop
- i18n keys for en-US / zh-CN / ko-KR / ru-RU (8 keys each)

https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-06 17:17:07 +08:00
Claude 46d9c396c6 feat(frontend): expose chunking strategy in KB editor
Surfaces the adaptive 3-tier chunking controls in the existing
"Chunking" section of the KB editor modal. Users can now pick a
strategy from a dropdown without crafting JSON for the API:

- Automatic (recommended)  → backend profiler picks the tier
- Markdown-optimized       → forces heading-aware splitting
- Smart structure detection → forces heuristic boundary detection
- Classic                  → original recursive splitter (legacy)

The fifth backend value `recursive` is intentionally hidden from the
UI — it's functionally near `legacy` and would dilute the choice.

Advanced options (collapsible, disabled when strategy=legacy):
- TokenLimit (0–8192 approx tokens; 0 = char-based budget)
- Languages multi-select (DE/EN/ZH; empty = auto-detect)

Behaviour:
- New KBs default to strategy="auto"
- Existing KBs without the field render with empty strategy and keep
  classic behavior on save unless the user actively picks one
- Overlap warning when overlap >= chunkSize/2

Wired through:
- KBChunkingSettings.vue: strategy select + advanced collapsible +
  ChunkingConfig interface extended
- KnowledgeBaseEditorModal.vue: form-state defaults, kb-load mapping,
  buildSubmitData (chunking_config) + updateKBConfig (documentSplitting)
  pass strategy/token_limit/languages
- api/initialization/index.ts: types extended
- i18n: en-US / zh-CN / ko-KR / ru-RU all carry strategy + advanced
  keys (6 keys each)

https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-06 17:17:07 +08:00
wizardchen d46a51cf6e fix(security): forbid <style> in sanitized document HTML
DOMPurify was configured with USE_PROFILES.svg, which implicitly allows
<style> tags so that inline SVG styling works. User-authored markdown
rendered via v-html therefore let a pasted nginx error page's
<style>body { width: 35em; margin: 0 auto }</style> through the
sanitizer and apply as global CSS, squashing the entire app layout.

Add 'style' to FORBID_TAGS so top-level style elements from document
content are dropped regardless of the SVG profile.
2026-05-06 16:41:20 +08:00
wizardchen 6ac2f964ca feat(kb-list): replace type column with source and add description subtitle
Document list view relied on a redundant Type column (file extension is
already shown in the filename and icon) while hiding where a document
came from — external syncs from Feishu/Notion/Yuque, web URLs, manual
entries, and uploaded files were indistinguishable.

Swap Type for a Source column that resolves from `channel` first and
falls back to `type`, and surface `description` as a 12px subtitle under
the filename so the list view no longer requires hovering to read the
summary.
2026-05-06 16:41:20 +08:00
wizardchen 2d3f32de5c feat(frontend): replace standalone search page with global command palette
Reworks search from a siloed /platform/knowledge-search page into a
universal ⌘K palette plus natural, in-context entry points.

Why the old page felt out of place:
- "Search" was an action pinned next to entity routes (knowledge base,
  agent, organization), mixing noun- and verb-level navigation items.
- Its two tabs (knowledge vs. chat messages) forced users to pick a
  mental model before they knew what they wanted.
- It was also the only way to search at all — no global shortcut, no
  context-aware entry.

What this replaces it with:
- A new ⌘K/Ctrl+K command palette (GlobalCommandPalette.vue) mounted
  once in views/platform/index.vue. Results are grouped by type
  (files, messages, knowledge bases, agents, chat titles, commands)
  so users never need to pre-filter. Debounced, identity-keyed
  selection survives async arrivals (slow KB results no longer yank
  the highlight off the user's current row). ⌘1-9 jump shortcuts are
  rendered inline on each row for discoverability.
- Sidebar gets a visible "Search" entry at the top — clicking it
  opens the palette (no route change), with a platform-aware kbd hint
  (⌘K on Mac, Ctrl K elsewhere).
- KB detail page: opening ⌘K there auto-scopes the search to the
  current KB via a removable chip (Backspace in empty input also
  clears it); no separate embedded search bar needed.
- The legacy route /platform/knowledge-search now redirects to the KB
  list with ?cmdk= set, so existing bookmarks still work.
- KnowledgeBase.vue now handles both route-query changes and a
  window event (weknora:open-knowledge) for intra-KB navigation,
  fixing the silent-no-op when the palette jumps to a chunk in the
  already-open KB.

Dropped:
- frontend/src/views/knowledge/KnowledgeSearch.vue (1163 lines).
- The exploratory SessionSearchBar mode-switching widget in the chat
  submenu; ⌘K covers its use cases without a two-mode UI.

i18n: zh-CN / en-US / ko-KR / ru-RU updated together — new
commandPalette.*, kb.*, and menu.search keys; obsolete session.search.*
and menu.knowledgeSearch removed.
2026-05-06 16:26:22 +08:00
wizardchen 0be4572bd5 feat(kb-list): group pinned knowledge bases into a labeled section
On the KB list page, pinned items already sort to the top but look
identical to the rest, so at a glance you can't tell where the pinned
group ends. Add lightweight section headers ("置顶" / "其他") that
span the grid when the list transitions from pinned to unpinned, in
both the "全部" and "我的" tabs. Shared KBs never enter the pinned
group (backend doesn't pin them).

No divider line, no backend change — purely a visual grouping on the
existing sort order.
2026-05-06 12:33:04 +08:00
c f08192ba26 fix: include shared knowledge in knowledge search 2026-05-05 01:04:49 +08:00
toy0116 05d35c904b feat(frontend): respect BASE_URL so the SPA works behind a path-prefix reverse proxy
When WeKnora is mounted under a sub-path (Kubernetes Ingress with a
path-prefix rule, an Nginx `location /weknora/` block, a Cloudflare
Tunnel route, or any other reverse-proxy gateway), the frontend's
`getApiBaseUrl()` currently returns `''` and axios issues `/api/v1/...`
requests at the origin root — bypassing the sub-path entirely and
404'ing every backend call.

This change makes `getApiBaseUrl()` honor Vite's
`import.meta.env.BASE_URL` so that, when the bundle was built with e.g.
`vite build --base /weknora/`, axios produces `/weknora/api/v1/...`.
Trailing-slash stripped to avoid double slashes (`/weknora//api/v1/...`).

For deployments at the origin root (the common case), `BASE_URL`
defaults to `'/'` which strips to `''` — behavior unchanged from
upstream. No new build flag required; no behavior change for existing
users.

Reproduce the original problem:

  1. cd frontend && vite build --base /weknora/
  2. Serve dist/ behind Nginx at `location /weknora/`, proxy
     /weknora/api/* → backend.
  3. Open https://example.com/weknora/ → 404 on every API request
     because axios calls /api/v1/auth/test instead of
     /weknora/api/v1/auth/test.

After the fix the same setup just works.
2026-05-05 00:58:19 +08:00
wizardchen e4fe9d7d9b fix(i18n): remove duplicate liveIndicator key in ko-KR locale
Vite raised `Duplicate key "liveIndicator" in object literal` at
ko-KR.ts:4107. Both entries mapped to the same Korean translation so
the second is simply redundant. Removing it silences the warning
without changing any user-visible string.

Verified no other duplicate keys remain in en-US / zh-CN / ko-KR /
ru-RU with a brace-scope-aware scan.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 00:54:43 +08:00
Claude 35a5e29a23 fix(frontend): drop infectious preference fallback, add migration latch
QA review of the previous hardening commit identified two cross-user
infection paths created by the smart-fallback read chain (CRIT-1/2),
plus a UI-desync hazard from validation guards in setters (HIGH-1).

- Extracted localStorage helpers and migration logic into
  composables/preferenceStorage.ts as a single source of truth.
- Reads now hit only the active user's namespace - no anon / legacy
  fallback in the hot path. Pre-existing values are migrated **once**
  per active user via migratePreferencesIntoUser, which adopts anon
  and legacy keys into the user namespace and then deletes the source
  keys, so a second user logging into the same browser cannot inherit
  the previous user's preferences.
- Migration latch tracks which user has already been migrated this
  session; auth store's reloadUserPreferences resets the latch on
  setUser/logout so the next active user gets a fresh migration.
- setSansFont / setMonoFont / setFontSize / setTheme now return a
  boolean; GeneralSettings.vue handlers roll the form back to the
  canonical state when validation rejects a value, preventing the
  UI from drifting out of sync with the source of truth.
- safeSetItem now console.warn on persistence failures so quota /
  private-mode issues are at least diagnosable.
- applyFont is diff-aware: only the CSS variables that actually
  changed are written to the root style, avoiding unnecessary style
  recalculation when only one knob is flipped.
- applyTheme caches the last effective mode to skip redundant
  attribute writes and Wails IPC calls.

https://claude.ai/code/session_01S1FVPf4jRfWXkTSnpMmMp7
2026-05-05 00:48:40 +08:00
Claude 2e0b423057 fix(frontend): harden font/theme preferences for production edge cases
Edge-case review identified several issues that would degrade UX or
silently break under unusual conditions:

- Anon settings chosen on the login screen were lost on first login
  because the storage namespace switched from "anon" to the user id;
  resolveStorageValue now falls through user -> anon -> legacy, so
  pre-login choices carry over and v1 unscoped keys are still picked up.
- localStorage.setItem can throw under quota / private mode; setters now
  swallow the error so the UI still updates for the session.
- applyFont reduced to String(undefined) when currentSize held an
  invalid value; runtime fallbacks to the default scale guard against
  manipulated storage.
- Added var(--app-font-scale, 1) defaults to all 32 calc() expressions
  in theme.css and the body font-size, so a missing variable cannot
  void the calc() value.
- Validation guards in setSansFont / setMonoFont / setFontSize / setTheme
  reject invalid keys instead of writing them to storage.
- GeneralSettings.vue now watches the composable refs so the form stays
  in sync if preferences change externally (e.g. user switch while on
  the page).
- Dropped the unverified t-radio-group variant prop in favour of the
  default style.

https://claude.ai/code/session_01S1FVPf4jRfWXkTSnpMmMp7
2026-05-05 00:48:40 +08:00
Claude bafcbd5e5f feat(frontend): add font size, namespace UI prefs per user
Build on the font picker with three additions per user feedback:

- Font size selector (Small / Normal / Large) wired through a new
  --app-font-scale CSS variable; the body font-size and every
  --td-font-size-* token are wrapped in calc(... * var(--app-font-scale))
  so TDesign components scale together with the body
- localStorage keys for theme, font family, mono font and font size are
  now namespaced as WeKnora_${userId}_${key}; falls back to "anon" before
  login. Each user keeps their own preferences in the same browser
- auth store calls reloadFontFromStorage / reloadThemeFromStorage on
  setUser (when the active user changes) and in logout, so a user switch
  swaps the applied preferences without a reload

https://claude.ai/code/session_01S1FVPf4jRfWXkTSnpMmMp7
2026-05-05 00:48:40 +08:00
Claude f140c12518 feat(frontend): unify font rendering and add font picker in settings
The UI used hardcoded "PingFang SC" in 50+ components, while the global
font stack in App.vue used a different fallback chain. Outside of mainland
China this caused visibly different fonts in the sidebar, breadcrumbs,
search and agent views compared to settings and document panes.

- Introduce --app-font-family / --app-font-family-mono CSS variables in
  theme.css and route TDesign's --td-font-family through them
- Add a useFont composable that persists the user's choice in localStorage
  and applies it via document.documentElement.style before mount
- Replace hardcoded font-family declarations across the app with the new
  variables (TencentSans logo and the SVG attribute list are preserved)
- Add UI font and monospace font selectors in General Settings with
  i18n strings for en-US, zh-CN, ko-KR and ru-RU

https://claude.ai/code/session_01S1FVPf4jRfWXkTSnpMmMp7
2026-05-05 00:48:40 +08:00