Major rebranding, i18n, dashboard, shared folders, role capabilities
- Rebrand: new app/agent icons, SKALD.md, warm "paper" CSS palette (terracotta accent, --radius tokens, WCAG contrast, reduced-motion), updated favicon, tray icon, skaldkonur asset - i18n: backend crate (i18n.rs, locale column, ui_locale config), frontend library (web/lib/i18n.js, I18nMixin, t(key)), translation files (web/i18n/), every component wired - Dashboard: <dashboard-page> replaces old home-page content; <app-copilot> becomes the landing page (full/dock layout modes) - Shared folders: API endpoints (shared_folders.rs), frontend page, can_write membership, container mount topology, user_fs routing - Role capabilities: new db table & authorization seam (data not enums), roles.attrs JSON for ui_mode / interface select - Setup: skald-setup prompts for language + password, sets ui_locale - General: components migrated to CSS variables, Lit conventions cleanup, connectors/catalog/marketplace/approval refactoring
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { LightElement } from './base.js';
|
||||
import { t } from './i18n.js';
|
||||
|
||||
// Slash commands handled entirely server-side: they reply with a `Done` and never
|
||||
// echo back as a `user_message`, so they are the only commands rendered
|
||||
@@ -270,7 +271,7 @@ export class ChatSession extends LightElement {
|
||||
if (approved) {
|
||||
this._updateTool(tool_call_id, { status: 'running', request_id: null });
|
||||
} else {
|
||||
this._updateTool(tool_call_id, { status: 'rejected', error: 'Rifiutato.' });
|
||||
this._updateTool(tool_call_id, { status: 'rejected', error: t('chat.rejected') });
|
||||
}
|
||||
const expanded = new Set(this._expanded);
|
||||
expanded.delete(tool_call_id);
|
||||
@@ -320,7 +321,7 @@ export class ChatSession extends LightElement {
|
||||
}
|
||||
|
||||
case 'truncated':
|
||||
this._pushError(`Risposta troncata dal limite di token (↓${msg.output_tokens?.toLocaleString() ?? '?'} tok).`);
|
||||
this._pushError(`${t('chat.truncated', { tokens: msg.output_tokens?.toLocaleString() ?? '?' })}`);
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
@@ -592,7 +593,7 @@ export class ChatSession extends LightElement {
|
||||
if (this._ws?.readyState === WebSocket.OPEN) {
|
||||
this._ws.send(JSON.stringify({ type: 'reject_tool', request_id: msg.request_id, note: this._rejectNote }));
|
||||
}
|
||||
this._updateTool(msg.tool_call_id, { status: 'rejected', error: "Rifiutato dall'utente." });
|
||||
this._updateTool(msg.tool_call_id, { status: 'rejected', error: t('chat.rejected_by_user') });
|
||||
this._rejectingId = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import en from '../i18n/en.js';
|
||||
import it from '../i18n/it.js';
|
||||
import fr from '../i18n/fr.js';
|
||||
|
||||
const DICTS = { en, it, fr };
|
||||
|
||||
export const LOCALES = [
|
||||
{ id: 'en', label: 'English' },
|
||||
{ id: 'it', label: 'Italiano' },
|
||||
{ id: 'fr', label: 'Français' },
|
||||
];
|
||||
|
||||
// Pre-auth the last choice is cached in localStorage (the login page can be
|
||||
// localized before any session exists); after login the server is the source
|
||||
// of truth: the user's own `locale` wins over the instance default.
|
||||
let _locale = localStorage.getItem('locale') || 'en';
|
||||
|
||||
export function t(key, params) {
|
||||
let s = DICTS[_locale]?.[key] ?? DICTS.en[key] ?? key;
|
||||
if (params) {
|
||||
for (const [k, v] of Object.entries(params)) s = s.replaceAll(`{${k}}`, String(v));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
export function getLocale() { return _locale; }
|
||||
|
||||
export function setLocale(locale, { persist = false } = {}) {
|
||||
if (!DICTS[locale]) locale = 'en';
|
||||
const changed = locale !== _locale;
|
||||
_locale = locale;
|
||||
localStorage.setItem('locale', locale);
|
||||
document.documentElement.lang = locale;
|
||||
if (changed) window.dispatchEvent(new CustomEvent('locale-changed', { detail: { locale } }));
|
||||
if (persist) {
|
||||
fetch('/api/auth/profile', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ locale }),
|
||||
}).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the effective locale once the session is known:
|
||||
* user preference (users.locale) → instance default (config `ui_locale`) →
|
||||
* cached/browser default. Pre-auth (login/setup) keeps the cached locale.
|
||||
*/
|
||||
export async function initI18n() {
|
||||
try {
|
||||
const res = await fetch('/api/auth/me');
|
||||
if (!res.ok) return;
|
||||
const me = await res.json();
|
||||
const eff = me.locale || me.default_locale;
|
||||
if (eff) setLocale(eff);
|
||||
} catch { /* keep cached locale */ }
|
||||
}
|
||||
|
||||
/** Re-renders the host component whenever the locale changes. */
|
||||
export const I18nMixin = (Base) => class extends Base {
|
||||
connectedCallback() {
|
||||
super.connectedCallback?.();
|
||||
this.__onLocaleChanged = () => this.requestUpdate();
|
||||
window.addEventListener('locale-changed', this.__onLocaleChanged);
|
||||
}
|
||||
disconnectedCallback() {
|
||||
window.removeEventListener('locale-changed', this.__onLocaleChanged);
|
||||
super.disconnectedCallback?.();
|
||||
}
|
||||
};
|
||||
@@ -1,10 +1,11 @@
|
||||
import { html, nothing } from 'lit';
|
||||
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
||||
import { renderMarkdown } from './base.js';
|
||||
import { t } from './i18n.js';
|
||||
|
||||
/**
|
||||
* InboxMixin — shared fetch, action, and render logic for the agent inbox.
|
||||
* Used by AgentInboxPage (full page) and HomePage (embedded section).
|
||||
* Used by AgentInboxPage (full page) and DashboardPage (embedded section).
|
||||
*/
|
||||
export const InboxMixin = (Base) => class extends Base {
|
||||
|
||||
@@ -68,7 +69,7 @@ export const InboxMixin = (Base) => class extends Base {
|
||||
}
|
||||
|
||||
_rejectWithNote(requestId, toolCallId = null) {
|
||||
const note = prompt('Rejection reason (optional):') ?? '';
|
||||
const note = prompt(t('inbox.reject_prompt')) ?? '';
|
||||
this._resolveApproval(requestId, 'reject', note, null, null, toolCallId);
|
||||
}
|
||||
|
||||
@@ -208,11 +209,11 @@ export const InboxMixin = (Base) => class extends Base {
|
||||
<div class="inbox-card-footer approval-footer">
|
||||
<button class="btn btn-success"
|
||||
@click=${() => this._resolveApproval(item.request_id, 'approve', '', null, null, item.tool_call_id)}>
|
||||
<i class="bi bi-check-lg"></i> Approve
|
||||
<i class="bi bi-check-lg"></i> ${t('approval.approve')}
|
||||
</button>
|
||||
<button class="btn btn-outline-danger"
|
||||
@click=${() => this._rejectWithNote(item.request_id, item.tool_call_id)}>
|
||||
<i class="bi bi-x-lg"></i> Reject
|
||||
<i class="bi bi-x-lg"></i> ${t('approval.reject')}
|
||||
</button>
|
||||
|
||||
${item.request_id ? html`
|
||||
@@ -233,7 +234,7 @@ export const InboxMixin = (Base) => class extends Base {
|
||||
|
||||
<button class="btn btn-outline-secondary"
|
||||
@click=${() => this._approveWithBypass(item, 0)}
|
||||
title="Approve and don't ask again for this session">
|
||||
title=${t('approval.bypass_all')}>
|
||||
<i class="bi bi-shield-check"></i> Sessione
|
||||
</button>
|
||||
` : nothing}
|
||||
@@ -360,7 +361,7 @@ export const InboxMixin = (Base) => class extends Base {
|
||||
${total === 0 ? html`
|
||||
<div class="inbox-empty">
|
||||
<i class="bi bi-inbox"></i>
|
||||
<p>No pending requests</p>
|
||||
<p>${t('inbox.empty')}</p>
|
||||
</div>
|
||||
` : html`
|
||||
<div class="inbox-grid">
|
||||
|
||||
Reference in New Issue
Block a user