Migration (multi-agent sweep over 216 files, 60 batches):
- Every user-visible dashboard + TUI string moved to t() with the exact
English inline default (en rendering byte-identical)
- Catalogs merged from per-batch fragments: en/zh-CN/zh-TW/fr/es now
carry ~5,930 keys each across common/app/errors/cli namespaces;
CLI bundles regenerated (6 locales incl. ko)
Integration fixes:
- 18 type errors: reserved {{count}} interpolations renamed, malformed
plural call, hand-rolled t-param types replaced with TFunction<"app">
- 23 lint errors: superseded label constants/helpers removed
- ExecutorStatusBar hook-order violation (keyboard-open early return
moved below hooks)
- TUI tests wrapped in I18nextProvider (uninitialized fallback renders
literal {{placeholders}}); dashboard vitest.setup boots a minimal en
i18next instance for the same reason
Known WIP (next commits): ~457 residual strings across 50 batches,
Korean drafts for swept keys, and a dashboard test-suite pass that is
still being stabilized (~283 failures under investigation — fake-timer
waitFor interaction, likely stale node_modules vs merged lockfile).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
import { useCallback } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import type { Task, TaskCreateInput } from "@fusion/core";
|
|
import type { ToastType } from "./useToast";
|
|
|
|
interface UseTaskHandlersOptions {
|
|
createTask: (input: TaskCreateInput) => Promise<Task>;
|
|
ingestCreatedTasks: (tasks: Task[]) => void;
|
|
onPlanningTaskCreated: (task: Task, addToast: (msg: string, type?: ToastType) => void) => void;
|
|
onPlanningTasksCreated: (tasks: Task[], addToast: (msg: string, type?: ToastType) => void) => void;
|
|
onSubtaskTasksCreated: (tasks: Task[], addToast: (msg: string, type?: ToastType) => void) => void;
|
|
addToast: (message: string, type?: ToastType) => void;
|
|
}
|
|
|
|
export interface UseTaskHandlersResult {
|
|
handleBoardQuickCreate: (input: TaskCreateInput) => Promise<Task>;
|
|
handleModalCreate: (input: TaskCreateInput) => Promise<Task>;
|
|
handlePlanningTaskCreated: (task: Task) => void;
|
|
handlePlanningTasksCreated: (tasks: Task[]) => void;
|
|
handleSubtaskTasksCreated: (tasks: Task[]) => void;
|
|
handleGitHubImport: (task: Task) => void;
|
|
}
|
|
|
|
export function useTaskHandlers(options: UseTaskHandlersOptions): UseTaskHandlersResult {
|
|
const { t } = useTranslation("app");
|
|
const {
|
|
createTask,
|
|
ingestCreatedTasks,
|
|
onPlanningTaskCreated,
|
|
onPlanningTasksCreated,
|
|
onSubtaskTasksCreated,
|
|
addToast,
|
|
} = options;
|
|
|
|
const handleBoardQuickCreate = useCallback(
|
|
async (input: TaskCreateInput): Promise<Task> => {
|
|
return createTask({ ...input, column: "triage", source: { sourceType: "dashboard_ui" } });
|
|
},
|
|
[createTask],
|
|
);
|
|
|
|
const handleModalCreate = useCallback(
|
|
async (input: TaskCreateInput): Promise<Task> => {
|
|
const task = await createTask({ ...input, column: "triage", source: { sourceType: "dashboard_ui" } });
|
|
return task;
|
|
},
|
|
[createTask],
|
|
);
|
|
|
|
const handlePlanningTaskCreated = useCallback((task: Task) => {
|
|
ingestCreatedTasks([task]);
|
|
onPlanningTaskCreated(task, addToast);
|
|
}, [addToast, ingestCreatedTasks, onPlanningTaskCreated]);
|
|
|
|
const handlePlanningTasksCreated = useCallback((tasks: Task[]) => {
|
|
ingestCreatedTasks(tasks);
|
|
onPlanningTasksCreated(tasks, addToast);
|
|
}, [addToast, ingestCreatedTasks, onPlanningTasksCreated]);
|
|
|
|
const handleSubtaskTasksCreated = useCallback((tasks: Task[]) => {
|
|
ingestCreatedTasks(tasks);
|
|
onSubtaskTasksCreated(tasks, addToast);
|
|
}, [addToast, ingestCreatedTasks, onSubtaskTasksCreated]);
|
|
|
|
const handleGitHubImport = useCallback((task: Task) => {
|
|
addToast(t("taskHandlers.githubImported", "Imported {{id}} from GitHub", { id: task.id }), "success");
|
|
}, [addToast, t]);
|
|
|
|
return {
|
|
handleBoardQuickCreate,
|
|
handleModalCreate,
|
|
handlePlanningTaskCreated,
|
|
handlePlanningTasksCreated,
|
|
handleSubtaskTasksCreated,
|
|
handleGitHubImport,
|
|
};
|
|
}
|