feat(assistant): add multi-dialog UX, task-aware llm settings, and i18n cleanup

This commit is contained in:
2026-02-23 23:45:01 +03:00
parent a26040254f
commit e97e19fc31
30 changed files with 1145 additions and 221 deletions

View File

@@ -16,6 +16,7 @@
import { gitService } from "../../services/gitService";
import { addToast as toast } from "../../lib/toasts.js";
import { api } from "../../lib/api";
import { t } from "../../lib/i18n";
// [/SECTION]
// [SECTION: PROPS]
@@ -49,10 +50,10 @@
`/git/repositories/${dashboardId}/generate-message`,
);
message = data.message;
toast("Commit message generated", "success");
toast($t.git?.commit_message_generated || "Commit message generated", "success");
} catch (e) {
console.error(`[CommitModal][Coherence:Failed] ${e.message}`);
toast(e.message || "Failed to generate message", "error");
toast(e.message || ($t.git?.commit_message_failed || "Failed to generate message"), "error");
} finally {
generatingMessage = false;
}
@@ -93,7 +94,7 @@
if (!diff) diff = "";
} catch (e) {
console.error(`[CommitModal][Coherence:Failed] ${e.message}`);
toast("Failed to load changes", "error");
toast($t.git?.load_changes_failed || "Failed to load changes", "error");
} finally {
loading = false;
}
@@ -114,7 +115,7 @@
committing = true;
try {
await gitService.commit(dashboardId, message, []);
toast("Changes committed successfully", "success");
toast($t.git?.commit_success || "Changes committed successfully", "success");
dispatch("commit");
show = false;
message = "";
@@ -141,7 +142,7 @@
<div
class="bg-white p-6 rounded-lg shadow-xl w-full max-w-4xl max-h-[90vh] flex flex-col"
>
<h2 class="text-xl font-bold mb-4">Commit Changes</h2>
<h2 class="text-xl font-bold mb-4">{$t.git?.commit || "Commit Changes"}</h2>
<div class="flex flex-col md:flex-row gap-4 flex-1 overflow-hidden">
<!-- Left: Message and Files -->
@@ -150,7 +151,7 @@
<div class="flex justify-between items-center mb-1">
<label
class="block text-sm font-medium text-gray-700"
>Commit Message</label
>{$t.git?.commit_message || "Commit Message"}</label
>
<button
onclick={handleGenerateMessage}
@@ -158,16 +159,16 @@
class="text-xs text-blue-600 hover:text-blue-800 disabled:opacity-50 flex items-center"
>
{#if generatingMessage}
<span class="animate-spin mr-1"></span> Generating...
<span class="animate-spin mr-1"></span> {$t.mapper?.generating || "Generating..."}
{:else}
<span class="mr-1"></span> Generate with AI
<span class="mr-1"></span> {$t.git?.generate_with_ai || "Generate with AI"}
{/if}
</button>
</div>
<textarea
bind:value={message}
class="w-full border rounded p-2 h-32 focus:ring-2 focus:ring-blue-500 outline-none resize-none"
placeholder="Describe your changes..."
placeholder={$t.git?.describe_changes || "Describe your changes..."}
></textarea>
</div>
@@ -176,7 +177,7 @@
<h3
class="text-sm font-bold text-gray-500 uppercase mb-2"
>
Changed Files
{$t.git?.changed_files || "Changed Files"}
</h3>
<ul class="text-xs space-y-1">
{#each status.staged_files as file}
@@ -218,14 +219,14 @@
<div
class="bg-gray-200 px-3 py-1 text-xs font-bold text-gray-600 border-b"
>
Changes Preview
{$t.git?.changes_preview || "Changes Preview"}
</div>
<div class="flex-1 overflow-auto p-2">
{#if loading}
<div
class="flex items-center justify-center h-full text-gray-500"
>
Loading diff...
{$t.git?.loading_diff || "Loading diff..."}
</div>
{:else if diff}
<pre
@@ -234,7 +235,7 @@
<div
class="flex items-center justify-center h-full text-gray-500 italic"
>
No changes detected
{$t.git?.no_changes || "No changes detected"}
</div>
{/if}
</div>
@@ -246,7 +247,7 @@
onclick={() => (show = false)}
class="px-4 py-2 text-gray-600 hover:bg-gray-100 rounded"
>
Cancel
{$t.common?.cancel || "Cancel"}
</button>
<button
onclick={handleCommit}
@@ -257,7 +258,7 @@
status?.staged_files?.length === 0)}
class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
>
{committing ? "Committing..." : "Commit"}
{committing ? ($t.git?.committing || "Committing...") : ($t.git?.commit || "Commit")}
</button>
</div>
</div>

View File

@@ -14,6 +14,7 @@
import { onMount, createEventDispatcher } from "svelte";
import { gitService } from "../../services/gitService";
import { addToast as toast } from "../../lib/toasts.js";
import { t } from "../../lib/i18n";
// [/SECTION]
// [SECTION: PROPS]
@@ -55,7 +56,7 @@
);
} catch (e) {
console.error(`[DeploymentModal][Coherence:Failed] ${e.message}`);
toast("Failed to load environments", "error");
toast($t.migration?.loading_envs_failed || "Failed to load environments", "error");
} finally {
loading = false;
}
@@ -76,7 +77,7 @@
try {
const result = await gitService.deploy(dashboardId, selectedEnv);
toast(
result.message || "Deployment triggered successfully",
result.message || ($t.git?.deploy_success || "Deployment triggered successfully"),
"success",
);
dispatch("deploy");
@@ -98,26 +99,26 @@
class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"
>
<div class="bg-white p-6 rounded-lg shadow-xl w-96">
<h2 class="text-xl font-bold mb-4">Deploy Dashboard</h2>
<h2 class="text-xl font-bold mb-4">{$t.git?.deploy || "Deploy Dashboard"}</h2>
{#if loading}
<p class="text-gray-500">Loading environments...</p>
<p class="text-gray-500">{$t.migration?.loading_envs || "Loading environments..."}</p>
{:else if environments.length === 0}
<p class="text-red-500 mb-4">
No deployment environments configured.
{$t.git?.no_deploy_envs || "No deployment environments configured."}
</p>
<div class="flex justify-end">
<button
onclick={() => (show = false)}
class="px-4 py-2 bg-gray-200 text-gray-800 rounded hover:bg-gray-300"
>
Close
{$t.common?.close || "Close"}
</button>
</div>
{:else}
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 mb-2"
>Select Target Environment</label
>{$t.migration?.target_env || "Select Target Environment"}</label
>
<select
bind:value={selectedEnv}
@@ -136,7 +137,7 @@
onclick={() => (show = false)}
class="px-4 py-2 text-gray-600 hover:bg-gray-100 rounded"
>
Cancel
{$t.common?.cancel || "Cancel"}
</button>
<button
onclick={handleDeploy}
@@ -164,9 +165,9 @@
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
></path>
</svg>
Deploying...
{$t.git?.deploying || "Deploying..."}
{:else}
Deploy
{$t.git?.deploy || "Deploy"}
{/if}
</button>
</div>

View File

@@ -82,13 +82,13 @@
*/
async function handleInit() {
if (!selectedConfigId || !remoteUrl) {
toast('Please select a Git server and provide remote URL', 'error');
toast($t.git?.init_validation_error || 'Please select a Git server and provide remote URL', 'error');
return;
}
loading = true;
try {
await gitService.initRepository(dashboardId, selectedConfigId, remoteUrl);
toast('Repository initialized successfully', 'success');
toast($t.git?.init_success || 'Repository initialized successfully', 'success');
initialized = true;
} catch (e) {
toast(e.message, 'error');
@@ -110,7 +110,7 @@
// Try to get selected environment from localStorage (set by EnvSelector)
const sourceEnvId = localStorage.getItem('selected_env_id');
await gitService.sync(dashboardId, sourceEnvId);
toast('Dashboard state synced to Git', 'success');
toast($t.git?.sync_success || 'Dashboard state synced to Git', 'success');
} catch (e) {
toast(e.message, 'error');
} finally {
@@ -129,7 +129,7 @@
loading = true;
try {
await gitService.push(dashboardId);
toast('Changes pushed to remote', 'success');
toast($t.git?.push_success || 'Changes pushed to remote', 'success');
} catch (e) {
toast(e.message, 'error');
} finally {
@@ -148,7 +148,7 @@
loading = true;
try {
await gitService.pull(dashboardId);
toast('Changes pulled from remote', 'success');
toast($t.git?.pull_success || 'Changes pulled from remote', 'success');
} catch (e) {
toast(e.message, 'error');
} finally {
@@ -164,8 +164,8 @@
{#if show}
<div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white p-6 rounded-lg shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-y-auto">
<PageHeader title="{$t.git.management}: {dashboardTitle}">
<div slot="subtitle" class="text-sm text-gray-500">ID: {dashboardId}</div>
<PageHeader title={`${$t.git?.management || "Git Management"}: ${dashboardTitle}`}>
<div slot="subtitle" class="text-sm text-gray-500">{$t.common?.id || "ID"}: {dashboardId}</div>
<div slot="actions">
<button onclick={() => show = false} class="text-gray-400 hover:text-gray-600 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
@@ -193,13 +193,13 @@
options={configs.map(c => ({ value: c.id, label: `${c.name} (${c.provider})` }))}
/>
{#if configs.length === 0}
<p class="text-xs text-red-500 -mt-4">No Git servers configured. Go to Settings -> Git to add one.</p>
<p class="text-xs text-red-500 -mt-4">{$t.git?.no_servers_configured || "No Git servers configured. Go to Settings -> Git to add one."}</p>
{/if}
<Input
label={$t.git.remote_url}
bind:value={remoteUrl}
placeholder="https://github.com/org/repo.git"
placeholder={$t.git?.remote_url_placeholder || "https://github.com/org/repo.git"}
/>
<Button