@wrongstack/webui 0.73.1 → 0.77.0

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.
@@ -2923,6 +2923,33 @@ async function startWebUI(opts = {}) {
2923
2923
  broadcast(clients, { type: "todos.updated", payload: { todos: [] } });
2924
2924
  break;
2925
2925
  }
2926
+ case "todos.remove": {
2927
+ const payload = msg.payload;
2928
+ if (!payload) {
2929
+ sendResult(ws, false, "Missing id or index");
2930
+ break;
2931
+ }
2932
+ const { id, index } = payload;
2933
+ let targetIdx = -1;
2934
+ if (typeof id === "string") {
2935
+ targetIdx = context.todos.findIndex((t) => t.id === id);
2936
+ } else if (typeof index === "number" && index > 0) {
2937
+ targetIdx = index - 1;
2938
+ }
2939
+ if (targetIdx < 0 || !context.todos[targetIdx]) {
2940
+ sendResult(ws, false, "Todo not found");
2941
+ break;
2942
+ }
2943
+ const removed = context.todos[targetIdx];
2944
+ const next = [
2945
+ ...context.todos.slice(0, targetIdx),
2946
+ ...context.todos.slice(targetIdx + 1)
2947
+ ];
2948
+ context.state.replaceTodos(next);
2949
+ sendResult(ws, true, `Removed: ${removed.content}`);
2950
+ broadcast(clients, { type: "todos.updated", payload: { todos: next } });
2951
+ break;
2952
+ }
2926
2953
  case "plan.get": {
2927
2954
  const planPath = context.meta["plan.path"];
2928
2955
  if (typeof planPath === "string" && planPath) {