@synergenius/flow-weaver-pack-weaver 0.9.81 → 0.9.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,87 +0,0 @@
1
- /**
2
- * TaskCreateForm — single-line task creation input for the swarm dashboard.
3
- *
4
- * Minimal: one input + one button. Type a title, hit Enter or click Create.
5
- * Description, priority, assignment can be edited after creation via task detail.
6
- */
7
- import React from 'react';
8
- import { Flex, Input, IconButton, toast, usePackWorkspace } from '@fw/plugin-ui-kit';
9
-
10
- const { useState, useCallback } = React;
11
-
12
- // ---------------------------------------------------------------------------
13
- // Types
14
- // ---------------------------------------------------------------------------
15
-
16
- interface TaskCreateFormProps {
17
- onTaskCreated?: () => void;
18
- }
19
-
20
- // ---------------------------------------------------------------------------
21
- // Helpers
22
- // ---------------------------------------------------------------------------
23
-
24
- function parseToolResult(raw: unknown): unknown {
25
- if (typeof raw === 'string') {
26
- try { return JSON.parse(raw); } catch { return raw; }
27
- }
28
- return raw;
29
- }
30
-
31
- // ---------------------------------------------------------------------------
32
- // Component
33
- // ---------------------------------------------------------------------------
34
-
35
- function TaskCreateForm({ onTaskCreated }: TaskCreateFormProps) {
36
- const ctx = usePackWorkspace();
37
- const { callTool } = ctx;
38
-
39
- const [title, setTitle] = useState('');
40
- const [creating, setCreating] = useState(false);
41
-
42
- const handleCreate = useCallback(async () => {
43
- const trimmed = title.trim();
44
- if (!trimmed) return;
45
-
46
- setCreating(true);
47
- try {
48
- const raw = await callTool('fw_weaver_task_create', { title: trimmed });
49
- const result = parseToolResult(raw) as { task?: { title: string } };
50
- toast(`Task created: ${result?.task?.title ?? trimmed}`, { type: 'success' });
51
- setTitle('');
52
- onTaskCreated?.();
53
- } catch (err: unknown) {
54
- toast(err instanceof Error ? err.message : 'Failed to create task', { type: 'error' });
55
- } finally {
56
- setCreating(false);
57
- }
58
- }, [title, callTool, onTaskCreated]);
59
-
60
- return React.createElement(Flex, {
61
- variant: 'row-center-start-nowrap-6',
62
- },
63
- React.createElement(Input, {
64
- type: 'text',
65
- size: 'small',
66
- placeholder: 'What needs to be done?',
67
- value: title,
68
- onChange: (v: string) => setTitle(v),
69
- onEnter: handleCreate,
70
- disabled: creating,
71
- defaultBoxStyle: { flex: 1, minWidth: 0 },
72
- inputBoxStyle: { maxWidth: 'none' },
73
- }),
74
- React.createElement(IconButton, {
75
- icon: 'add',
76
- size: 'sm',
77
- variant: 'fill',
78
- color: 'primary',
79
- onClick: handleCreate,
80
- disabled: creating || !title.trim(),
81
- loading: creating,
82
- }),
83
- );
84
- }
85
-
86
- export { TaskCreateForm };
87
- export default TaskCreateForm;