Commit Graph

36 Commits

Author SHA1 Message Date
wizardchen 559b5a6e20 feat(ui): render workspace-context notifications with styled chips
The login-success and tenant-switch toasts previously showed the
workspace name and role inline as bracketed plain text, which read
flat and made the two key data points hard to scan at a glance.

Render them through a shared `renderWorkspaceNotifyContent` helper
that produces a NotifyPlugin VNode with:

* a neutral rounded chip for the workspace name (with a generic
  workspace icon), and
* a role-coloured chip for the role (with the existing per-role icon
  from useRoleLabel), so owner / admin / contributor / viewer each
  get a distinct visual identity that matches the role badges used
  elsewhere in the product.

The i18n templates lose the surrounding 「」 / "" / «» quote marks
because the chip itself now provides the visual delineation; double
emphasis looked off. Translators control the surrounding wording via
`{name}` and `{role}` placeholders and the renderer splits on those
markers to interleave plain text and chips in the original order.

The PendingTenantSwitchToast payload (sessionStorage-stashed for the
hard-reload survival trick) grows a `roleEnum` field so the post-
reload toast can colour the chip — without that, the switch toast
would fall back to a neutral chip while the login toast got the
colour treatment.

Note on icon resolution: the chip renderer imports TDesign's `Icon`
component directly rather than referencing it by string tag in `h()`
— Vue's render function does not auto-resolve component names the
way templates do, so `h('t-icon', ...)` would silently render an
unknown HTML element.
2026-05-18 20:37:57 +08:00
wizardchen 0cdb922d84 feat(tenant): remember user's last-active workspace across logins
Until now a fresh login (new device, expired refresh token, cleared
browser) always dropped the user into their home tenant, even if they
spend most of their time in a peer workspace. The session-local
X-Tenant-ID override in localStorage gave a "same browser sticky"
effect, but never crossed devices or new sessions.

This adds a small server-side preference, `users.preferences.
last_active_tenant_id`, persisted in the existing jsonb column (no
new migration), and threads it through:

* Backend
  * `UserPreferences` gains `LastActiveTenantID *uint64` with sentinel
    semantics (`*0` from the PATCH endpoint = clear preference).
  * `resolveLoginTenantID` validates the stored id (tenant still
    exists + active membership, or CanAccessAllTenants) and falls
    back to home on any failure, best-effort clearing the stale
    preference so subsequent logins don't pay for it again.
  * `Login` and `LoginWithOIDC` resolve once and use the result for
    both the JWT `tenant_id` claim and the returned `active_tenant`,
    keeping the two in sync. `RefreshToken` rides through
    `GenerateTokens` so refresh rotations also land the user back in
    their preferred tenant instead of bouncing to home.
  * `UpdateUserPreferences` learns to merge the new key.
  * `PUT /auth/me/preferences` accepts the new field.

