diff --git a/src/renderer/src/i18n/zh.ts b/src/renderer/src/i18n/zh.ts index 7c2db68d..50a8555d 100644 --- a/src/renderer/src/i18n/zh.ts +++ b/src/renderer/src/i18n/zh.ts @@ -695,6 +695,7 @@ export const zh: Record = { "Unsaved": "未保存", "Working language": "工作语言", "That did not work": "操作未成功", + "Working…": "处理中…", "This page could not be shown.": "此页面无法显示。", "AgentCompany hit an error it could not recover from here.": "AgentCompany 遇到了无法在此恢复的错误。", "The rest of the app still works; go to another page or try this one again.": "应用的其他部分仍可使用;可以前往其他页面,或重试此页面。", diff --git a/src/renderer/src/pages/ChatPage.tsx b/src/renderer/src/pages/ChatPage.tsx index e0bbd07a..f70cc9f4 100644 --- a/src/renderer/src/pages/ChatPage.tsx +++ b/src/renderer/src/pages/ChatPage.tsx @@ -152,7 +152,7 @@ export function ChatPage({ snapshot, actions }: PageProps) { event.preventDefault(); const form = new FormData(event.currentTarget); const existingSpaceIds = new Set(spaces.map((space) => space.id)); - void actions.run(() => window.agentCompany.createChatSpace({ + return actions.run(() => window.agentCompany.createChatSpace({ orgId, spaceType: value(form, "spaceType") as SpaceType, name: value(form, "name"), diff --git a/src/renderer/src/pages/NewTaskDialog.tsx b/src/renderer/src/pages/NewTaskDialog.tsx index f4c9c303..12dc7d48 100644 --- a/src/renderer/src/pages/NewTaskDialog.tsx +++ b/src/renderer/src/pages/NewTaskDialog.tsx @@ -50,7 +50,7 @@ export function NewTaskDialog({ const submit = (event: FormEvent) => { event.preventDefault(); const form = new FormData(event.currentTarget); - void actions.run(() => window.agentCompany.createTask({ + return actions.run(() => window.agentCompany.createTask({ orgId, title: value(form, "title"), description: value(form, "description"), diff --git a/src/renderer/src/pages/TeamPage.tsx b/src/renderer/src/pages/TeamPage.tsx index 88b392db..516e0e62 100644 --- a/src/renderer/src/pages/TeamPage.tsx +++ b/src/renderer/src/pages/TeamPage.tsx @@ -55,7 +55,7 @@ export function TeamPage({ snapshot, actions }: PageProps) { const form = new FormData(event.currentTarget); const selectedProvider = providers.find((provider) => provider.id === hireProviderId) ?? null; const modelId = selectedProvider ? hireModelId.trim() || null : null; - void actions.run(() => window.agentCompany.createAgent({ + return actions.run(() => window.agentCompany.createAgent({ orgId, name: text(form, "name"), role: text(form, "role"), @@ -79,7 +79,7 @@ export function TeamPage({ snapshot, actions }: PageProps) { event.preventDefault(); if (!editingAgent) return; const form = new FormData(event.currentTarget); - void actions.run(() => window.agentCompany.updateAgent({ + return actions.run(() => window.agentCompany.updateAgent({ orgId, agentId: editingAgent.id, name: text(form, "name"), diff --git a/src/renderer/src/pages/library/DocumentsPanel.tsx b/src/renderer/src/pages/library/DocumentsPanel.tsx index 68a51203..29541c02 100644 --- a/src/renderer/src/pages/library/DocumentsPanel.tsx +++ b/src/renderer/src/pages/library/DocumentsPanel.tsx @@ -60,7 +60,7 @@ export function DocumentsPanel({ event.preventDefault(); if (!selected) return; const form = new FormData(event.currentTarget); - void perform(() => actions.run(() => window.agentCompany.updateDocument({ + return perform(() => actions.run(() => window.agentCompany.updateDocument({ orgId, documentId: selected.id, title: String(form.get("title") ?? ""), @@ -141,7 +141,7 @@ export function DocumentsPanel({ onClose={() => setConfirmDelete(false)} onSubmit={(event) => { event.preventDefault(); - void perform(() => actions.run(() => window.agentCompany.deleteDocument({ orgId, documentId: selected.id, deletedByEmployeeId: employeeId })), () => { + return perform(() => actions.run(() => window.agentCompany.deleteDocument({ orgId, documentId: selected.id, deletedByEmployeeId: employeeId })), () => { setConfirmDelete(false); setSelectedId(null); }); diff --git a/src/renderer/src/pages/library/KnowledgePanel.tsx b/src/renderer/src/pages/library/KnowledgePanel.tsx index c49c88f5..ce79fd10 100644 --- a/src/renderer/src/pages/library/KnowledgePanel.tsx +++ b/src/renderer/src/pages/library/KnowledgePanel.tsx @@ -52,7 +52,7 @@ export function KnowledgePanel({ const perform = (operation: () => Promise, done: () => void) => { setError(null); - void operation().then(done, (failure: unknown) => setError(failure instanceof Error ? failure.message : String(failure))); + return operation().then(done, (failure: unknown) => setError(failure instanceof Error ? failure.message : String(failure))); }; const text = (form: FormData, key: string) => String(form.get(key) ?? ""); @@ -60,7 +60,7 @@ export function KnowledgePanel({ event.preventDefault(); const form = new FormData(event.currentTarget); const validUntil = text(form, "validUntil"); - perform(() => actions.run(() => window.agentCompany.createKnowledgeEntry({ + return perform(() => actions.run(() => window.agentCompany.createKnowledgeEntry({ orgId, topic: text(form, "topic"), category: text(form, "category"), @@ -79,7 +79,7 @@ export function KnowledgePanel({ event.preventDefault(); if (!selected) return; const form = new FormData(event.currentTarget); - perform(() => actions.run(() => window.agentCompany.updateKnowledgeEntry({ + return perform(() => actions.run(() => window.agentCompany.updateKnowledgeEntry({ orgId, entryId: selected.id, topic: text(form, "topic"), @@ -202,7 +202,7 @@ export function KnowledgePanel({ onClose={() => setDialog(null)} onSubmit={(event) => { event.preventDefault(); - perform(() => actions.run(() => window.agentCompany.deleteKnowledgeEntry({ orgId, entryId: selected.id, deletedByEmployeeId: employeeId })), () => { + return perform(() => actions.run(() => window.agentCompany.deleteKnowledgeEntry({ orgId, entryId: selected.id, deletedByEmployeeId: employeeId })), () => { setDialog(null); setSelectedId(null); }); diff --git a/src/renderer/src/pages/settings/CompanyDialog.tsx b/src/renderer/src/pages/settings/CompanyDialog.tsx index c7d9c8c8..6d43497e 100644 --- a/src/renderer/src/pages/settings/CompanyDialog.tsx +++ b/src/renderer/src/pages/settings/CompanyDialog.tsx @@ -14,7 +14,7 @@ export function CompanyDialog({ organization, open, actions, onClose }: { organi const form = new FormData(event.currentTarget); const value = (key: string) => String(form.get(key) ?? ""); setError(null); - actions.run(() => window.agentCompany.updateOrganization({ + return actions.run(() => window.agentCompany.updateOrganization({ orgId: organization.id, name: value("name"), description: value("description"), diff --git a/src/renderer/src/pages/settings/ProvidersPanel.tsx b/src/renderer/src/pages/settings/ProvidersPanel.tsx index 849c2aaf..bc63f016 100644 --- a/src/renderer/src/pages/settings/ProvidersPanel.tsx +++ b/src/renderer/src/pages/settings/ProvidersPanel.tsx @@ -55,7 +55,7 @@ export function ProvidersPanel({ orgId, companyName, employeeId, providers, auth if (!active || !activeCatalogEntry || activeIsOAuth) return; const form = new FormData(event.currentTarget); const secret = composeSecret(activeCatalogEntry, form); - void actions.run(() => window.agentCompany.saveProviderCredential({ + return actions.run(() => window.agentCompany.saveProviderCredential({ orgId, providerId: active.id, secret, @@ -68,7 +68,7 @@ export function ProvidersPanel({ orgId, companyName, employeeId, providers, auth if (!modelFor) return; const model = String(new FormData(event.currentTarget).get("model") ?? ""); setModelError(null); - void actions.run(() => window.agentCompany.setProviderModel({ orgId, providerId: modelFor.id, model })) + return actions.run(() => window.agentCompany.setProviderModel({ orgId, providerId: modelFor.id, model })) .then((result) => { if (result) setModelFor(null); }) .catch((reason: unknown) => setModelError(reason instanceof Error ? reason.message : String(reason))); }; diff --git a/src/renderer/src/pages/settings/WorkspacePanel.tsx b/src/renderer/src/pages/settings/WorkspacePanel.tsx index 307ebd4d..61d427de 100644 --- a/src/renderer/src/pages/settings/WorkspacePanel.tsx +++ b/src/renderer/src/pages/settings/WorkspacePanel.tsx @@ -55,7 +55,7 @@ export function WorkspacePanel({ const submit = (event: FormEvent) => { event.preventDefault(); const form = new FormData(event.currentTarget); - void actions.run(() => window.agentCompany.createWorkspace({ + return actions.run(() => window.agentCompany.createWorkspace({ orgId, name: text(form, "name"), localPath: text(form, "localPath"), diff --git a/src/renderer/src/pages/settings/WorkspaceRow.tsx b/src/renderer/src/pages/settings/WorkspaceRow.tsx index 8dcd805b..1fff4c02 100644 --- a/src/renderer/src/pages/settings/WorkspaceRow.tsx +++ b/src/renderer/src/pages/settings/WorkspaceRow.tsx @@ -12,14 +12,14 @@ export function WorkspaceRow({ workspace, projects, focused, actions }: { worksp const [error, setError] = useState(null); const act = (operation: () => Promise, after?: () => void) => { setError(null); - operation().then(after, (reason: unknown) => setError(reason instanceof Error ? reason.message : String(reason))); + return operation().then(after, (reason: unknown) => setError(reason instanceof Error ? reason.message : String(reason))); }; const orgId = workspace.orgId; const submit = (event: FormEvent) => { event.preventDefault(); const form = new FormData(event.currentTarget); const value = (key: string) => String(form.get(key) ?? ""); - act(() => actions.run(() => window.agentCompany.updateWorkspace({ + return act(() => actions.run(() => window.agentCompany.updateWorkspace({ orgId, workspaceId: workspace.id, name: value("name"), localPath: value("localPath"), projectId: value("projectId") || null, })), () => setEditing(false)); }; diff --git a/src/renderer/src/pages/work/GoalDialog.tsx b/src/renderer/src/pages/work/GoalDialog.tsx index 11aecec5..f905cadc 100644 --- a/src/renderer/src/pages/work/GoalDialog.tsx +++ b/src/renderer/src/pages/work/GoalDialog.tsx @@ -29,7 +29,7 @@ export function GoalDialog({ const submit = (event: FormEvent) => { event.preventDefault(); const form = new FormData(event.currentTarget); - void actions.run(() => window.agentCompany.createGoal({ + return actions.run(() => window.agentCompany.createGoal({ orgId, title: text(form, "title"), description: text(form, "description"), diff --git a/src/renderer/src/pages/work/ProjectDialog.tsx b/src/renderer/src/pages/work/ProjectDialog.tsx index 397944e8..39569073 100644 --- a/src/renderer/src/pages/work/ProjectDialog.tsx +++ b/src/renderer/src/pages/work/ProjectDialog.tsx @@ -31,7 +31,7 @@ export function ProjectDialog({ const submit = (event: FormEvent) => { event.preventDefault(); const form = new FormData(event.currentTarget); - void actions.run(() => window.agentCompany.createProject({ + return actions.run(() => window.agentCompany.createProject({ orgId, goalId: optional(form, "goalId"), name: text(form, "name"), diff --git a/src/renderer/src/pages/work/TaskDetailDialog.tsx b/src/renderer/src/pages/work/TaskDetailDialog.tsx index f9b3e76e..1c781128 100644 --- a/src/renderer/src/pages/work/TaskDetailDialog.tsx +++ b/src/renderer/src/pages/work/TaskDetailDialog.tsx @@ -1,3 +1,4 @@ +import { useBusySubmit } from "../../shared/useBusySubmit"; import { approvalStateLabel, runTriggerLabel, taskEventLabel } from "../../i18n/labels"; import { TaskHoldNotice } from "./TaskHoldNotice"; import { useState, type FormEvent } from "react"; @@ -104,7 +105,7 @@ export function TaskDetailDialog({ const form = new FormData(event.currentTarget); const val = (key: string) => String(form.get(key) ?? "").trim(); setEditError(null); - void actions.run(() => window.agentCompany.updateTask({ + return actions.run(() => window.agentCompany.updateTask({ orgId, taskId: task.id, title: val("title"), @@ -323,13 +324,14 @@ function ActivityTab({ audit, approvals, onOpenApproval }: { audit: AuditEventRe function EditOverlay({ task, companyLanguage, agents, allTasks, projects, goals, workspaces, error, onSubmit, onCancel }: { task: TaskRecord; companyLanguage: WorkLanguage; agents: AgentRecord[]; allTasks: TaskRecord[]; projects: ProjectRecord[]; goals: GoalRecord[]; workspaces: WorkspaceRecord[]; error: string | null; - onSubmit: (e: FormEvent) => void; onCancel: () => void; + onSubmit: (e: FormEvent) => void | Promise; onCancel: () => void; }) { + const { busy, submit } = useBusySubmit(onSubmit); const beneath = descendantIds(task.id, allTasks); const otherTasks = allTasks.filter((t) => t.id !== task.id && t.orgId === task.orgId && !beneath.has(t.id)); return (
-
+

{t("Edit task")}