Add a production i18n lint baseline while replacing dashboard copy with translation keys. - Localize task, board, mailbox, report, graph, settings, and shared dashboard surfaces. - Regenerate locale catalogs and resource types for the migration keys. - Add the i18n lint-baseline regression test and contributor guidance. Files changed: .changeset/fn-013-i18n-lint-baseline.md | 7 + docs/i18n-contributing.md | 11 + .../dashboard/app/components/ActiveAgentsPanel.tsx | 2 +- .../dashboard/app/components/AgentDetailView.tsx | 2 +- packages/dashboard/app/components/Board.tsx | 19 +- packages/dashboard/app/components/ChatView.tsx | 2 +- .../dashboard/app/components/ComposeChatPanel.tsx | 14 +- packages/dashboard/app/components/DockTaskList.tsx | 16 +- .../dashboard/app/components/FloatingWindow.tsx | 6 +- .../dashboard/app/components/GitHubImportModal.tsx | 4 +- .../dashboard/app/components/KnowledgeGraphPanel.tsx | 21 +- packages/dashboard/app/components/ListView.tsx | 2 +- .../app/components/MailboxArtifactAttachment.tsx | 16 +- packages/dashboard/app/components/MailboxModal.tsx | 12 +- .../app/components/MailboxStructuralItem.tsx | 13 +- .../app/components/MailboxTaskProposal.tsx | 10 +- .../app/components/MailboxTaskRecommendations.tsx | 12 +- packages/dashboard/app/components/MailboxView.tsx | 14 +- packages/dashboard/app/components/MermaidDiagram.tsx | 4 +- packages/dashboard/app/components/MeshTopology.tsx | 6 +- .../dashboard/app/components/MessageComposer.tsx | 24 +- .../app/components/NativeStructurePreview.tsx | 14 +- packages/dashboard/app/components/ProviderLoginDialog.tsx | 24 +- packages/dashboard/app/components/ReportActionMenu.tsx | 6 +- packages/dashboard/app/components/ReportModal.tsx | 26 +- packages/dashboard/app/components/TaskChatTab.tsx | 10 +- packages/dashboard/app/components/TaskDetailModal.tsx | 28 +- .../app/components/TaskVerificationStatus.tsx | 10 +- .../dashboard/app/components/WhatsAppChatPairingPanel.tsx | 38 +- .../components/command-center/CommandCenter.tsx | 4 +- .../components/command-center/IdeationPanel.tsx | 12 +- .../components/settings/sections/McpServersCard.tsx | 2 +- .../components/settings/sections/MemorySection.tsx | 4 +- .../app/task-modal-touch-resize-e2e-fixture.tsx | 28 +- packages/i18n/locales/en/app.json | 247 +++++++- packages/i18n/locales/es/app.json | 256 +++++++- packages/i18n/locales/fr/app.json | 256 +++++++- packages/i18n/locales/ko/app.json | 256 +++++++- packages/i18n/locales/pt-BR/app.json | 705 ++++++++++++++++++++ packages/i18n/locales/zh-CN/app.json | 256 +++++++- packages/i18n/locales/zh-TW/app.json | 256 +++++++- .../i18n/src/__tests__/i18n-lint-baseline.test.ts | 31 + packages/i18n/src/resources.d.ts | 229 ++++++- 43 files changed, 2627 insertions(+), 288 deletions(-) Fusion-Task-Id: FN-013 Fusion-Task-Lineage: 846ac221-c7c3-4ff0-a30d-69479b614765 Co-authored-by: Fusion <noreply@runfusion.ai>
124 lines
6.3 KiB
TypeScript
124 lines
6.3 KiB
TypeScript
import { useCallback, useEffect, useRef, useState } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useComposerDictation } from "../hooks/useComposerDictation";
|
|
import { MicButton } from "./MicButton";
|
|
import type { NativeStructureEmbed } from "@fusion/core";
|
|
import { FN_AGENT_ID, useChat } from "../hooks/useChat";
|
|
import "./ComposeChatPanel.css";
|
|
|
|
interface ComposeChatPanelProps {
|
|
projectId?: string;
|
|
embeds: NativeStructureEmbed[];
|
|
draftBody: string;
|
|
onUseDraft: (draft: string) => void;
|
|
onClose: () => void;
|
|
}
|
|
|
|
/**
|
|
* FNXC:NativeStructureEmbed 2026-07-22-10:30:
|
|
* This compact helper deliberately reuses useChat and a FN_AGENT_ID scratch session rather than
|
|
* creating another streaming engine. Its session title prefix makes the disposable compose context
|
|
* auditable, and closing archives only that session. Applying output replaces empty text directly;
|
|
* typed text is replaced only after the composer confirms, while embeds remain untouched.
|
|
*/
|
|
export function ComposeChatPanel({ projectId, embeds, draftBody, onUseDraft, onClose }: ComposeChatPanelProps) {
|
|
const { t } = useTranslation("app");
|
|
const chat = useChat(projectId);
|
|
const [request, setRequest] = useState("Draft a clear report or approval message around the attached structure.");
|
|
const [isCreating, setIsCreating] = useState(false);
|
|
const [hasPendingPrompt, setHasPendingPrompt] = useState(false);
|
|
const [activeScratchSessionId, setActiveScratchSessionId] = useState<string | null>(null);
|
|
const scratchSessionId = useRef<string | null>(null);
|
|
const priorSession = useRef<typeof chat.activeSession>(null);
|
|
const pendingPrompt = useRef<string | null>(null);
|
|
const creatingSession = useRef(false);
|
|
const closed = useRef(false);
|
|
const archivedSessionId = useRef<string | null>(null);
|
|
const requestRef = useRef<HTMLTextAreaElement>(null);
|
|
const dictation = useComposerDictation({ textareaRef: requestRef, value: request, onChange: setRequest, projectId });
|
|
const restoredSessionId = useRef<string | null>(null);
|
|
|
|
const archiveScratchSession = useCallback((id = scratchSessionId.current) => {
|
|
if (!id || archivedSessionId.current === id) return;
|
|
archivedSessionId.current = id;
|
|
void chat.archiveSession(id)
|
|
.catch(() => undefined)
|
|
.finally(() => {
|
|
const previous = priorSession.current;
|
|
if (!previous || restoredSessionId.current === previous.id) return;
|
|
restoredSessionId.current = previous.id;
|
|
chat.selectSession(previous.id, previous);
|
|
});
|
|
}, [chat.archiveSession, chat.selectSession]);
|
|
|
|
useEffect(() => () => {
|
|
closed.current = true;
|
|
archiveScratchSession();
|
|
}, [archiveScratchSession]);
|
|
|
|
useEffect(() => {
|
|
const prompt = pendingPrompt.current;
|
|
if (!prompt || chat.activeSession?.id !== scratchSessionId.current) return;
|
|
|
|
// FNXC:NativeStructureEmbed 2026-07-22-11:00:
|
|
// createSession selects state asynchronously. Queue the first prompt until the scratch session
|
|
// is active so useChat's closure cannot drop it against the previous/no active session.
|
|
pendingPrompt.current = null;
|
|
setHasPendingPrompt(false);
|
|
chat.sendMessage(prompt);
|
|
}, [activeScratchSessionId, chat.activeSession?.id, chat.sendMessage, hasPendingPrompt]);
|
|
|
|
const send = useCallback(async () => {
|
|
const context = embeds.length
|
|
? embeds.map((embed) => `- ${embed.kind}: ${embed.label ?? embed.id} (${embed.id})`).join("\n")
|
|
: "- No structures attached yet.";
|
|
pendingPrompt.current = `${request}\n\nAttached native structures (keep these as first-class embeds, do not describe them as missing):\n${context}\n\nCurrent draft body:\n${draftBody || "(empty)"}`;
|
|
setHasPendingPrompt(true);
|
|
|
|
if (scratchSessionId.current || creatingSession.current) return;
|
|
// FNXC:NativeStructureEmbed 2026-07-22-12:00:
|
|
// useChat selects the scratch session globally. Keep the user's prior selection so scratch
|
|
// cleanup restores it after archiving rather than leaving ChatView on an archived session.
|
|
priorSession.current = chat.activeSession;
|
|
creatingSession.current = true;
|
|
setIsCreating(true);
|
|
try {
|
|
const session = await chat.createSession({ agentId: FN_AGENT_ID, title: "compose-mail-scratch" });
|
|
if (closed.current) {
|
|
archiveScratchSession(session.id);
|
|
return;
|
|
}
|
|
scratchSessionId.current = session.id;
|
|
// Force the queued-send effect after createSession has selected its stateful active session.
|
|
setActiveScratchSessionId(session.id);
|
|
} catch {
|
|
pendingPrompt.current = null;
|
|
setHasPendingPrompt(false);
|
|
} finally {
|
|
creatingSession.current = false;
|
|
if (!closed.current) setIsCreating(false);
|
|
}
|
|
}, [archiveScratchSession, chat.activeSession, chat.createSession, draftBody, embeds, request]);
|
|
|
|
const close = useCallback(() => {
|
|
closed.current = true;
|
|
archiveScratchSession();
|
|
onClose();
|
|
}, [archiveScratchSession, onClose]);
|
|
|
|
const latestDraft = chat.streamingText || [...chat.messages].reverse().find((message) => message.role === "assistant")?.content || "";
|
|
|
|
return (
|
|
<section id="compose-chat-panel" className="compose-chat-panel" aria-label={t("composeChat.ariaLabel", "Compose chat narrative helper")} data-testid="compose-chat-panel">
|
|
<label className="message-composer-label" htmlFor="compose-chat-request">{t("composeChat.draftNarrative", "Draft narrative")}</label>
|
|
<textarea ref={requestRef} id="compose-chat-request" className="input compose-chat-panel__input" value={request} onChange={(event) => setRequest(event.target.value)} />
|
|
<div className="compose-chat-panel__output" aria-live="polite">{latestDraft || t("composeChat.emptyDraft", "Ask the assistant to draft the narrative around your attached structures.")}</div>
|
|
<div className="compose-chat-panel__actions"><MicButton {...dictation.micProps} />
|
|
<button className="btn btn-sm btn-primary" type="button" onClick={() => void send()} disabled={chat.isStreaming || isCreating || hasPendingPrompt || !request.trim()}>{t("composeChat.draft", "Draft")}</button>
|
|
<button className="btn btn-sm btn-secondary" type="button" onClick={() => latestDraft && onUseDraft(latestDraft)} disabled={!latestDraft}>{t("composeChat.useDraft", "Use draft")}</button>
|
|
<button className="btn btn-sm btn-secondary" type="button" onClick={close}>{t("actions.close", "Close")}</button>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|