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