@columenlabs/lumen-ui 0.1.91 → 0.1.92

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.
package/dist/index.d.ts CHANGED
@@ -69,7 +69,7 @@ export { WhatsNew } from './whats-new.js';
69
69
  export { type LumenApp, LumenAppSwitcher, LumenSuiteSwitcher, type SuiteApp, type SuiteList, suiteApps, } from './app-switcher.js';
70
70
  export { type BriefActions, type BriefChange, type ScheduleChange, type ScheduleItem, type ScheduleRun, SchedulesSection, } from './schedules.js';
71
71
  export { NotificationsSettings } from './notifications.js';
72
- export { type TasksConfig, TasksButton, TasksProvider, useTasks } from './tasks.js';
72
+ export { type TasksConfig, TasksButton, TasksProvider, useTaskFor, useTasks } from './tasks.js';
73
73
  export { type McpServer, McpSettings } from './mcp-settings.js';
74
74
  export { lumenToast } from './lumen-toast.js';
75
75
  export { LumenShell, type LumenShellProps, type ShellUser, StatusItem, firstName, initials, maskAmount, useAmountsHidden, useApp, useShell, } from './shell.js';
package/dist/index.js CHANGED
@@ -76,7 +76,7 @@ export { WhatsNew } from './whats-new.js';
76
76
  export { LumenAppSwitcher, LumenSuiteSwitcher, suiteApps, } from './app-switcher.js';
77
77
  export { SchedulesSection, } from './schedules.js';
78
78
  export { NotificationsSettings } from './notifications.js';
79
- export { TasksButton, TasksProvider, useTasks } from './tasks.js';
79
+ export { TasksButton, TasksProvider, useTaskFor, useTasks } from './tasks.js';
80
80
  export { McpSettings } from './mcp-settings.js';
81
81
  export { lumenToast } from './lumen-toast.js';
82
82
  export { LumenShell, StatusItem, firstName, initials, maskAmount, useAmountsHidden, useApp, useShell, } from './shell.js';
package/dist/tasks.d.ts CHANGED
@@ -15,11 +15,18 @@ interface TasksState {
15
15
  /** Deletes one ended task, or every ended one; open tasks stay. */
16
16
  clear: (id?: string) => Promise<void>;
17
17
  open: (t: Task) => void;
18
+ /** Shows a task the app just started (its POST's answer) at once, before the next read, so its
19
+ * end toasts even when it finishes within one poll. */
20
+ track: (t: Task) => void;
18
21
  /** `TasksConfig.apps`. */
19
22
  apps?: Record<string, string>;
20
23
  }
21
24
  /** The Tasks list, or null where the app has none; `refresh()` after starting one shows it at once. */
22
25
  export declare function useTasks(): TasksState | null;
26
+ /** The newest task for one piece of work (`kind` + the engine's `ref`, such as a saved search's
27
+ * id), so the button that starts it can show it running (`Running 1/3`) and come back when it
28
+ * ends. Null when there is none or the app has no Tasks. */
29
+ export declare function useTaskFor(kind: string, ref: string | null | undefined): Task | null;
23
30
  export declare function TasksProvider({ config, children }: {
24
31
  config?: TasksConfig;
25
32
  children: ReactNode;
package/dist/tasks.js CHANGED
@@ -30,6 +30,15 @@ const TasksCtx = createContext(null);
30
30
  export function useTasks() {
31
31
  return useContext(TasksCtx);
32
32
  }
33
+ /** The newest task for one piece of work (`kind` + the engine's `ref`, such as a saved search's
34
+ * id), so the button that starts it can show it running (`Running 1/3`) and come back when it
35
+ * ends. Null when there is none or the app has no Tasks. */
36
+ export function useTaskFor(kind, ref) {
37
+ const tasks = useTasks();
38
+ if (!tasks?.list || !ref)
39
+ return null;
40
+ return tasks.list.tasks.find((t) => t.kind === kind && t.ref === ref) ?? null;
41
+ }
33
42
  const POLL_MS = 3000;
34
43
  export function TasksProvider({ config, children }) {
35
44
  if (!config)
@@ -84,6 +93,18 @@ function TasksLive({ api, apps, children, }) {
84
93
  activeIds.current = new Set(next.tasks.filter(isActive).map((t) => t.id));
85
94
  setList(next);
86
95
  }, [api, open, qc]);
96
+ const track = useCallback((t) => {
97
+ activeIds.current = new Set([...(activeIds.current ?? []), t.id]);
98
+ setList((l) => {
99
+ const tasks = [t, ...(l?.tasks ?? []).filter((x) => x.id !== t.id)];
100
+ return {
101
+ tasks,
102
+ active: tasks.filter(isActive).length,
103
+ unseen: tasks.filter((x) => x.finished_at && !x.seen_at).length,
104
+ };
105
+ });
106
+ void refresh();
107
+ }, [refresh]);
87
108
  const post = useCallback(async (path) => {
88
109
  await fetch(`${api}${path}`, {
89
110
  method: 'POST',
@@ -137,7 +158,7 @@ function TasksLive({ api, apps, children, }) {
137
158
  }, POLL_MS);
138
159
  return () => window.clearInterval(id);
139
160
  }, [active, refresh]);
140
- const value = useMemo(() => (gone ? null : { list, refresh, cancel, seen, clear, open, apps }), [gone, list, refresh, cancel, seen, clear, open, apps]);
161
+ const value = useMemo(() => (gone ? null : { list, refresh, cancel, seen, clear, open, track, apps }), [gone, list, refresh, cancel, seen, clear, open, track, apps]);
141
162
  return _jsx(TasksCtx.Provider, { value: value, children: children });
142
163
  }
143
164
  function endedToast(t, open) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ui",
3
- "version": "0.1.91",
3
+ "version": "0.1.92",
4
4
  "description": "Lumen: shared React components (frame, views, widgets, charts, drawers).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "@codemirror/lang-javascript": "6.2.5",
50
50
  "@codemirror/lang-json": "6.0.2",
51
51
  "@codemirror/lang-sql": "6.10.0",
52
- "@columenlabs/lumen-ui-types": "0.1.91",
52
+ "@columenlabs/lumen-ui-types": "0.1.92",
53
53
  "@dnd-kit/core": "6.3.1",
54
54
  "@dnd-kit/sortable": "10.0.0",
55
55
  "@dnd-kit/utilities": "3.2.2",