* Frontend
  * `Login.vue` now writes the user's HOME tenant id into
    `user.tenant_id` (matching the field's documented semantics) and
    expresses any active-vs-home divergence via `setSelectedTenant`,
    so `useHomeTenant` and the "current"/"home" badges stay correct
    after the backend honours a remembered preference. `App.vue`'s
    OIDC sync does the same reconciliation.
  * `TenantSelector`, `UserMenu` and the post-tenant-create handlers
    fire `persistLastActiveTenantPreference` after every successful
    user-initiated switch (switching to home sends `0` to clear).
    The call is raced against the existing reload-grace window so
    most writes finish before the page tears down; lost writes are
    recoverable on the next switch.

No new UI. Users will simply notice that, after re-logging in on
another device, they land back in the workspace they were last
using rather than always in their home tenant.

Note: `make docs` is unrelated-broken on `main` (audit_log.go
references `errors.AppError` which swag can't resolve), so the
Swagger artifacts under docs/ are intentionally not regenerated
in this PR. The handler code is the source of truth.
2026-05-18 20:37:57 +08:00
wizardchen 0655b545be feat(tenant): show rich workspace-switch confirmation that survives reload
Replace the lightweight "switch success" message with a richer
NotifyPlugin notification that reports the new workspace name and the
user's role in it. Because the post-switch flow does a hard reload,
the notification is stashed in sessionStorage before navigation and
consumed by App.vue on the next mount, so the toast actually appears
on the destination page with its full 6s duration instead of being
torn down a frame after it is shown.

For the cross-tenant superuser path (TenantSelector), the role line is
omitted when the user has no membership row in the target tenant,
avoiding a misleading empty/raw role value. Role labels are formatted
through the shared useRoleLabel composable so any future role text
change still lives in one place.

i18n keys updated across zh-CN, en-US, ko-KR, ru-RU.
2026-05-18 19:39:53 +08:00
wizardchen 68ac7fb973 feat(user-preferences): implement user preferences management with backend support
Added functionality for managing user preferences, including the ability to update preferences via a new API endpoint. The preferences are now stored server-side, allowing for synchronization across devices. Updated relevant components to handle user preferences, including the UserMenu and settings views. Enhanced internationalization support for error messages related to preference updates.
2026-05-18 17:28:58 +08:00
wizardchen 3226cb97ff feat(user-menu): add QuickNav entry for members with role-based visibility
Introduced a new QuickNav menu item for 'members' in the UserMenu component, allowing users with the appropriate role to access member-related functionalities. Updated the role alignment for QuickNav entries to ensure consistency with the Settings component. This enhancement improves navigation for users based on their permissions.

Refs: #1303
2026-05-18 17:28:58 +08:00
wizardchen b0b05b49c5 feat(tenant): enhance tenant information update with description field and add global invitation bell component
Updated the tenant information API to allow editing of both name and description fields, improving user experience in managing tenant details. Introduced a new GlobalInvitationBell component to display pending invitations in the UI, ensuring users can easily access their invitations without navigating away from their current context. Additionally, updated internationalization files to support new description-related messages.

Refs: #1303
2026-05-18 17:28:58 +08:00
wizardchen 884ac44283 feat(invitations): implement pending invitations feature with polling and dialog
Added functionality for managing pending invitations, including a polling mechanism to update the invitation count in real-time. Introduced a new dialog component for users to view and respond to their invitations without navigating away from their current context. Updated API endpoints for fetching and managing invitations, and enhanced the user interface with relevant internationalization support.

Refs: #1303
2026-05-18 17:28:58 +08:00
wizardchen 3693f977ab style(menu, UserMenu): adjust padding and dimensions for improved layout
Modified padding values in menu.vue and UserMenu.vue to enhance the visual consistency of the components. Reduced padding in various elements and adjusted avatar sizes for a more cohesive design. These changes aim to improve the overall user interface without altering functionality.

Refs: #1303
2026-05-18 17:28:58 +08:00
wizardchen dc0671899e feat(tenant): enhance CreateTenantDialog layout and styling
Updated the CreateTenantDialog component to improve the header layout by adding an icon and title for better visual clarity. Introduced new CSS styles for the header to enhance the overall user experience. Additionally, adjusted font sizes in UserMenu.vue for consistency across the application.

Refs: #1303
2026-05-18 17:28:58 +08:00
wizardchen 6c523144bf feat(tenant): update tenant creation dialog and internationalization
Refactored the CreateTenantDialog component to enhance the user experience by improving the layout and adding a subtitle for clarity. Updated the internationalization files to reflect changes in terminology from "tenant" to "workspace" across multiple languages, ensuring consistency in user messaging. This includes adjustments to prompts and labels related to workspace creation.

Refs: #1303
2026-05-18 17:28:58 +08:00
wizardchen 29dc99ae79 feat(tenant): implement self-service tenant creation functionality
Added a new API endpoint for creating tenants, allowing any logged-in user to create their own workspace. The backend automatically assigns the creator as the Owner of the new tenant. A new CreateTenantDialog component was introduced in the frontend, enabling users to input the workspace name and an optional description. Internationalization files were updated to include relevant messages for this feature across multiple languages.

Refs: #1303
2026-05-18 17:28:58 +08:00
wizardchen 79d397297d refactor(UserMenu): streamline template structure and improve readability
Refactored the UserMenu.vue component by consolidating template elements and removing unnecessary line breaks. This change enhances the overall readability of the code while maintaining the existing functionality of the user menu.

No functional changes were made; the focus was solely on code clarity.

Refs: #1303
2026-05-18 17:28:58 +08:00
wizardchen e7f9a6580a feat(rbac-ui): rework tenant identity surfaces
Polish the role-aware UI surfaces wired up in #1303 so role / tenant
context is discoverable from the main shell rather than buried in a
hover-only switcher or the settings drawer.

UserMenu sidebar trigger:
- Replace username + email with `tenant name / username · role-icon
  role-name` so the active tenant + current role are always visible at
  the bottom of the sidebar; long usernames elide before the role label.
- Single-tenant users keep the old username + email layout.

UserMenu dropdown:
- Promote the tenant switcher to a clickable header row at the top of
  the dropdown (tenant name + swap icon, role caption underneath).
- Drop the standalone "Switch tenant" submenu entry — the header row
  hosts the same hover panel.
- Switcher panel rows now lead the role label with a role icon
  (owner / admin / contributor / viewer) and surface the home tenant
  via a small home dot on the avatar instead of a separate badge, so
  the right-edge "current" badge column lines up across rows.

Settings:
- Add SECTION_MIN_ROLE so settings nav entries are gated by the same
  role matrix the backend enforces (chathistory + ollama + websearch +
  vectorstore + parser + storage + mcp → admin; api → owner; rest →
  viewer). UserMenu quickNav uses the same map.
- Render a role-denied empty state when a user deep-links into a
  section their role can't reach.
- Split account info (id / username / email / created_at) out of the
  owner-only API Info page into a new viewer-accessible UserProfile
  section.

Composable:
- New useRoleLabel composable centralises role → label and role → icon
  mapping (consumed by UserMenu trigger / dropdown / switcher panel).
- useHomeTenant derives the home tenant id from `user.tenant_id` (the
  immutable signup-time field), not `tenant.id` which now reflects the
  active tenant after a switch.

Lists:
- KnowledgeBaseList / AgentList default the sidebar selection to "all"
  for viewers (who typically own nothing) so the empty "Mine" state no
  longer hides the shared content they actually have access to;
  contributor+ keeps "Mine" as the default.

i18n:
- Tenant role labels: 拥有者/贡献者/查看者 → 所有者/编辑/访客 (all four
  locales updated, plus new userProfile / roleDenied / homeBadge keys).

The org-vs-tenant scope question raised during review is intentionally
out of scope here — that needs an RFC before any UI/backend changes.
2026-05-18 17:28:58 +08:00
wizardchen 854cb0c2a1 feat(ui): redirect tenant switch away from tenant-scoped routes
Switching the active tenant triggers window.location.reload() to
re-key every cached store / open SSE stream / in-flight request.
The catch: when the user is currently sitting on a route whose URL
embeds a tenant-scoped resource id, the new tenant lands on a
404/403 and the user sees a blank screen.

Three risky route shapes today:

  /platform/knowledge-bases/:kbId
  /platform/knowledge-bases/:kbId/creatChat
  /platform/chat/:chatid

Add a tiny tenantSwitch utility (navigateAfterTenantSwitch) that
matches the current path against this list and redirects to
/platform/knowledge-bases — the platform default landing, always
renderable regardless of role. Anything else (settings, agent
list, KB list, etc.) continues to reload its current path because
those views handle empty/forbidden data gracefully.

Both tenant-switch call sites (TenantSelector and UserMenu) use
the helper so the matrix lives in one place; future tenant-scoped
routes only need to add a regex to the list.
2026-05-18 17:28:58 +08:00
wizardchen 466182c8d6 feat(frontend): tenant switcher in user menu + role-aware UI gates
PR 4 of #1303 wired the backend X-Tenant-ID gate to accept active
tenant_members rows (not just superusers), but the frontend never
exposed a switcher to ordinary multi-tenant members. The only
existing component, the sidebar TenantSelector, is gated to
canAccessAllTenants and queries /tenants/search — both wrong for a
Contributor that an Owner just invited to a second tenant.

This PR closes both gaps:

1. Switcher entry inside the user-avatar dropdown
   - New "Switch Tenant" submenu in UserMenu.vue, hover-triggered, with
     a teleported floating panel (same pattern as the existing IM
     overview submenu so the layout/animation read consistently).
   - Data source is authStore.memberships, populated by /auth/login.
     No new API call: the JWT-issued claim already enumerates every
     tenant the user is an active member of plus their role.
   - Visibility: only shown when memberships.length > 1. Cluster
     superusers keep using the sidebar TenantSelector for "any tenant
     in the system" — the avatar entry is the curated "tenants I'm a
     member of" list.
   - Click writes via authStore.setSelectedTenant(...), then
     window.location.reload() so every cached store / open SSE
     stream / in-flight request is re-keyed under the new tenant.
     Same approach as the existing TenantSelector.

2. Role-aware UI gates on high-friction surfaces
   - authStore exposes a new hasRole(min: 'viewer'|'contributor'|
     'admin'|'owner') helper (numeric ordering matches
     middleware/rbac.go) so v-if gates line up with the server-side
     matrix instead of duplicating ['admin','owner'].includes(...).
   - Gates applied per the PR 4 audit:
     * KB list "Create" button — Contributor+
     * Agent list "Create" button — Contributor+
     * Model / VectorStore / WebSearch / MCP — Add+Edit+Delete+Test
       are Admin+ (and the per-card action menus return [] for
       non-Admins so the dropdowns disappear, not just disable).
     * Parser / Storage engine drawers — Save button Admin+
     * Retrieval settings — slider/selector inputs disabled for
       non-Admins (the form auto-saves on change, no dedicated Save).
     * API key reset — Owner+ (Reset is the highest-impact tenant op).
     * IM channel toggle/edit/delete + Add — Admin+. Same in the
       avatar-menu IM submenu (toggle disabled for non-Admins).
   - KB / agent per-card edit/delete already key off kb.isMine /
     agent.isMine + (for builtins) is_builtin; that path is left as-is.

3. i18n
   - Three new keys under tenant.switcher.* in en-US/zh-CN/ko-KR/ru-RU.
   - Role labels reuse the existing tenantMember.role.* bundle from
     PR 3, with a "show raw role" fallback if a locale lacks the key.

The server is the source of truth for every gated action — these
changes only hide buttons that would 403, never grant new authority.
authStore.hasRole and currentTenantRole both carry a SECURITY note
saying they read from localStorage and are UI-rendering-only.

vue-tsc --build error count unchanged from baseline (90, all
pre-existing issues unrelated to this PR).
2026-05-18 17:28:58 +08:00
wizardchen e029d31f86 feat(im): tenant-wide IM channels overview under the user menu
Until now the IM channels a tenant has connected were only visible from
inside each agent's editor (AgentEditorModal → IMChannelPanel). Finding
out which bots are live across all agents meant clicking through every
one of them. Add a tenant-scoped overview so the set of connected IMs is
always one hop away from the avatar.

Backend

- im.Service.ListChannelsByTenant(tenantID) returns all non-deleted
  channels in the tenant, LEFT JOIN'd with custom_agents.name so
  built-in agents (which don't have rows in custom_agents) still show
  up with an empty agent_name; the frontend substitutes a localized
  "built-in agent" label.
- Credentials are intentionally stripped from this response — the list
  view is read-only and the editor route (GET /agents/:id/im-channels)
  remains the only source for secrets.
- New ChannelWithAgent DTO + IMHandler.ListAllIMChannels wired at
  GET /api/v1/im-channels under the existing RegisterIMChannelRoutes
  group, so auth middleware is inherited.

Frontend

- IMChannelsOverviewPanel.vue: floating submenu pane, stacked rows
  (agent on top, channel below) with identical 20px avatars and 12px
  labels so neither identity dominates. Each row is the whole click
  target (jumps to the agent editor); the switch uses @click.stop to
  toggle in place without triggering navigation.
- UserMenu.vue: new hover-driven submenu entry ("已接入的 IM" + link
  icon). The pane is teleported to <body> because the sidebar container
  has overflow:hidden that would otherwise clip right-flying content.
  Position is computed from the menu item's rect and clamps/flips
  against the viewport edges.
- "Live" indicator: a pulsing green dot on the menu item when at least
  one channel is enabled. UserMenu prefetches the list once on mount;
  the panel re-emits channels-changed after every load/toggle so the
  dot stays in sync. Respects prefers-reduced-motion.
- AgentList.vue: supplement the existing onMounted-only
  checkAndOpenEditModal with a watch(route.query.edit) so
  router.push({ path: '/platform/agents', query: { edit, section } })
  from an already-mounted AgentList (the common case when navigating
  from the overview) opens the editor immediately instead of only
  after a hard refresh.

Assets

- Seven platform SVGs under assets/img/im/, pulled from iconify
  (simple-icons / logos / tdesign / icon-park / remix icon) and baked
  with brand colors so monochrome sources (wecom/wechat/dingtalk/
  feishu) don't render black.

i18n

- New imOverview namespace in zh-CN / en-US / ko-KR / ru-RU covering
  the menu label, panel title/subtitle, column headers, builtin-agent
  fallback, and the live-indicator tooltip.

Tested

- go build ./...
- go test ./internal/im/...
- vue-tsc --noEmit
- npm run build
2026-04-30 15:29:14 +08:00
wizardchen c4ebc1f60e feat: enhance UserMenu and KnowledgeBase components with loading skeletons and improved UI elements, including GitHub star tooltip and translations for better user experience 2026-04-11 18:51:16 +08:00
wizardchen d99e2cbac3 feat: implement fixed local API port settings for desktop app, allowing users to specify a port for consistent access, with corresponding UI and translations 2026-04-11 18:51:16 +08:00
wizardchen 3f0f69815f feat: add new menu items for Clawhub Skill and Chrome Extension with corresponding functionality and translations, enhancing user access to additional resources 2026-04-11 18:51:16 +08:00
wizardchen 98ff0761ed feat: implement Lite edition support by filtering menu items and adjusting UI elements, enhancing user experience for Lite users 2026-04-11 18:51:16 +08:00
ochan.kwon db7cef5f17 feat(i18n): replace hardcoded Chinese strings with i18n calls across frontend
Replace all user-visible hardcoded Chinese strings in Vue/TS source files
with proper i18n function calls and add corresponding translation keys
to all 4 locale files (zh-CN, en-US, ko-KR, ru-RU).

Changes:
- Replace 80+ hardcoded Chinese strings across 30+ source files
- Add ~450 new translation keys per locale file
- Cover components, views, utils, hooks, and API modules
- Remove Chinese fallback patterns (|| '中文') from existing t() calls
- Add mermaid toolbar and ollama date format translations

Intentionally preserved (backend API values / backward compatibility):
- FAQ CSV column headers and parsing constants
- RelevanceLevel type and Record key mappings
- Graph database engine status comparison ('未启用')
- Language name labels ('简体中文')
2026-03-06 10:34:08 +08:00
wizardchen 5d90019fd0 feat: enhance sidebar functionality and UI responsiveness
- Implemented sidebar collapse and expand functionality, allowing users to toggle the sidebar visibility for a more streamlined interface.
- Updated the `uiStore` to manage sidebar state, persisting the collapsed state in local storage for user preference.
- Enhanced the `menu.vue` and `UserMenu.vue` components to adapt their layout based on the sidebar state, improving usability.
- Added corresponding translations for sidebar actions in English, Korean, Russian, and Chinese, ensuring accessibility for diverse users.
- Refined CSS styles to support the new sidebar behavior, enhancing overall UI consistency and responsiveness.

These changes significantly improve the user experience by providing a more flexible and user-friendly navigation system.
2026-03-05 18:14:14 +08:00
wizardchen dbc7c32874 feat: update theme and UI styles across components
- Refactored CSS variables for consistent theming, replacing hardcoded colors with CSS variables for better maintainability.
- Updated various components including `AgentAvatar`, `AgentSelector`, and `AgentShareSettings` to utilize new theme variables for colors, backgrounds, and shadows.
- Enhanced SVG icons to use `currentColor` for better adaptability to theme changes.
- Improved overall UI consistency by aligning styles with the new theming approach, enhancing user experience across the application.

These changes significantly improve the visual coherence and maintainability of the UI, ensuring a more seamless user experience.
2026-03-05 18:14:14 +08:00
liweijie 53669876d2 docs: fix api link 2026-02-05 20:02:47 +08:00
wizardchen 0ca947981a refactor: 调整智能体配置,增强智能体选择与状态管理 2025-12-26 21:31:02 +08:00
wizardchen cdf576eb18 feat: Implement cross-tenant access functionality
- Added configuration for enabling cross-tenant access in the application.
- Introduced new API endpoints for listing and searching tenants, accessible only to users with the appropriate permissions.
- Updated user and tenant models to include the `can_access_all_tenants` field.
- Enhanced the authentication middleware to handle cross-tenant requests and validate user permissions.
- Created a new TenantSelector component for selecting tenants in the frontend, improving user experience.
- Updated internationalization files to support new tenant-related strings and messages.
2025-12-02 12:17:39 +08:00
wizardchen 73fbc4552c feat: Enhance Input-field and UserMenu components with new model management and navigation options
- Added functionality to update conversation model configurations in Input-field.vue, including error handling and state management.
- Improved UserMenu.vue by introducing quick navigation options for agent settings, web search configuration, and MCP service.
- Updated UI elements for better user experience, including new icons and styles for dropdowns and menu items.
- Enhanced localization support for new menu items and messages.
2025-11-20 14:58:49 +08:00
wizardchen ddf6b4e748 feat: Revamp conversation configuration management and enhance localization
- Removed outdated DEVELOPMENT.md, consolidating development instructions into relevant documentation.
- Updated conversation configuration to include new parameters such as max rounds, embedding thresholds, and rewrite prompts.
- Enhanced UI components to support new conversation settings, including AgentSettings.vue and related views.
- Improved localization in English, Russian, and Chinese for new conversation configuration fields and UI elements.
- Implemented logic to apply tenant-specific conversation settings, ensuring defaults are respected.
2025-11-18 23:18:43 +08:00
wizardchen 59f3d22169 feat: Integrate vue-i18n for multilingual support across components
- Added vue-i18n integration to various components for dynamic text translation.
- Updated text placeholders, button labels, and error messages to utilize translation functions.
- Enhanced user experience by providing localized content in the Knowledge Base, chat components, and settings.
- Removed hardcoded strings and replaced them with translation keys for better maintainability and scalability.
2025-11-13 19:34:33 +08:00
wizardchen f30720f99b feat: Enhance agent settings navigation and error handling in UI components
- Introduced a new method to handle navigation to agent settings, improving code organization and reusability.
- Updated tooltip content in the agent mode button to include a link for quick access to agent settings.
- Enhanced error handling in the KnowledgeBase component to provide actionable links for VLM configuration errors.
- Added initial section handling in the KnowledgeBaseEditorModal for improved user experience during knowledge base editing.
2025-11-07 16:40:53 +08:00
wizardchen 8e3771f6c1 chore: Update tdesign-vue-next and refactor UserMenu and Settings components
- Upgraded tdesign-vue-next to version 1.17.2 for improved features and performance.
- Replaced emoji icons with corresponding tdesign icons in UserMenu and Settings components for consistency.
- Adjusted styles in the nav-icon class for better alignment and visual appeal.
2025-11-06 22:02:32 +08:00
wizardchen 625b40b184 feat: Add API documentation and external links to User Menu
- Introduced new menu items for accessing API documentation, the official website, and GitHub repository.
- Implemented corresponding methods to open these links in a new tab.
- Removed the previous API documentation card from TenantInfo.vue to streamline the UI.
2025-11-06 21:44:12 +08:00
wizardchen 30a711ea2f feat: Implement logout functionality with API integration
- Added logout API call in both menu and user menu components.
- Enhanced error handling for logout process to ensure local state is cleared even if API fails.
- Updated styles for submenu items for better UI consistency.
2025-11-06 21:36:38 +08:00
wizardchen 602e8a3b88 refactor: Simplify UI styles and remove unused theme management
- Removed theme initialization and management from the UI store.
- Cleaned up CSS styles across multiple components, replacing CSS variables with fixed color values for consistency.
- Updated background colors and text colors to enhance UI clarity and responsiveness.
- Streamlined component styles to improve maintainability and readability.
2025-11-06 02:47:01 +08:00
wizardchen 7a64371603 feat: Implement theme management and UI enhancements across the application
- Added theme initialization and management in the UI store.
- Enhanced dark mode styles for various components, including tables, dialogs, and inputs.
- Updated multiple components to use CSS variables for consistent theming.
- Introduced a new simplified API for updating knowledge base configurations.
- Improved overall UI consistency and responsiveness with new styles.
2025-11-06 02:45:44 +08:00
wizardchen 4fa3adbf3b feat: Add agent configuration and cleanup scripts for database migrations 2025-11-05 23:18:44 +08:00