This commit introduces a new utility function, `knowledgeSpansPayloadHasTrace`, to determine if the knowledge spans data contains a valid trace. Key changes include:
1. Updated the `KnowledgeBase` component to utilize the new trace availability checks, improving the logic for displaying trace-related UI elements.
2. Enhanced the `fetchSpans` function in the `knowledge-processing-timeline` component to emit trace availability based on the new utility.
3. Implemented caching for trace availability to optimize performance and reduce unnecessary API calls.
These changes aim to improve user experience by providing accurate trace information and enhancing the overall responsiveness of the UI.
This commit introduces a resizable trace drawer in the `doc-content` component, allowing users to adjust the width for better visibility. Key changes include:
1. Added functionality to save and load the drawer width from local storage.
2. Implemented mouse events for resizing the drawer, enhancing user interaction.
3. Updated the UI to reflect the new drawer width dynamically.
4. Enhanced the trace entry button for improved accessibility and clarity.
These changes aim to improve user experience by providing a more flexible and user-friendly interface for trace inspection.
This commit enhances the polling mechanism in the KnowledgeProcessingTimeline component by introducing a new function, `shouldPollNow`, which clarifies the conditions under which polling should occur based on the `gracePoll` prop. The documentation for `gracePoll` has been expanded to provide clearer semantics for both user-visible and background mounts. Additionally, minor formatting adjustments were made to improve code readability. These changes aim to streamline the polling behavior and enhance the overall user experience.
This commit introduces several improvements to the knowledge processing timeline and related components. Key changes include:
1. Added a `gracePoll` prop to the `KnowledgeProcessingTimeline` component to manage polling behavior more effectively.
2. Enhanced the UI by displaying the document title in the drawer, improving user visibility of the current document context.
3. Implemented new CSS classes for better styling of the drawer title bar, ensuring a more polished appearance.
4. Updated the backend to support the new `WikiSpan` tracking, allowing for detailed monitoring of document processing stages.
These changes aim to improve user experience and provide better insights into the document processing workflow.
This commit introduces a new method to open the trace drawer directly from the card menu, enhancing user experience by allowing immediate access to trace details without navigating through the document detail drawer. The implementation includes updates to the `handleViewTrace` function to ensure the correct knowledge ID and parse status are set before opening the trace drawer. Additionally, minor adjustments were made to the UI for better consistency and clarity.
Three fixes in response to user feedback:
1. Span input disappearing on End/Fail
The Upsert's DoUpdates always listed input/output/metadata, so calls
that only set output (EndSpan) or only set error_* (FailSpan) wrote
NULL into input/metadata, clobbering whatever Begin had recorded.
Build the column list dynamically: skip input/output/metadata when
the incoming row's value is nil. nil now means "preserve existing"
(matches user's intuition "Begin recorded it, End shouldn't erase it").
2. Subspans not auto-expanded
Stages with children (multimodal.image[*], postprocess.summary,
postprocess.question, postprocess.graph.chunk[*]) required a click
on the ▸ caret to surface — easy to miss. On the FIRST successful
fetch per (knowledgeId × attempt), auto-expand any stage that has
children. Subsequent polls honor whatever the user has collapsed,
so manual collapse mid-parse stays collapsed.
3. Auto-poll still not firing
Force-arm the polling interval in onMounted regardless of state.
The per-tick callback decides whether to actually fetch based on
current parse_status — so the loop can never get stranded waiting
on a status transition that already happened. Added a console.debug
when the interval arms, so we can verify from DevTools console that
polling is actually running.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
User report: opened a parsing-in-progress doc, /spans was hit ONCE on
mount and then never again — but parse_status said 'processing' and
the LIVE badge was lit. The setTimeout-based recursive scheduler had
a fragile property: any unexpected throw or skipped tick between the
finally block and the schedule check could silently strand the loop
with no way to re-arm.
Refactor to a self-healing pattern:
- setInterval polling: a single 2s tick checks "should we be polling?
and is no fetch in flight?" — if both, fire fetchSpans. Decision is
re-evaluated every tick from current reactive state, so flipping
status from 'processing' to 'completed' between ticks naturally
stops further fetches.
- ensurePolling() helper is idempotent — calling it from fetchSpans's
finally, from a parse_status watcher, and from onMounted all just
arm the same single interval if not already running.
- watch(data.value.parse_status) acts as a watchdog: any time the
status flips into 'pending'/'processing', re-arm. Any time it flips
out, tear down. This is the belt-and-suspenders that ensures the
loop can't get stranded even if a future regression re-introduces
a missed-schedule path.
- fetchInFlight guard prevents overlapping fetches if a slow backend
takes longer than POLL_INTERVAL_MS to respond.
- Console warns on fetch failure — silent rejections is exactly what
hid this bug. With this in place we can verify the loop's health
from DevTools console.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
User report: opening an already-completed doc still shows "更新于 X 秒前"
ticking up forever, which is misleading — the data IS final, no
freshness concern exists. Re-gate the caption on isLive (was always
on) so it only appears while pending/processing. Failures pill is
still gated on the same isLive condition, which is the only state
where polling-failure feedback is meaningful.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
User reported: spinner spinning + "更新于 X 秒前" continuously growing
without bound while parsing is in progress. The auto-poll loop IS
firing every 2s, but lastFetchedAt only updated on success — so when
the API returns success=false or errors, the caption silently aged
while the visible state suggested live polling.
- Move lastFetchedAt update into the finally block so it tracks
attempts (success or failure). The caption now bounces back to
"刚刚 / 1s 前 / 刚刚" every poll cycle, matching the spinner's
visual cadence.
- Track failedAttempts and lastFetchOk: when the last attempt failed
the timestamp shows in muted italic; when 2+ consecutive attempts
fail a small "⚠ 刷新失败" pill appears next to it with a tooltip
explaining the situation.
- New i18n keys fetchFailed / fetchFailedShort in zh-CN/en-US/ko-KR.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Trace trigger was a giant card-style row with a green left strip
sitting above 文件名/摘要 — visually competed with document content
and felt out of place vs. the rest of the app's quiet density.
Trace entry:
- Replaces the big card with a compact rounded pill in the drawer
header, next to the file-type t-tag.
- Reads as a quiet secondary action — status dot + label + duration
+ chevron — at the same visual weight as the file-type tag.
- Status dot still pulses while parsing is in progress so the LIVE
signal survives the size cut.
- Hidden mount preserved so the pill's status/duration stays live
even before the user opens the secondary drawer.
Refresh UX:
- "更新于 X 秒前" caption now always visible (was hidden once polling
stopped). After parsing completes it tells the user how stale the
data is when they reopen the drawer hours later — the original
reason it was hidden ("ticks up forever") is exactly the staleness
signal one needs.
- LIVE badge tooltip simplified from "解析中,每 2 秒自动刷新({n}s 后)"
(cryptic countdown) to "解析进行中 — 每 2 秒自动刷新".
- Manual refresh icon now slow-spins in brand color while auto-poll
is active — users can tell at a glance "auto-refresh is on" without
needing the LIVE badge to interpret. Manual click still triggers
the fast spin.
- Drops the unused nextRefreshIn computed.
i18n: liveTooltip rewritten in zh-CN/en-US/ko-KR; new keys
autoRefreshOn / autoRefreshOff for the button title states.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The post-process stage closes in ~9ms (just enqueue work) but its async
subspans (postprocess.summary, postprocess.question, postprocess.graph)
keep producing rows for tens of seconds AFTER the root finalizes. The
old timeline used trace.duration_ms as the time axis maximum, which
clipped those subspan bars past the right edge.
Timeline:
- totalMs now always takes max(trace.duration_ms, observed-tail), so
the axis stretches to fit the latest descendant end regardless of
parse_status.
- Render a faint dashed wrapping outline behind a parent span when
its descendants extend past its own finished_at, so the postprocess
stage row visibly spans the full window without overloading the
9ms self-time bar.
- Tree expand/collapse caret bumped from 10 to 14px in a 16x16 hit
area; copy icons in detail panel bumped from 11/14 to 14/18px;
.kp-kv-copy button grown from 18 to 22px.
- Short input/output payloads (<= 8 entries / <= 600 bytes JSON)
auto-expand inline so users see the actual data without an extra
click; longer payloads keep the click-to-expand summary.
Span payloads (subspans only - root keeps the canonical identity, no
duplicate knowledge_id/kb_id/tenant_id on every child):
- extract.go: graph subspan output gains chunk_chars, chunk_preview,
sample_nodes, sample_relations.
- summary subspan output gains model_id, summary_preview.
- question subspan output gains model_id and a sample_question
captured from the first non-empty LLM response.
i18n: new key knowledgeStages.detail.includingChildren for the
wrapping-bar tooltip.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Backend: summary, question, and graph-extract async tasks now record
real processing time as subspans hanging off the (closed) postprocess
stage, so the trace viewer no longer caps the postprocess row at the
~10 ms enqueue duration. Carries Attempt through SummaryGeneration /
QuestionGeneration / ExtractChunk payloads so cross-process workers
can resolve the right parent attempt.
Frontend: drawer now uses attach="body" so the secondary 820px detail
drawer escapes the 654px container of the main drawer; timeline
timestamps include date prefix (MM-DD, or YYYY-MM-DD across years);
"updated X ago" caption only shows during live polling.
Tests: 4 new cases covering postprocess subspan attaching under a
closed parent, missing-parent fallthrough, and Attempt JSON round-trip
on the three task payloads.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous Langfuse-style waterfall had concrete UX problems visible
in the field: the status text column wrapped Chinese characters across
two lines, the root span name truncated mid-identifier, the inline
detail expansion shifted sibling rows out of order, and the attempt
selector was a plain HTML <select>.
This commit rebuilds the visual layer around three corrections:
- Status column removed entirely. Status is conveyed by the 8 px dot
and the bar color; the redundant Chinese label that was wrapping
vertically is gone. Header subtitle now reads "总耗时 6.2s · ✓ 已完成"
via knowledgeStages.total + knowledgeStages.status.<value>.
- Inline row-detail replaced by a right-side drawer absolutely
positioned inside the timeline shell (overflow: hidden). Clicking a
row no longer reorders later rows beneath it. The drawer slides via
CSS transform, ESC and × close it, clicking the selected row toggles.
- Attempt <select> dropdown replaced by a horizontal pill tab strip
with a per-attempt status glyph (✓ / ✗ / ●). attemptStatuses Map
populates lazily — one /spans?attempt=n fetch per missing tab on
mount — so multi-attempt history doesn't block the initial render.
Drawer body shows the rich span data the backend just started
emitting: timing (started / finished / duration), an error block when
failed/cancelled, and Input / Output / Metadata as a 2-column
humanized key/value table. Numbers use toLocaleString, booleans render
as ✓/✗, arrays/objects collapse to a summary with a per-key "Show
JSON" toggle. Existing copySpan retains the raw JSON export path.
Root span name is now localized via knowledgeStages.root ("Knowledge
processing" / "知识处理") instead of leaking the raw identifier
"knowledge_processing" — which previously truncated as
"knowledge_process…".
i18n: added knowledgeStages.total and knowledgeStages.detail.{started,
finished, duration, input, output, metadata, error, showJson, hideJson}
to en-US, zh-CN, ko-KR, ru-RU. Compact mode (used by the card hover
popover) is untouched.
The root span created by OpenAttempt was never closed: PostProcess only
ended the postprocess stage, so the root row stayed at status=running
forever even after parse_status flipped to completed/failed. The
timeline rendered "进行中" indefinitely on the root, defeating the
whole "is the document done" question the timeline is meant to answer.
- SpanTracker.FinalizeAttempt(kid, attempt, status, output, code, msg):
closes the root row idempotently. Re-closing a terminal root no-ops
so success / cascade-fail / dead-letter paths can fire without
coordination.
- PostProcess.Handle calls FinalizeAttempt(done) after EndSpan(postprocess)
on the success path. Async downstream work (summary/question/wiki/
graph) still records its own spans; their completion extends the
trace's wall-clock end-time but doesn't reopen the root.
- FailSpan auto-closes the root when a MAIN pipeline stage fails
(docreader / chunking / embedding / multimodal / postprocess).
Cascade-cancelled siblings stay closed-with-the-cascade as before.
- Dead-letter callback (router/task.go) accepts the SpanTracker via
DI and calls FinalizeAttempt(failed, TASK_TIMEOUT) when a
document-related task exhausts retries. The probe payload now
extracts the Attempt field that Document/Manual/PostProcess
payloads already thread through.
Stage spans were also being recorded with nil input/output, leaving
the new detail panel with timestamps only. Each Begin/End site now
emits useful work metrics:
- DocReader input: file_name, file_type, is_url, url
output: text_length, images_found, is_audio, pages
- Chunking input: chunks_planned
output: chunks_written, total_text_chars
- Embedding input: chunks_to_embed, model_id, dim
output: vectors_written, storage_bytes
- Multimodal input: image_count, enable_ocr, enable_caption
- PostProcess output: chunks_total, enqueued_summary, _question, _wiki, _graph
i18n: add knowledgeStages.root ("Knowledge processing") so the UI
can render a localized name instead of the raw span identifier.
The five-circle pipeline conveyed only "which stage we're on" — operators
asked for the actual span tree (root → stages → batches/images), the time
each span took relative to the whole run, and the recorded JSON in/out.
This commit rebuilds the visual layer to match Langfuse's trace view
without touching the data layer (polling, attempt selector, retry,
copy-span and watchers all unchanged).
- Three-column grid (name | status+duration | bar): each span is one
row, indented by depth. Status dot 8px, name monospace, duration
right-aligned. Bars are absolutely-positioned inside a shared
timeline lane, left/width computed from each span's
started_at / duration_ms relative to trace.started_at and the run's
end (or "now" while running).
- Time ruler with five ticks (0% → 100%) above the bars; total
duration label on the right.
- Sub-spans (embedding.batch[i], multimodal.image[i]) collapsed
under each stage by default behind a chevron toggle. Click any
row to expand an inline detail panel showing ISO timestamps,
status, error_code/message when failed, and input/output/metadata
JSON blocks plus a "Copy span JSON" action.
- Removed the parse_status gate in doc-content: the timeline is now
always rendered when a knowledge detail is open, so completed
documents also expose their recorded pipeline for audit. The
KnowledgeBase hover popover stays compact-mode-only and still
gates on parse_status (popover height matters there).
- Running bars grow visibly via a 1s ticker (cleared on unmount).
- Last-error block restricted to parse_status === failed.
- Added knowledgeStages.totalDuration to en-US / zh-CN / ko-KR / ru-RU.
Renders a five-segment timeline (DocReader → Chunking → Embedding →
Multimodal → PostProcess) above each document so users can see exactly
which stage a document is in and which one failed, instead of a flat
"Parsing..." spinner.
- New KnowledgeProcessingTimeline component (full + compact mode):
full mode lives at the top of doc-content for any document not yet
in `completed`; compact mode replaces the parsing/failed lines in
the card hover popover with a five-dot mini-progress.
- Polls GET /api/v1/knowledge/:id/spans every 2s while
parse_status in {pending, processing}; stops on terminal status or
unmount. Hover popover instances opt out of polling to avoid
amplifying requests on grid hover.
- Failed / cancelled steps expand into an error card with the raw
error_message, an error_code -> localized title + suggestion mapping
for the twelve canonical codes (DOCREADER_TIMEOUT, EMBEDDING_RATE_LIMIT,
...), and a "Copy details" button that pastes the failed span JSON
for support tickets.
- Attempt selector renders only when latest_attempt > 1 so reparse
history is browsable; the latest attempt is selected by default.
- Last-error block under the timeline includes a Retry button that
calls reparseKnowledge() and immediately re-fetches.
- i18n strings added under knowledgeStages for en-US, zh-CN, ko-KR,
ru-RU. ja-JP locale file does not exist in this repository.
* feat(rbac): add multi-use share-link invitations for invite_only mode
When the auth.registration_mode toggle flips to invite_only, the public
/auth/register endpoint returns 403 — but until now there was no
channel for unregistered users to actually join a tenant. The existing
invitation table required a registered invitee, so new emails could
not enter the system at all.
This change introduces a share-link model:
- Owner generates a multi-use registration link with a per-tenant role
- Recipient opens the link, registers with their own email, and is
added to the tenant on the same request
- Token is stored in plaintext (not hashed) so the management UI can
re-display the URL on demand without a "copy now or revoke" trap.
Threat model is bounded by 7-day TTL, revocability, and the fact
that all the link grants is membership in one tenant.
- accepted_count tracks how many users joined through the link so the
Owner can tell whether a link is fresh or has already been spread
Per-user invitations (registered email -> in-app inbox accept) are
unchanged. Share-link rows use empty invitee_user_id as discriminator;
the partial unique index on (tenant_id, invitee_user_id) was relaxed
to skip empty values so multiple share links can coexist per tenant.
Frontend reuses Login.vue for /register?token=xxx instead of a
parallel page, and adds icon-only revoke / remove actions plus a
distinct "active" status tag for share-link rows.
Migration 000054 adds the token column, the accepted_count column,
and the relaxed pending unique index in a single step.
* feat(auth): update invitation token handling and add rate limiting
- Refactor the invitation token retrieval to use POST instead of GET, enhancing security by preventing the plaintext token from appearing in logs and browser history.
- Update the API endpoint from `/auth/invitations/:token` to `/auth/invitations/lookup` to reflect the new method.
- Introduce a rate limiter for unauthenticated share-link endpoints to mitigate brute-force attacks and abuse, ensuring a maximum of 30 requests per minute per IP.
- Adjust the registration flow to maintain user experience while securing the invitation process.
Drop the per-engine first-letter monograms on Vector Store / Storage /
Web Search cards in favor of real brand SVGs. Logos live under
`assets/img/providers/{color,mono}/<category>/<id>.svg`:
- color/: full-color vendor SVGs (gilbarbara/logos, svgl, vendor github)
rendered directly via <img>; covers qdrant, milvus, elasticsearch,
postgres, opensearch, sqlite, s3, minio, bing, duckduckgo, google,
ollama, searxng.
- mono/: single-color marks (simple-icons / vendor) rendered via
mask-image so the existing per-engine `color: <brand>` rule tints
them; covers doris, cos, obs, oss, baidu.
- Anything without a logo falls back to the existing monogram badge.
A small `providerLogos.ts` helper auto-discovers SVGs with
`import.meta.glob` and returns `{ mode, url }`; the three settings
views read it to pick the render path. Badge styles stay backwards
compatible: a `--logo` modifier swaps the brand-tinted background for
a neutral white card with a thin stroke when a logo is present.
The standalone "Test connection" button cluttered the title row
and the inline result bar made cards visually unstable as users
ran tests. Behavior change:
- Move "测试连接" into the more-actions dropdown as the first item.
env-source stores now also get a dropdown (test-only) instead of
showing a hidden placeholder button.
- Surface the result via MessagePlugin.success / .error toast and
drop the per-card testResults state, getTestResult(),
clearTestResult(), and the .store-card__result* SCSS rules.
- Keep an inline spinner in the title row while a test is in
flight, so the user still sees progress after the menu closes.
Bring vector stores in line with the rest of the settings list
redesign. The previous list-row layout (lock icon + 2 tags +
endpoint subtitle + buttons) carried the same "low" feel as the
old model/provider cards: flat, tag-heavy, no engine identity.
- Replace .store-list rows with a .store-grid card grid sharing
the same skeleton used by Parser/Storage/Mcp: a 36x36 monogram
badge tinted per engine_type (qdrant red, milvus blue, weaviate
green, elasticsearch amber, postgres blue, opensearch / infinity
purple, tencent_vectordb blue, doris orange, sqlite gray, others
fall back to brand blue).
- Title row carries the name + an env pill for read-only stores +
a low-contrast text-style "Test" button (admin-only) + the
hover-only ellipsis menu (edit / delete, user stores only).
- Subtitle: engine_type · endpoint (monospaced, truncated).
- Test result keeps its inline success/error bar but rebuilt as
store-card__result so it lives inside the card instead of
hanging off a sibling row.
Drops the .store-list / .store-item / .item-* / .test-result-*
selectors that were only ever used here.
Bring the engine selectors in line with the rest of the redesigned
settings cards (Model / WebSearch / Mcp). Same skeleton: leading
36x36 monogram badge tinted per engine, clean title row, dot+label
status pill, two-line description, brand-color outline when the
config drawer is open for that card.
Parser engines:
- Replace the bespoke .engine-card markup with a button-based card
carrying a badge derived from the localized display name.
- Keep available/unavailable as a status pill (green dot / red dot)
instead of t-tags, retaining the unavailable-reason tooltip via a
dedicated --help variant.
Storage engines:
- Collapse the eight hand-written cards into a single v-for over a
STORAGE_PROVIDERS array; titles, monograms, and statuses funnel
through providerTitle/providerInitial/providerStatus helpers so
adding a future engine only needs an array entry plus translations.
- Status pill mirrors Parser/Mcp idioms: green for available /
configurable, gray for "needs config" (currently MinIO-only).
Drops the now-unused .engine-card-header/.engine-card-desc/
.tag-with-tooltip rules.
- Web search: drop the "default" and "free" pills from the card
header; the provider type subtitle and the existing form-side
free badge already cover this, and three rows of pills made the
cards feel busy.
- MCP: collapse the inline switch and the on/off tag into a single
on/off status pill (dot + label), and move the actual flip into
the more-actions dropdown as the first item. Built-in services
keep showing the "builtin" pill instead, since they're not
togglable.
Drops the now-unused isEntityFree helper and the .provider-card__pill
SCSS variants.
Apply the model-card pattern to the other two provider lists in
the new "Data & Extensions" group so they share one visual idiom.
Web search providers:
- Drop the 3-tag row (provider type / default / free) for a 36x36
monogram badge tinted per provider (duckduckgo, bing, google,
tavily, baidu, searxng, ollama).
- Title row carries the entity name plus optional "default" /
"free" pills; the more-actions button hides until hover/focus
and opens on click.
- Subtitle reads "Provider type · description"; proxy URL drops
to a muted monospaced last line, no leading icon.
- Grid is responsive: repeat(auto-fill, minmax(320px, 1fr)).
MCP services:
- Same skeleton with a transport-type badge (sse → cast / sse-green,
http-streamable → link / brand-blue, stdio → code / amber).
- Keep the inline enable switch, but slot it into the title row so
the card stops repeating "on/off" as a tag.
- Builtin services keep the muted background to signal read-only.
- Three-dot menu hides until hover/focus and opens on click.
Drops dead CSS (.provider-meta-item, .service-meta-item, the old
2-column grids) and the now-unused SettingCard imports. SettingCard
itself is left in place for future consumers.
The two-column model list looked low-res because every card
shared the same skeleton, with three saturated tags and a raw
baseUrl meta line carrying most of the visual weight.
Replace SettingCard usage on this page (other consumers — Mcp
and WebSearch settings — keep using it untouched) with an inline
ModelCard built around:
- A 36x36 leading badge per model type (chat, embedding, rerank,
vllm, asr) with low-saturation tinted backgrounds and a
matching tdesign icon, so users can scan by type at a glance
instead of decoding tag colors.
- Title row with the model name and an optional muted "builtin"
pill; the more-actions button only appears on hover/focus and
opens the dropdown on click (not hover) to match the rest of
the app.
- A muted subtitle (type · source · embedding dimension) and a
monospaced, single-line truncated baseUrl as the last line —
so secondary info reads as secondary.
- Responsive grid: repeat(auto-fill, minmax(320px, 1fr)) so
wider modals get 3 columns and narrow viewports collapse to 1.
Drops dead CSS (.model-type-tag-* color rules, the page-wide
:deep(.t-tag) override, .model-meta-item) and the now-unused
SettingCard import.
Sidebar UX polish for the Settings modal:
- Regroup nav into 5 cleaner buckets: Account / Workspace /
Models / Data & Extensions / Platform. Personal preferences
(general) and credentials (api) move to Account; chathistory
follows its scope into Workspace; integrations and engines
merge to avoid two narrow groups.
- Pin the sidebar header (title) so it stays visible while the
nav list scrolls; move overflow from the sidebar wrapper to
the nav list itself.
- Tighten paddings/font sizes a notch for higher information
density without sacrificing hit targets.
- Sync the four locale files (zh-CN as source of truth, plus
en-US, ko-KR, ru-RU): drop workspaceAccount / integrations /
knowledgeInfra; introduce account / workspace / dataExtensions.
The system_settings update, system admin promote/revoke, and
apply-default-storage-quota routes have been writing audit rows since
the prior commits, but with TenantID=0 (system-scope). The per-tenant
GET /tenants/:id/audit-log endpoint filters by tenant_id and never
returns them, so until now those rows existed only in the DB with no UI
surface. This commit closes the loop:
Backend:
- GET /api/v1/system/admin/audit-log: new SystemAdmin-gated endpoint
reusing AuditLogService.List with tenant_id=0. Same cursor-paged
shape and query params (after_id / limit / action / outcome / actor)
as the per-tenant feed, so the frontend reuses the same client logic.
- Wired through RegisterSystemAdminRoutes (mounted on the existing
adminRoutes group so it inherits the SystemAdmin() guard). The
handler dependency is optional: nil auditLogHandler skips the route,
mirroring RegisterTenantRoutes' /audit-log handling.
Frontend — new platform audit drawer in SystemSettings.vue:
- "审计日志" entry button in the section header opens a side drawer
(880px) listing system-scope events. Lazy-loaded on first open;
refresh is explicit via a button inside the drawer.
- Table columns: stacked date/time (so 50 events in the same minute
remain distinguishable), stacked actor/role, action tag, structured
target (subject key + diff line), outcome. The dead request column
(system actions don't go through middleware path capture) is dropped
in favour of richer target rendering.
- Per-action target formatters:
* system.setting_changed: subject = registry key, diff = `old → new`
(JSON-encoded, 80-char truncation). Reset shows `old → (空)`.
* tenant_storage_quota bulk apply: subject = "批量同步", diff =
"applied to N tenants (X GB)".
* system.admin_promoted / revoked: subject = "name (email)", diff
annotates idempotent / noop branches so an audit reader can tell
a real grant from a probe.
- Click-to-expand row reveals the full audit context: actor UUID,
target_user_id / target_type / target_id, and raw details JSON in
monospaced scroll-capped block. No psql round-trip needed for
forensic spot checks.
- Sticky thead pinned to the scroll container so column labels survive
long scrolls. Cells vertical-aligned middle to keep single-line tag
cells visually balanced against multi-line target cells. No zebra
stripes — the stacked content already provides row separation, and
stripes on top read as noise.
Frontend — same polish back-ported to TenantMembers.vue audit drawer:
- Same drawer width, stacked time / actor cells, structured target +
diff layout, expandable raw-details row, sticky thead, vertical-
align middle, no stripes. Refresh button reformulated as a text
button with label (was an outlined square icon-only).
- request_path column kept (rbac.access_denied carries meaningful
paths) but empty values render as a placeholder dash so they don't
read as broken.
- Diff line now covers rbac.invitation_sent / invitation_revoked role
in addition to the existing role_changed / access_denied details.
API:
- frontend/src/api/system/index.ts: listSystemAuditLog() reuses the
AuditLog / ListAuditLogParams types from @/api/tenant/audit-log
(re-exported) so consumers don't need to cross-import.
i18n (zh-CN / en-US / ko-KR / ru-RU):
- system.globalSettings.audit.*: full drawer copy + per-action labels
(system.setting_changed / admin_promoted / admin_revoked) + target
diff templates + expanded-row labels.
- tenantMember.audit.expanded.*: expanded-row labels added so the
shared drawer treatment renders cleanly under tenant scope.
Replace the standalone /platform/system/* routes with a single
"系统设置" section inside the canonical Settings modal. The previous
SystemLayout.vue / SystemAdmins.vue surfaces are removed and their
functionality (system admin roster, global settings) is hosted directly
in SystemSettings.vue under the standard `.section-header` /
`.settings-group` skeleton. Legacy URLs redirect to the modal section
so external bookmarks don't 404.
Backend:
- SystemSettingService.Reset + repo.Delete: drop the DB override for a
key so the 3-tier resolver falls back to ENV / built-in default.
Idempotent (resetting a never-persisted key returns nil); emits an
audit row only on real deletions, invalidates the local cache, and
publishes to peers via the existing pubsub channel.
- TenantService.BulkSetStorageQuota: overwrite every tenant's
storage_quota in one statement. Powers POST /system/admin/tenants/
apply-default-storage-quota; bypasses the per-tenant whitelist on
PUT /tenants/:id which intentionally forbids storage_quota edits.
- AuditAction{SystemAdminPromoted,SystemAdminRevoked} constants and
emitAdminAudit() in SystemHandler — promote / revoke now leave an
audit trail with TenantID=0 and {target_email,target_username,
idempotent|changed} in details.
- SystemSetting.LastModifiedByName: derived per-request display label
(username, email fallback) so the UI shows "wizardchen" instead of
a UUID prefix without storing a denormalised column.
Frontend:
- SystemSettings.vue rewritten against the Settings modal skeleton with
auto-persisting controls (switch/select @change, input/inputnumber
@blur, tag-input + per-delta popconfirm for SSRF whitelist and admin
roster). auth.registration_mode change goes through an inline
popconfirm; cancel rolls back. Reset / bulk-apply also inline
popconfirms — no dialog modal for these per-row affordances.
- Priority hint panel surfaces the DB > ENV > default resolver order
so operators can reason about "I set the env but it doesn't show up".
- Router: /platform/system, /platform/system/settings, /platform/system/
admins are now compatibility redirects to /platform/settings?section=
system-global.
- Settings modal sized 900x700 → 1080x780 and content-wrapper 600 → 760
so the wider tables (members, system settings) breathe; <1100px
viewport still flexes to the screen.
- i18n: system.globalSettings.* keys for title / description / loading /
empty / badges / priority hint / per-key labels / reset / bulkApply /
admins (label, placeholder, save messages, popconfirm copy) across
zh-CN, en-US, ko-KR, ru-RU.
Misc:
- internal/utils/filesize.go doc: clarify MAX_FILE_SIZE_MB is a
deploy-time-only knob (nginx + docreader + frontend each cache the
env at startup); a SystemAdmin UI override would mislead operators
because nginx would still 413. Until all four layers can hot-reload
the limit in lockstep, this stays env-only.
- internal/utils/security.go: SSRF whitelist parser/runtime now drives
off SystemSettingService for live updates; ENV remains the fallback
for never-overridden deployments.
- Consolidated global system settings into the standard Settings modal, improving accessibility and user experience.
- Updated routing to redirect system settings to the new modal structure, ensuring a seamless transition for users.
- Enhanced UI components for better responsiveness and visual clarity, including adjustments to layout and styling.
- Added visibility controls for system admin-specific settings, ensuring proper access management.
- Refactored related comments and documentation for improved clarity on the new settings structure.
- Added WEKNORA_BOOTSTRAP_SYSTEM_ADMIN_EMAIL environment variable to promote a specified user to system admin on startup.
- Introduced a new bootstrap process in `bootstrap.go` to handle the promotion logic.
- Updated `.env.example` to document the new environment variable and its behavior.
- Created new views for managing system administrators and system settings, including listing, promoting, and revoking admin privileges.
- Enhanced the frontend to reflect the new system admin features, including UI elements for admin management and settings configuration.
- Updated API interfaces to support system admin functionalities, ensuring proper data handling and user management.
When selecting an agent from the chat page's agent selector dropdown,
built-in agents other than `builtin-quick-answer` and
`builtin-smart-reasoning` trigger the wrong toast. "Switched to
Intelligent Reasoning" pops up regardless of which agent was actually
picked — Wiki Questioner, Data Analyst, Wiki Fixer, etc.
Root cause: the toast logic checks only `agent.is_builtin`, then
branches on `agent_mode === 'smart-reasoning'` to pick between the
"Switched to Intelligent Reasoning" / "Switched to Quick Q&A" strings.
Those strings were designed for the two original built-ins
(`builtin-quick-answer` and `builtin-smart-reasoning`), which the
dropdown re-brands as "Normal Mode" / "Agent Mode". They don't make
sense for any other built-in.
Narrow the special-case branch to those two IDs. Other built-ins fall
back to the generic `agentSelected` toast (the path custom agents
already take), so they get a toast naming the agent that was actually
selected.
Start new agents with an empty context_template so mode-switch logic can
populate the system default instead of keeping the smart-reasoning placeholder.
Co-authored-by: Cursor <cursoragent@cursor.com>
Added a new KBSwitcherDropdown component to enhance the user experience when selecting knowledge bases. This component displays a list of knowledge bases with the current selection highlighted, allowing users to easily switch between them. Integrated the dropdown into both KnowledgeBase.vue and FAQEntryManager.vue, replacing the previous dropdown implementation for a more streamlined and consistent UI. The new component supports dynamic updates and maintains the order of knowledge bases while ensuring the current selection is always visible at the top.
Updated the styles for the info button in KBInfoPopover.vue to enhance its appearance and interaction. Adjusted dimensions, colors, and hover effects to create a clearer distinction between the info button and the settings button. Added a warning state for better visual feedback when necessary. These changes aim to improve user experience and maintain consistency in the UI design.
Refactor the logic in KBInfoPopover.vue to differentiate between FAQ and document knowledge bases. The component now uses `chunk_count` for FAQ KBs and retains `knowledge_count` for document KBs, ensuring accurate representation of entry totals. This change aligns the display logic with the intended user-facing metrics for each KB type.
Move the info popover (intro'd in the previous commit) into a
dedicated `frontend/src/components/KBInfoPopover.vue` component so
both the document KB header and the FAQ KB header can share the
exact same metadata surface.
- KnowledgeBase.vue: replace the inline popover and the now-dead
helper computeds (kbLastUpdated, kbHasDistinctUpdate,
infoCardCapabilities, infoCardChunking, infoCardStats,
chunkingStrategyLabel, supportedFileTypesList, accessRoleLabel,
accessPermissionSummary) and their CSS with a single
<KBInfoPopover> tag. The page still fetches parser engines and
forwards the supported file types so the "Accepted formats" row
renders for document KBs.
- FAQEntryManager.vue: drop the legacy inline meta strip
(role tag · share source · last updated) along with the
accessRoleLabel / accessPermissionSummary / kbLastUpdated /
effectiveKBPermission computeds it only served, and wire the
same <KBInfoPopover> into the actions cluster next to the
settings button. FAQ KBs don't pass supportedFileTypes so the
format row simply hides itself.
- KBInfoPopover.vue: self-contained — re-derives access role,
shared-binding and chunking config from kbInfo + the org/auth
stores. supported-file-types remains an opt-in prop so callers
decide whether the parser-engine pipeline is relevant.
No user-visible regressions: both pages now render the same
Basic / Access / Capabilities / Chunking / Stats / Storage
Binding sections, with rows hiding when they don't apply.
Replace the inline meta strip on the knowledge base detail header
(role tag · share source · last updated · vector store badge) and
the vector-store engine badge on the list cards with a single
structured "info" popover next to the settings button.
The popover groups Basic, Access, Capabilities, Chunking, Stats
and Storage Binding into separate sections, only rendering those
with data. A warning dot on the info button surfaces unreachable
vector-store bindings without occupying header real estate. The
popover caps at min(70vh, 560px) with an internal scrolling body
so it never overflows the viewport.
Hide the last-updated row when it equals created_at, since GORM
only bumps KB.updated_at on metadata edits — never on document
uploads — so surfacing two identical timestamps next to "created
at" was misleading. Once the KB metadata is actually edited the
row reappears naturally.
i18n entries added for zh-CN, en-US, ko-KR, ru-RU.
The per-card "more actions" popover (edit / rebuild / move / delete ...)
stayed open when clicking "Delete document", so the popover floated above
the t-dialog and visually obscured the confirmation dialog.
Reset the card's isMore flag and moreIndex inside delCard before toggling
delDialog so the popover closes synchronously with the dialog opening.
DeleteKnowledge is now an async pipeline on the backend, so refreshing the
list immediately after a successful response can still show the deleted
entry. Mirror the polling loop already used for batch delete: re-list up to
~12s (30 polls * 400ms) until the deleted id disappears, then refresh tags.
Without this the UI shows "delete success" but the list visibly contains
the entry until the user manually refreshes.
The user font-size preference applies CSS `zoom` on `<html>`
(see `composables/useFont.ts`). This breaks every popover that
anchors itself with `getBoundingClientRect()` + `position: fixed/absolute`,
because the rect is in visual pixels while CSS lengths are then
multiplied by zoom again — shifting popovers toward the lower-right
and miscomputing maxHeight / width / viewport-edge clamping.
PR #1459 patched only `AgentSelector.vue` (and left its width/maxHeight
unfixed). This PR introduces a shared helper `frontend/src/utils/zoom.ts`
(`getRootZoom`, `rectToCssPx`, `cssViewportSize`) and applies it to every
affected popover:
- `AgentSelector.vue` — refactored to use the helper; also normalizes
`width` and `maxHeight` (previously still in visual px).
- `Input-field.vue` — model dropdown, mention popup (typed @ and button-
triggered), and agent-mode dropdown.
- `KnowledgeBaseSelector.vue` — primary anchor path and fallback path.
- `UserMenu.vue` — tenant and IM floating submenus + viewport clamp.
- `FAQTagTooltip.vue` — fixed tooltip positioning + edge clamp.
- `AgentEditorModal.vue` — placeholder popups for system_prompt,
context_template, and rewrite/fallback prompts.
- `AgentStreamDisplay.vue` — `kb-float-popup` (absolute under body, also
under the zoom containing block).
Verified with `npm --prefix frontend run build`.
Add a link in the wiki page header that navigates to the graph tab
with the page slug pre-selected, so users can jump from a wiki page
to its corresponding graph node in one click.
After re-login, the JWT is minted with the user's last-active tenant
(see userService.resolveLoginTenantID). Both TenantSelector and
UserMenu used to clear weknora_selected_tenant_id when "switching to
home", which made request.ts stop attaching X-Tenant-ID. Without the
header, the auth middleware fell back to the JWT-encoded tenant id —
i.e. the peer tenant the user just tried to leave — so the switch was
silently a no-op until the user manually wiped localStorage and
re-logged in.
Always write the active tenant id into selectedTenantId so the
"always attach X-Tenant-ID" invariant request.ts relies on stays
true. The server-side last_active_tenant_id preference is still
cleared when switching to home, so a clean re-login still lands the
user on home.
Also fix TenantSelector.defaultTenantId to read user.tenant_id (the
immutable home id) instead of authStore.tenant.id (the active tenant,
which is overwritten by /auth/me). This matches the contract spelled
out in useHomeTenant() and prevents switchingToHome from misfiring
when the active tenant differs from home.
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
Keep the member search input visible during empty/loading states, avoid layout jitter on search, simplify role select display, widen the role column, and use icon-only edit buttons for tenant name/description.
Tenant RBAC headline release: 4-tier role matrix (Owner/Admin/
Contributor/Viewer), per-KB resource ownership, per-tenant audit
log, tenant member management, self-service workspaces.
Also: CLI v0.3/v0.4 GA, KB retrieval fan-out across vector stores,
AES-256-GCM credential at-rest, docreader gRPC TLS+Token, Zhipu
embedding, Huawei OBS, vLLM URL for MinerU, Apache Doris compat
modes, server-side user preferences, Go 1.26.0.
See CHANGELOG.md for the full list.
docs(rbac): wire RBAC screenshots into READMEs and RBAC guide
- README.md / README_CN.md / README_JA.md / README_KO.md: replace the
single member-management thumbnail under the v0.6.0 RBAC highlight
with a 2×2 showcase (member management, workspace switcher,
self-service workspace creation, pending invitations).
- docs/RBAC说明.md: add the member-management screenshot to the
existing 前端实际界面 showcase so the guide is self-contained
and no longer cross-references README for it.
feat(rbac-ui): link tenant member page to RBAC guide
Add an inline doc-link in the Tenant Members settings page that
opens docs/RBAC说明.md on GitHub in a new tab, complementing the
existing in-app role-matrix popover. New i18n key
tenantMember.learnRbacGuide covered for zh-CN / en-US / ko-KR /
ru-RU.