From 4986796fbf1205dc127c73e7dfbbdfe324a6b416 Mon Sep 17 00:00:00 2001 From: ehonis Date: Tue, 24 Nov 2026 15:33:28 -0500 Subject: [PATCH] Chats panel: Recent / By task, tasks in the sidebar on web and iPhone; task snooze presets Published from the private repository by oss-sync. - Chats panel: Recent / By task, tasks in the sidebar on web and iPhone; task snooze presets 34 files changed, 1300 insertions(+), 230 deletions(-) --- AGENTS.md | 4 +- docs/chat.md | 38 ++- docs/tasks.md | 4 +- mobile/AGENTS.md | 4 + mobile/src/features/chat/ChatsNav.tsx | 35 +- mobile/src/features/chat/TaskRows.tsx | 318 ++++++++++++++++++ mobile/src/features/chat/chatsOrder.ts | 20 ++ mobile/src/features/chat/icons.ts | 4 + mobile/src/features/todos/SheetCard.tsx | 6 +- mobile/src/features/todos/SheetItemPage.tsx | 4 +- mobile/src/features/todos/TodoCard.tsx | 4 +- .../src/features/todos/TodoDetailScreen.tsx | 8 +- mobile/src/features/work/shared.test.mjs | 7 +- mobile/src/features/work/state.ts | 24 +- mobile/src/lib/tasksnav/lists.ts | 84 +++++ mobile/src/lib/todos/format.ts | 79 ++--- scripts/web-layout.test.mjs | 31 +- web/src/chat/ChatsNav.tsx | 106 ++++-- web/src/chat/useChatDrafts.test.ts | 23 ++ web/src/chat/useChatDrafts.ts | 8 +- web/src/components/ChatView.tsx | 10 +- web/src/components/TodosView.tsx | 2 +- web/src/tasksnav/icons.ts | 3 + web/src/tasksnav/lists.test.ts | 85 +++++ web/src/tasksnav/lists.ts | 84 +++++ web/src/tasksnav/order.ts | 20 ++ web/src/tasksnav/parts.tsx | 250 ++++++++++++++ web/src/tasksnav/pick.ts | 19 ++ web/src/tasksnav/tasksnav.css | 101 ++++++ web/src/todos/TaskMenus.tsx | 4 +- web/src/todos/format.test.ts | 52 +-- web/src/todos/format.ts | 79 ++--- web/src/work/state.ts | 8 +- web/vitest.config.ts | 2 +- 34 files changed, 1300 insertions(+), 230 deletions(-) create mode 100644 mobile/src/features/chat/TaskRows.tsx create mode 100644 mobile/src/features/chat/chatsOrder.ts create mode 100644 mobile/src/lib/tasksnav/lists.ts create mode 100644 web/src/tasksnav/icons.ts create mode 100644 web/src/tasksnav/lists.test.ts create mode 100644 web/src/tasksnav/lists.ts create mode 100644 web/src/tasksnav/order.ts create mode 100644 web/src/tasksnav/parts.tsx create mode 100644 web/src/tasksnav/pick.ts create mode 100644 web/src/tasksnav/tasksnav.css diff --git a/AGENTS.md b/AGENTS.md index c669c28..9923a7c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -93,8 +93,8 @@ open-ended work. The default provider and model come from Settings → Providers | Apple data | `apple/`, the "Apple" block in `bridge.mjs`, the Messages view in `web/src/messages/` | macOS only, off unless `APPLE_ENABLED=true`. Reads Messages (`chat.db`), Contacts and Photos (`Photos.sqlite` plus Photos' own search index) read-only; sends through the Messages app with `osascript`. The owner sends from the Messages tab (last on the desktop rail, not on the phone drawer; `/messages` still opens); agents only stage an `imessage` inbox proposal (`totem_apple_propose_message`), which only the dashboard can accept. `docs/apple.md`. | | Chat | `chat/`, the "Web chat" block in `bridge.mjs`, `web/src/chat/` | Server-owned threads and runs that outlive the browser, listed as summaries and read a window at a time with Load earlier (`GET /api/threads?view=summary`, `GET /api/threads/?turns=10&before=`; one merge file shared by web and app, `web/src/chat/history.ts`; each chat reopens where it was left, `scrollMemory.ts`; docs/chat.md → Loading chats) (`POST /api/chat` streams SSE; `GET /api/chat/runs//stream?since=` re-attaches; only `POST /api/chat/stop` ends a run early; `POST /api/chat/steer` sends the owner's words and files into a running reply, live for Claude, interrupt-and-resume for the rest, `chat/steer.mjs`; or the message waits in the thread's queue, which the bridge drains itself when a run ends and holds after a stop or failure, `chat/queue.mjs`, `POST /api/chat/queue`; Settings → Chat › Follow-up behaviour picks which Enter does, Ctrl/⌘ the other). T3 Code's saved drafts: one per chat, several per place for chats not started yet (`new:`), each its words and finished uploads, rows atop the chats list and a pencil on a chat with unsent words; pure store `web/src/chat/drafts.ts` and what both clients do with it in `draftsShared.ts` (both copied byte for byte to `mobile/src/lib/chat/`, whose storage side is `draftsApp.ts`: a record per bridge, the drawer's "Unsent" rows, swipe or long-press to discard with the drawer's Undo line, saved as the app leaves the foreground) with the web's storage, other tabs and Undo in `draftsWeb.ts` and the chat view's wiring in `useChatDrafts.ts`, and the bridge holds a draft's uploads past the orphan sweep for 30 days from the last renewal (`POST /api/chat/uploads/hold`, `createUploadHolds`); docs/chat.md → Drafts. Native per-provider session resume, attachments (in the tray and inline in the text as T3 Code-style chips: the composer is a minimal TipTap editor over the message string, `web/src/chat/editor/`, its own chunk; a chip is `![name](totem-ref://upload/)` or `[name](…)` in the text, `web/src/chat/refs.ts`, copied byte for byte to the app; the bridge turns each into `[Image: …; ref=upload_]` plus one `` block with paths, resolving only the message's own uploads, `chat/refs.mjs`; lists, titles and search show plain names; docs/chat.md → Attachments), Markdown formatted as it is typed (numbered, bullet and task lists and code fences as real nodes that keep the prefix each line was typed with; Return, Tab and Shift+Tab in a list are edits of the string, `web/src/chat/editor/markdown.ts`, so the message is exactly the Markdown typed; Settings → Chat › Format Markdown as you type turns the drawing off per device; docs/chat.md → Lists and code in the message box), named tool cards folded with the reply's in-between text into one line above the answer, led by the connectors' own logos stacked (`web/src/chat/workFold.ts`; Claude's `tool_use_meta`, `connectorLook` in `chat/tools.mjs`); a picture a tool returned (an image the agent read, a screenshot) stays on its card as a thumbnail (`images` on the tool part, from a `tool_image` event), and the reply shows one only when the agent writes `![…](path)`, from its outputs folder, the temp dir or an image Claude read that turn (which reuses the card's upload); the upload sweep keeps ids a message's text names (docs/chat.md → Pictures the agent looks at), per-reply stats (setting, effort, tokens, tok/s, cost; `chat/stats.mjs`, shown on hover by `TurnStats.tsx`), no modes (every chat run gets the browser, computer use where the account has it, and an hour; the agent decides, `chat/reach.mjs`), the model picker (`ModelPicker.tsx`; no automatic routing since Auto/Instant/Thinking were retired; picking another account mid-chat hands the chat over with what it missed, `handoffReplay`, docs/chat.md → Switching accounts), thread titles and icons, local whisper.cpp dictation and an optional OpenAI Realtime voice mode. `docs/chat.md`. | | Chat projects | `chat/projects.mjs`, `chat/memory-ref.mjs`, `web/src/chat/Project*.tsx` | A project's page is its composer (centred on desktop) and chats (the first five, then Show more: `FIRST_CHATS` in `ProjectHome.tsx`); its files, instructions, memory, model and settings are a T3 Code-style card pinned top right (`ProjectCard.tsx`, stacked over a task's pinned card in `.vc-pins`; in the page on a phone). Chats grouped with a shared default model (a new chat takes its own pick, else the folder's, else the project's, else Settings → Providers: `threadChoice`/`projectDefault` in `web/src/chat/store.ts`, `projectModelDefault` on the bridge; a pick in a draft never carries to another chat), owner-written instructions, an agent-kept `memory.md` and shared files (`data/chat-projects/`). Each turn names the memory file with a one-line summary (size, entries, last updated, headings) and the agent reads it on demand, again when the summary changed; only the owner's instructions are pasted (memory used to be, once per turn of a resumed session). OpenCode, which cannot read outside `AGENT_CWD` unattended, gets the file's start instead. One level of folders (`parentId`) that read the parent read-only and keep their own memory; a chat can turn project context off (`projectContextOff`); an uploaded image or a website's icon can stand in for the Tabler icon (`image`, `chat/favicon.mjs`); finished chats wait on the owner (`needsReply`) until the owner opens one, replies or marks it read; "Mark as unread" sets `keepUnread`, which opening does not clear. The chats panel has one Snoozed and one Settled shelf, a project's page its own, T3 Code style (`web/src/chat/settle.ts`; auto-settle and wake-up are computed on read, never written). An agent that finished a one-off request calls `mark_chat_done` (`chat/done.mjs`, on `/agent-mcp`): the row offers a one-tap Settle until the reply is read, then the chat settles itself once he moves off it (`doneAt`; dropped by a failed or stopped reply, or by anything he writes in the chat: `wakeOnOwnerMessage` in `chat/store.mjs`, which also takes it off the Settled shelf and ends a snooze). `docs/chat.md` → Projects. | -| Chats panel | `web/src/chat/ChatsNav.tsx`, `web/src/chat/sidebar.ts`, `web/src/chat/ThreadList.tsx` (`ThreadItem`, `ShelfSection`), `web/src/work/TaskBadge.tsx` | Since 1.1, T3 Code's sidebar: one list of every chat in every project and folder (no tabs, no drilling into projects), as `sidebarLists` sorts it: unsent drafts, Pinned, everything still in play latest first, then Working (running and not waiting on him; starts open), Snoozed and one Settled shelf at the bottom. Live chats are cards: place ("Project › Folder" or Home) and status words (Awaiting input/approval, Your turn, Working, Woke, Done, else age), title, and the linked task as T3 shows a PR (`TaskBadge`: glyph coloured by due/done, title, due day; a click opens its task card, never the chat). A scope button (All chats, Home, a project or folder; `totem.chats.scope`) narrows the list without moving the page, with ↗ to the project's page and a dot for waiting chats it hides; New chat starts in the scoped project (`newChatInScope`). Totems' own chats are not listed (Totems is a rail item). The iPhone drawer is the same list (`mobile/src/features/chat/ChatsNav.tsx`, `mobile/AGENTS.md`). `docs/chat.md` → The chats panel. | -| Linked tasks | `web/src/work/`, `chat/task-folders.mjs`, `chat/task-link.mjs`, `/api/chat/task-folders` in `bridge.mjs` | A chat's task, shown on its card in the chats panel (above). Tasks and sheet rows are filed under a chat project or folder (a task's `folderId`; a sheet row's filing in `data/task-folders.json`, `TASK_FOLDERS_FILE`, `none` meaning Personal on purpose). The web panel's Tasks face (a list of every task with its chats, its add line and sort menu) was removed in 1.1; the Tasks page lists tasks. A task's card (`web/src/work/TaskCard.tsx`: folder, due, priority, repeat, snooze, description, chats, Open in Tasks) is pinned at the open chat's top right for that chat's own task (`PinnedTask` in `ChatView`; folds, never closes, the log moves left to clear it; opening that task anywhere unfolds it, `pinTask` in `card.ts`), and any other task opens it as a modal dialog (`TaskCardHost`, mounted once in `App.tsx`; a bottom sheet on a phone), from a chat card's task badge. A chat names at most one task (`thread.taskId`: a task id or a sheet row id), linked from its "…", the `$` menu, or by starting a chat from the task (`startTaskDraft`; the first send carries `taskId`, kept by `startChatTurn` on a new chat only). A chat whose task is finished (a local task done, a sheet row the owner marked done) settles as a `mark_chat_done` chat does, the way T3 Code settles a thread when its pull request merges: the bridge adds `taskDoneAt` to every chat it reads out (`chat/task-done.mjs`, worked out per read, never stored, so a task reopened brings the chat back and a task finished from the gateway counts), and `settle.ts` `taskDoneSince` counts it only when the task was finished after the owner last wrote in the chat (`docs/chat.md` → Settled and snoozed). A linked chat's composer shows the task (Done, change, unlink; `TaskBar.tsx`) and every non-voice turn carries a `LINKED TASK.` block (`linkedTaskBlock`). Filing a task, Move to… and Link to task… share one T3 Code-style project-selector popover (`ComboPicker.tsx`: search, arrows, Enter, "New folder/project/task …" from what was typed). Tasks load only while a card's task badge, a strip or the composer's `$` menu is on screen. A chat not started yet is placed from its composer with `$` (Home, a project or folder, or a task, which starts it through `startTaskDraft` in the task's folder; `web/src/chat/destinations.ts`, `destinations` on `Composer`), and ⌘/Ctrl+Shift+O starts a blank chat at Home from any page (a hotkey: `hotkeys` in `web/src/shortcuts.ts`, Settings → Keyboard › Hotkeys; `docs/shortcuts.md` → Hotkeys). The iPhone drawer is the same list since 1.1 (`mobile/src/features/chat/ChatsNav.tsx`, `lib/chat/sidebar.ts` byte for byte, `features/work/TaskBadge.tsx`; no Tasks face): a task opens its own page, which lists its chats, in place of the card; no `$` menu. `docs/chat.md` → Linked tasks, → Placing a new chat with `$`. | +| Chats panel | `web/src/chat/ChatsNav.tsx`, `web/src/chat/sidebar.ts`, `web/src/chat/ThreadList.tsx` (`ThreadItem`, `ShelfSection`), `web/src/work/TaskBadge.tsx` | Since 1.1, T3 Code's sidebar: one list of every chat in every project and folder (no tabs, no drilling into projects), as `sidebarLists` sorts it: unsent drafts, Pinned, everything still in play latest first, then Working (running and not waiting on him; starts open), Snoozed and one Settled shelf at the bottom. Recent / By task at the top (`totem.chats.order`, By task by default; `web/src/tasksnav/`): By task folds Working in, gathers chats on one open task under its row (`playByTask`), and lists the scope's next tasks below by due day, folding, with Snooze (Tomorrow, 3 days, a week) and New chat on hover and a click that starts a chat for the task, carrying a new chat's typed words (`pickTask`, `useChatDrafts.startForTask`). Live chats are cards: place ("Project › Folder" or Home) and status words (Awaiting input/approval, Your turn, Working, Woke, Done, else age), title, and the linked task as T3 shows a PR (`TaskBadge`: glyph coloured by due/done, title, due day; a click opens its task card, never the chat). A scope button (All chats, Home, a project or folder; `totem.chats.scope`) narrows the list without moving the page, with ↗ to the project's page and a dot for waiting chats it hides; New chat starts in the scoped project (`newChatInScope`). Totems' own chats are not listed (Totems is a rail item). The iPhone drawer is the same list (`mobile/src/features/chat/ChatsNav.tsx`, `mobile/AGENTS.md`). `docs/chat.md` → The chats panel. | +| Linked tasks | `web/src/work/`, `chat/task-folders.mjs`, `chat/task-link.mjs`, `/api/chat/task-folders` in `bridge.mjs` | A chat's task, shown on its card in the chats panel (above). Tasks and sheet rows are filed under a chat project or folder (a task's `folderId`; a sheet row's filing in `data/task-folders.json`, `TASK_FOLDERS_FILE`, `none` meaning Personal on purpose). The web panel's Tasks face (a list of every task with its chats, its add line and sort menu) was removed in 1.1; its By task order lists tasks with their chats now (Chats panel row), and the Tasks page edits them. A task's card (`web/src/work/TaskCard.tsx`: folder, due, priority, repeat, snooze, description, chats, Open in Tasks) is pinned at the open chat's top right for that chat's own task (`PinnedTask` in `ChatView`; folds, never closes, the log moves left to clear it; opening that task anywhere unfolds it, `pinTask` in `card.ts`), and any other task opens it as a modal dialog (`TaskCardHost`, mounted once in `App.tsx`; a bottom sheet on a phone), from a chat card's task badge. A chat names at most one task (`thread.taskId`: a task id or a sheet row id), linked from its "…", the `$` menu, or by starting a chat from the task (`startTaskDraft`; the first send carries `taskId`, kept by `startChatTurn` on a new chat only). A chat whose task is finished (a local task done, a sheet row the owner marked done) settles as a `mark_chat_done` chat does, the way T3 Code settles a thread when its pull request merges: the bridge adds `taskDoneAt` to every chat it reads out (`chat/task-done.mjs`, worked out per read, never stored, so a task reopened brings the chat back and a task finished from the gateway counts), and `settle.ts` `taskDoneSince` counts it only when the task was finished after the owner last wrote in the chat (`docs/chat.md` → Settled and snoozed). A linked chat's composer shows the task (Done, change, unlink; `TaskBar.tsx`) and every non-voice turn carries a `LINKED TASK.` block (`linkedTaskBlock`). Filing a task, Move to… and Link to task… share one T3 Code-style project-selector popover (`ComboPicker.tsx`: search, arrows, Enter, "New folder/project/task …" from what was typed). Tasks load while the chats panel, a card's task badge, a strip or the composer's `$` menu is on screen. A chat not started yet is placed from its composer with `$` (Home, a project or folder, or a task, which starts it through `startTaskDraft` in the task's folder; `web/src/chat/destinations.ts`, `destinations` on `Composer`), and ⌘/Ctrl+Shift+O starts a blank chat at Home from any page (a hotkey: `hotkeys` in `web/src/shortcuts.ts`, Settings → Keyboard › Hotkeys; `docs/shortcuts.md` → Hotkeys). The iPhone drawer is the same list since 1.1 (`mobile/src/features/chat/ChatsNav.tsx`, `lib/chat/sidebar.ts` byte for byte, `features/work/TaskBadge.tsx`; no Tasks face): a task opens its own page, which lists its chats, in place of the card; no `$` menu. `docs/chat.md` → Linked tasks, → Placing a new chat with `$`. | | Chat files | `chat/files.mjs`, `web/src/chat/FilesPanel.tsx`, `/api/chat/files*` in `bridge.mjs`, `openFile` in `web/src/chat/store.ts`, `web/src/links.ts` | T3 Code's files viewer: the chat's outputs folder as a tree beside the chat, every file openable in the canvas and downloadable from any device. It, the canvas, Browser and Agents panels share one slot, drag-resizable per panel (`docs/chat.md` → Side panel widths). Serves `CHAT_OUTPUTS_DIR` plus `FILES_ROOTS`, by real path, never Totem's `data/`, `secrets/` or `.env`. A reply's link to an absolute path opens there, and the same path opened as a URL redirects to the chat (`?file=`). Every opener goes through `openFile(path)`: `GET /api/chat/files/link` checks the path and returns a signed link (real path + 12 h expiry + HMAC under a random per-process key), which the canvas, its frames and the native download read without the bearer (a Files row's Download signs on the click; the listing carries no links); only the exact spelling `/api/chat/files/raw?…&sig=` skips the sign-in gate, and the roots/deny check runs on every read. A bearer-only dashboard read the bare raw URL with no header and showed `{"error":"unauthorized"}`; `chat/files-bridge.test.mjs` boots a bridge to hold this. `docs/chat.md` → Files panel. | | Download activity | `web/src/downloads.ts`, `web/src/components/DownloadActivity.tsx`, `desktop/src-tauri/src/lib.rs` | App-wide activity for download links, chat and question attachments, generated files, previews, project files, Messages files and journal audio. Active repeats join one transfer; different files have separate progress, cancel/retry and dismiss controls. Browsers offering a save-file picker stream directly to the chosen file; otherwise transfers buffer at most 32 MiB before handing larger files to the browser. Browser handoff and application transfer completion explicitly tell the owner to check Downloads, never claim an OS save. Native wrappers advertising `downloads` stream through Tauri and report real saved/failed events (indeterminate: Tauri has no byte progress); this requires a new desktop build. A saved native download gets Show in folder (Show in Finder on a Mac): the app keeps the path (`Downloads` in `lib.rs`, the last 50) and the page asks by the download's URL through a cancelled `totem-desktop://reveal?u=` navigation, never seeing a path; older wrappers do not send `reveal`, so no button. Raw chat files and signed uploads accept authenticated HEAD preflights without reading file bodies; bearer-only users need a session or a signed URL (an upload's `?sig=`, a chat file's signed link) for native/browser navigation handoff. | | Sub-agents | `chat/subagents.mjs`, `web/src/chat/AgentsPanel.tsx` | Agents a chat's agent starts: Claude's Agent/Task sub-agents (events tagged `parent_tool_use_id`), Codex collab children, and another CLI run from a shell (`codex exec`, `claude -p`, …), whose own session log is found by start time and prompt and tailed. Each folds into its tool card as `part.agent` (status, model, tokens, steps). The Agents panel beside the chat lists them and opens each one's live log. Each writes an `agent.delegate` line to the action log. `docs/chat.md` → Agents panel. | diff --git a/docs/chat.md b/docs/chat.md index b8939fd..437d870 100644 --- a/docs/chat.md +++ b/docs/chat.md @@ -1433,7 +1433,10 @@ is T3 Code's sidebar: one list of every chat, whatever project or folder it is f chat started three folders down is never out of sight. The rules are pure, in `web/src/chat/sidebar.ts` (`sidebarLists`, tested in `sidebar.test.ts`). Top to bottom: -- **New chat**, then the **scope button** ("All chats"). It narrows the list to Home or one +- **New chat**, then **Recent / By task**, which orders what is in play (below; kept per + device, `totem.chats.order`, By task unless he picks Recent). A count on By task is how many + tasks in the scope are due today or overdue. +- The **scope button** ("All chats"). It narrows the list to Home or one project (with its folders) or folder, the way T3's project filter does, and is kept per device (`totem.chats.scope`). It never moves the page: when scoped to a project, ↗ opens that project's page and × goes back to every chat. A dot on it means a chat the scope hides @@ -1449,6 +1452,22 @@ chat started three folders down is never out of sight. The rules are pure, in - **Snoozed** and **Settled**, folded, at the bottom: one of each for the whole panel, not one per project, left out while empty. Settled shows ten, then Show more. +**By task** (`web/src/tasksnav/`, the pure part in `lists.ts`, `playByTask`) keeps that +list but folds Working into it, and gathers the chats in play that work on one open task under +that task's row, the group placed where its latest chat would be. A chat with no task, or +whose task is done, stays a card of its own. Under the chats come the owner's **next tasks** +in the scope (a task's folder stands where a chat's project does), less those already +heading a group: Overdue, Today, Next 7 days, Later and No date, each a folding heading +(Later and No date start folded, kept per device as `totem.nav.folded`), then a folded +Snoozed tasks with Wake now on each. A task's row shows its check (done; for a sheet row, done for +him alone), title, folder and due day, a dot when one of its chats is answering or waiting +on him, and on hover Snooze (Tomorrow, For 3 days, For a week, or a time) and New chat. A +click on the row starts a chat for it in its folder (`tasksnav/pick.ts`): from a new chat's +page the words already typed go with it (`useChatDrafts.startForTask`); from an open chat it +starts a new one and leaves that chat's draft alone. The task picked for the chat being +written is highlighted, and stays in sight in a folded section. The tasks load while the +panel is up (`useWork` polls each minute). Snoozed and Settled stay at the bottom. + Each chat in the list, Pinned and Working is a **card**: its place (project icon and "Project › Folder", or Home) and on the right what it is doing (Awaiting input, Awaiting approval, Your turn, Working, Woke, Done for a finished reply he hasn't read, else how long @@ -1799,8 +1818,9 @@ timer (`pauseToast`/`resumeToast` in `web/src/toast.ts`). A chat can name the task it works on, and the chats panel shows it on the chat's card (The chats panel), the way T3 Code shows a thread's pull request. Action items get worked on in chats; this is where the two meet (`web/src/work/`). Until 1.1 the panel had a Tasks -face listing every open task with its chats; the Tasks page is now where tasks are listed, -added and sorted. +face listing every open task with its chats; now its By task order gathers chats under their +task and lists the next tasks under them (The chats panel), and the Tasks page is where tasks +are added, edited and sorted. - **Folders.** A task is filed under a chat project or folder, or nowhere ("Personal"): the same folders the Tasks page shows (`docs/tasks.md` → Folders). A local task carries its @@ -1909,9 +1929,19 @@ project. Working is a section of cards at the end of the list; Snoozed and Settl buttons (Settled and snoozed, above). Totems is a drawer row of its own under Overview, with a dot for a report waiting, and the drawer's Tasks face is gone, as on the web. It is built for a thumb: +- **Recent / By task** sits at the top, as on the web (`features/chat/chatsOrder.ts`, the web's + key; By task by default; the rules are `mobile/src/lib/tasksnav/lists.ts`, the web's + `tasksnav/lists.ts` byte for byte, checked by `features/work/shared.test.mjs`). By task folds + Working into the list, puts a task's chats in play under its row as slim rows, and lists the + next tasks below (`features/chat/TaskRows.tsx`), with Later, No date and Snoozed tasks folded. + A task's row: its ring finishes it, a tap starts a new chat for it in its folder + (`newTaskChat`; the words in a new chat's composer are not carried over, as they are on the + web), swiped right it is done, swiped left it shows Snooze (Tomorrow, 3 days, a week) and Open + (its page), and a long-press has all four. Done and Snooze leave the drawer's Undo line. + - **No second list.** The tasks are the app's own task store (`features/todos/store.ts`), so the Tasks page, a task's page and the drawer never disagree; the drawer reads them each time it - opens, only when a card names a task, never on a timer. Every call that finishes or reopens a + opens, never on a timer. Every call that finishes or reopens a task (`lib/api.ts`, `toldTasks`) makes the chat store read the list again, so its chats settle or come back at once. - **A task opens its page**, the sheet the Tasks page opens (`todo/[id]`, a sheet row's too), in place diff --git a/docs/tasks.md b/docs/tasks.md index 2ab22aa..682dbcf 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -78,8 +78,8 @@ mirrored byte for byte to `mobile/src/lib/todos/`. - **Select tasks** (the "…" menu) acts on many at once. Done's Undo reopens only the tasks it finished that did not roll (never one already done before); the toast says how many repeating tasks rolled to their next date. -- **Snooze** (`s`, or the hover button) offers `snoozeTimes` plus a picked time; Undo - wakes it. **Not doing** and **delete** (Delete/Backspace) offer Undo too. +- **Snooze** (`s`, or the hover button) offers `snoozeTimes` (Tomorrow, For 3 days, For a + week, each to 9:00 local, stepped by calendar day) plus a picked time; Undo wakes it. **Not doing** and **delete** (Delete/Backspace) offer Undo too. - **The pane** opens the selected row on the right (Enter or a click) and follows the keyboard cursor. Everything saves as it changes, with no Save button: title (Enter or leaving the field), description, Due, Priority, Folder (the chats panel's folder picker, diff --git a/mobile/AGENTS.md b/mobile/AGENTS.md index 2963ccd..e2090e3 100644 --- a/mobile/AGENTS.md +++ b/mobile/AGENTS.md @@ -127,6 +127,10 @@ Use `npx expo install ` for dependencies so versions match the SDK. linked task is done settles once read, as T3 settles a merged PR (`settle.ts` `taskDoneSince`, from the bridge's `taskDoneAt`); every task status call in `lib/api.ts` goes through `toldTasks`, which makes the chat store read the list again (`onTaskStatus` in `initChat`), so a new call that finishes or reopens a task goes through it too. + Recent / By task at the top (`features/chat/chatsOrder.ts`, By task by default) is the web's order: + `lib/tasksnav/lists.ts` is the web's `tasksnav/lists.ts` byte for byte (`features/work/shared.test.mjs`), and + `features/chat/TaskRows.tsx` draws a task's group and the next tasks (ring = Done, tap = new chat for it, swipe + right = Done, swipe left = Snooze and Open, long-press = all four; `snoozeTask` in `features/work/state.ts`). - **Tasks and chats** (`src/features/work/`): the task store the Tasks page uses (`features/work/state.ts` derives the WorkTasks, it keeps no copy; `lib/work/groups.ts` is the web's `work/groups.ts` byte for byte, `features/work/shared.test.mjs`). A task opens its page (`todo/[id]`), whose Chats section is the web card's; diff --git a/mobile/src/features/chat/ChatsNav.tsx b/mobile/src/features/chat/ChatsNav.tsx index 58aa2e4..395d37d 100644 --- a/mobile/src/features/chat/ChatsNav.tsx +++ b/mobile/src/features/chat/ChatsNav.tsx @@ -12,6 +12,11 @@ // swiped left it shows Snooze, Settle and "…" (the full menu), and long-press opens // that menu too. A chat with unsent words wears an amber pencil. // +// Recent / By task at the very top orders what is in play (chatsOrder.ts, By task +// by default): By task folds Working into the list, gathers chats on one open task +// under its row, and lists the next tasks under the chats (TaskRows.tsx; the rules +// are lib/tasksnav/lists.ts, the web's file byte for byte). +// // The scope button at the top narrows the list to Home or one project and its folders, // the way T3's project filter does (chatsScope.ts); ↗ opens that project's page, and a // dot says when a chat the scope hides is waiting on him. Totems' own chats are not @@ -52,6 +57,9 @@ import { drawerPan } from '../../shell/drawerGesture' import TaskBadge from '../work/TaskBadge' import { loadBoard, loadSheet } from '../todos/store' import { setSidebarScope, useSidebarScope } from './chatsScope' +import { setChatsOrder, useChatsOrder } from './chatsOrder' +import { useDrawerTasks, TaskGroupRows, NextTasks, OrderSwitch } from './TaskRows' +import { dueNow, playByTask } from '../../lib/tasksnav/lists' const muted80 = 'rgba(138, 145, 163, 0.8)' // The web card's status colours (chat.css .sb-working, .sb-done, .sb-needs). @@ -421,14 +429,23 @@ export default function ChatsNav({ onOpenChat, drafts, chatShowing = true }: { useEffect(() => { setDock({ scope, snoozed: snoozed.length, settled: settled.length, showing: chatShowing }) }, [scope, snoozed.length, settled.length, chatShowing]) useEffect(() => () => setDock(null), []) - // The cards' tasks are read each time the drawer opens: it stays mounted, so a timer here would poll while it is closed. + // The tasks are read each time the drawer opens (By task lists them, and Recent's cards and + // switch name them): it stays mounted, so a timer here would poll while it is closed. const status = useDrawerStatus() - const namesTask = useMemo(() => [...pinned, ...inbox, ...working].some((t) => !!t.taskId), [pinned, inbox, working]) useEffect(() => { - if (status !== 'open' || !namesTask) return + if (status !== 'open') return void loadBoard() void loadSheet() - }, [status, namesTask]) + }, [status]) + + // By task: everything in play (Working too), latest first, gathered under the task each chat works on. + const order = useChatsOrder() + const byTask = order === 'task' + const d = useDrawerTasks(scope, now) + const due = dueNow(d.sections) + const play = useMemo(() => (byTask ? playByTask([...inbox, ...working].sort((a, b) => activeAt(b, now) - activeAt(a, now)), d.tasks) : []), [byTask, inbox, working, now, d.tasks]) + const grouped = useMemo(() => new Set(play.flatMap((i) => (i.kind === 'task' ? [i.group.task.ref] : []))), [play]) + const slim = (t: ChatThread) => const card = (t: ChatThread) => { const project = t.projectId ? projects.find((p) => p.id === t.projectId) || null : null @@ -441,17 +458,21 @@ export default function ChatsNav({ onOpenChat, drafts, chatShowing = true }: { const draftsProject = scope !== 'all' && scope !== 'home' ? scope : null return ( + onOpenChat(null)} /> {drafts?.(draftsProject, scope === 'home')} {pinned.length ? {pinned.map(card)} : null} - {pinned.length && inbox.length ? : null} - {inbox.map(card)} + {pinned.length && (byTask ? play.length : inbox.length) ? : null} + {byTask + ? play.map((i) => (i.kind === 'task' ? : card(i.chat))) + : inbox.map(card)} {loaded && nothing ? ( {snoozed.length || settled.length ? 'All settled. Nothing is waiting on you.' : scope === 'all' ? 'Your chats will show up here.' : 'Chats here will show up in this list.'} ) : null} - {working.length ? ( + {byTask ? : null} + {working.length && !byTask ? ( diff --git a/mobile/src/features/chat/TaskRows.tsx b/mobile/src/features/chat/TaskRows.tsx new file mode 100644 index 0000000..4a12c57 --- /dev/null +++ b/mobile/src/features/chat/TaskRows.tsx @@ -0,0 +1,318 @@ +// The drawer's By task order (web tasksnav/parts.tsx): the owner's tasks in the +// list's scope, read from the board store (features/work/state.ts), by the web's +// rules (lib/tasksnav/lists.ts, the web's file byte for byte). A task with chats in +// play heads them; under the chats come the next tasks by due day (Overdue, Today, +// Next 7 days, then Later and No date folded) and a folded Snoozed. +// +// A task's row: its ring (Done; a sheet row is done for him alone), title, folder +// and due day. A tap starts a chat for it in its folder; swiped right it is done, +// swiped left it shows Snooze (Tomorrow, 3 days, a week) and Open; a long-press has +// all of those. What can be undone gets the drawer's Undo line (work/undoDock.tsx). +import React, { useCallback, useMemo, useRef, useState } from 'react' +import { StyleSheet, View } from 'react-native' +import { MenuView, type MenuAction } from '@react-native-menu/menu' +import ReanimatedSwipeable, { type SwipeableMethods } from 'react-native-gesture-handler/ReanimatedSwipeable' +import { useChat } from '../../lib/chat/store' +import { chatsByTask, folderOf, type WorkTask } from '../../lib/work/groups' +import { scopedTasks, snoozedTasks, taskActivity, taskSections, wakeOf, type TaskGroup, type TaskSectionId } from '../../lib/tasksnav/lists' +import { wakeLabel } from '../../lib/todos/board' +import { snoozeTimes } from '../../lib/todos/format' +import type { SidebarScope } from '../../lib/chat/sidebar' +import type { ChatThread } from '../../lib/chat/types' +import { colors, textAlpha } from '../../theme' +import { T } from '../../ui/Text' +import { Press } from '../../ui/kit' +import { impact, tap } from '../../ui/haptics' +import { showActionTree } from '../../ui/menu' +import { drawerPan } from '../../shell/drawerGesture' +import { useBoard, loadBoard } from '../todos/store' +import { PERSONAL } from '../todos/folders' +import CheckCircle from '../todos/CheckCircle' +import { completeTask, snoozeTask, useWorkTasks } from '../work/state' +import { newTaskChat, openTask } from '../work/nav' +import { showUndo } from '../work/undoDock' +import { dueLook } from '../work/look' +import { ProjectIcon } from './ThreadIcon' +import { TI } from './ui' +import { IconAlarmOff, IconCheck, IconChecklist, IconChevronDown, IconChevronUp, IconTable, IconUser, IconZzz } from './icons' + +const MUTED = 'rgba(138, 145, 163, 0.8)' +const WORKING = '#8ec5ff' +const SECTION_TONE: Partial> = { overdue: '#ff9aac', today: '#f3c969' } + +/** The tasks in the drawer's scope, their chats, and what is picked for the chat being written. */ +export function useDrawerTasks(scope: SidebarScope, now: number) { + const tasks = useWorkTasks() + const { loaded, error } = useBoard() + const threads = useChat((s) => s.threads) as ChatThread[] + const projects = useChat((s) => s.projects) + const runs = useChat((s) => s.runs) + const draftTaskId = useChat((s) => (!s.activeId ? s.draftTaskId : null)) + const scoped = useMemo(() => scopedTasks(tasks, scope, projects), [tasks, scope, projects]) + const sections = useMemo(() => taskSections(scoped, new Date(now)), [scoped, now]) + const snoozed = useMemo(() => snoozedTasks(scoped, now), [scoped, now]) + const byTask = useMemo(() => chatsByTask(threads, tasks), [threads, tasks]) + const live = useCallback((id: string) => !!runs[id], [runs]) + const open = sections.reduce((n, s) => n + s.tasks.length, 0) + return { now, tasks, projects, live, loaded, error, draftTaskId, sections, snoozed, byTask, open } +} + +export type DrawerTasks = ReturnType + +const snoozeActions = (now: Date): MenuAction[] => + snoozeTimes(now).map((o) => ({ id: `snooze:${o.value.toISOString()}`, title: o.label, subtitle: o.detail })) + +async function finish(ref: string) { + const undo = await completeTask(ref) + if (undo) showUndo(undo) + return !!undo +} + +async function snooze(ref: string, until: Date | null) { + const undo = await snoozeTask(ref, until) + if (undo) showUndo(undo) +} + +/** One task. `head`: it heads its chats in play, so no chat count. */ +function TaskRow({ task, d, head = false }: { task: WorkTask; d: DrawerTasks; head?: boolean }) { + const swipe = useRef(null) + const [ticked, setTicked] = useState(false) + const now = new Date(d.now) + const sheet = task.kind === 'sheet' + const chats = d.byTask.get(task.ref) + const activity = taskActivity(chats, d.live) + const selected = d.draftTaskId === task.ref + const due = dueLook(task.dueDate, now, true) + const folder = folderOf(task, d.projects) + const done = () => { + if (ticked) return + setTicked(true) + impact() + void finish(task.ref).then((ok) => { if (!ok) setTicked(false) }) + } + const run = (id: string) => { + swipe.current?.close() + tap() + if (id === 'chat') newTaskChat(task.ref) + else if (id === 'open') openTask(task.ref) + else if (id === 'done') done() + else if (id.startsWith('snooze:')) void snooze(task.ref, new Date(id.slice(7))) + } + const actions: MenuAction[] = [ + { id: 'chat', title: 'New chat for this task', image: 'plus.bubble' }, + { id: 'open', title: 'Open task', image: 'checklist' }, + { id: 'snooze', title: 'Snooze…', image: 'moon.zzz', subactions: snoozeActions(now) }, + { id: 'done', title: sheet ? 'Done for you' : 'Done', subtitle: sheet ? 'The sheet is unchanged' : undefined, image: 'checkmark.circle' }, + ] + const row = ( + + + run('chat')} + onLongPress={() => { impact(); showActionTree(actions, run, task.title) }} + accessibilityRole="button" + accessibilityLabel={`${task.title}, ${folder?.name || PERSONAL}${due ? `, ${due.text}` : ''}${activity === 'live' ? ', a chat is answering' : activity === 'waiting' ? ', a chat is waiting on you' : ''}`} + accessibilityHint="Starts a chat for this task. Swipe or long-press for more" + accessibilityState={{ selected }} + > + + {sheet ? : null} + {task.title} + {activity ? : null} + + + {folder ? : } + {folder?.name || PERSONAL} + {chats?.length && !head ? · {chats.length} chat{chats.length === 1 ? '' : 's'} : null} + + + {due ? {due.text} : null} + + ) + return ( + ( + + + Done + + )} + renderRightActions={() => ( + + run(nativeEvent.event)} style={st.menuTall}> + + + Snooze + + + run('open')} accessibilityLabel={`Open ${task.title}`}> + + Open + + + )} + onSwipeableOpen={(direction) => { + // RIGHT means the row travelled right, uncovering Done. + if (direction !== 'right') return + swipe.current?.close() + done() + }} + > + {row} + + ) +} + +/** A task with its chats in play under it, on a thread line. `chat` draws one (the drawer's slim row). */ +export function TaskGroupRows({ group, d, chat }: { group: TaskGroup; d: DrawerTasks; chat: (t: ChatThread) => React.ReactNode }) { + return ( + + + {group.chats.map(chat)} + + ) +} + +// Which sections are folded, per device, under the web's key. +const FOLDED_KEY = 'totem.nav.folded' +const readFolded = (): TaskSectionId[] => { try { const v = JSON.parse(localStorage.getItem(FOLDED_KEY) || 'null'); return Array.isArray(v) ? v : ['later', 'undated'] } catch { return ['later', 'undated'] } } + +/** The next tasks: a folding heading per due section, then a folded Snoozed. `skip`: tasks already heading a group. */ +export function NextTasks({ d, skip }: { d: DrawerTasks; skip: ReadonlySet }) { + const [folded, setFolded] = useState(readFolded) + const [snoozedOpen, setSnoozedOpen] = useState(false) + const toggle = (id: TaskSectionId) => { + tap() + setFolded((cur) => { + const next = cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id] + try { localStorage.setItem(FOLDED_KEY, JSON.stringify(next)) } catch { /* kept for this session */ } + return next + }) + } + const now = new Date(d.now) + if (d.error && !d.open) { + return ( + + Couldn’t load your tasks · {d.error} + { tap(); void loadBoard() }} accessibilityRole="button">Retry + + ) + } + return ( + + {d.sections.map((s) => { + const tasks = s.tasks.filter((t) => !skip.has(t.ref)) + if (!tasks.length) return null + const shut = folded.includes(s.id) + // Folded, the task picked for the chat being written still shows. + const rows = shut ? tasks.filter((t) => t.ref === d.draftTaskId) : tasks + const tone = SECTION_TONE[s.id] ?? MUTED + return ( + + toggle(s.id)} accessibilityRole="button" accessibilityState={{ expanded: !shut }} accessibilityLabel={`${s.label}, ${tasks.length} ${tasks.length === 1 ? 'task' : 'tasks'}`}> + {s.label} + {tasks.length} + + + + {rows.map((t) => )} + + ) + })} + {d.loaded && !d.open ? No open tasks. : null} + {d.snoozed.length ? ( + + { tap(); setSnoozedOpen((v) => !v) }} accessibilityRole="button" accessibilityState={{ expanded: snoozedOpen }} accessibilityLabel={`Snoozed tasks, ${d.snoozed.length}`}> + + Snoozed tasks + {d.snoozed.length} + + + + {snoozedOpen ? d.snoozed.map((t) => { + const wake = wakeOf(t) + return ( + + + { tap(); openTask(t.ref) }} accessibilityRole="button" accessibilityHint="Opens the task"> + {t.title} + {wake ? Back {wakeLabel(new Date(wake), now)} : null} + + { tap(); void snooze(t.ref, null) }} accessibilityRole="button" accessibilityLabel={`Wake ${t.title} now`}> + + + + ) + }) : null} + + ) : null} + + ) +} + +/** Recent / By task, at the top of the drawer's list. `due`: tasks due today or overdue, a count on By task. */ +export function OrderSwitch({ value, onChange, due }: { value: 'recent' | 'task'; onChange: (v: 'recent' | 'task') => void; due: number }) { + const option = (id: 'recent' | 'task', label: string) => { + const on = value === id + return ( + { if (!on) { tap(); onChange(id) } }} + accessibilityRole="radio" + accessibilityState={{ checked: on }} + accessibilityLabel={id === 'task' && due ? `${label}, ${due} due today or overdue` : label} + > + {label} + {id === 'task' && due ? {due} : null} + + ) + } + return ( + + {option('recent', 'Recent')} + {option('task', 'By task')} + + ) +} + +const st = StyleSheet.create({ + task: { flexDirection: 'row', alignItems: 'center', minHeight: 52, paddingRight: 10, borderRadius: 10 }, + on: { backgroundColor: 'rgba(91, 140, 255, 0.16)' }, + // Opaque, so the actions stay hidden until the row slides off them. + off: { backgroundColor: colors.bg2 }, + main: { flex: 1, minWidth: 0, gap: 2, paddingVertical: 6, paddingRight: 6 }, + line: { flexDirection: 'row', alignItems: 'center', gap: 5, minWidth: 0 }, + due: { flexShrink: 0, fontVariant: ['tabular-nums'] }, + dot: { width: 7, height: 7, borderRadius: 4, backgroundColor: colors.accent }, + group: { marginVertical: 2 }, + groupChats: { marginLeft: 22, paddingLeft: 6, borderLeftWidth: StyleSheet.hairlineWidth, borderLeftColor: 'rgba(255, 255, 255, 0.16)' }, + next: { marginTop: 10, paddingTop: 4, borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: colors.line }, + head: { flexDirection: 'row', alignItems: 'center', gap: 7, minHeight: 40, paddingHorizontal: 12 }, + rule: { flex: 1, height: StyleSheet.hairlineWidth, backgroundColor: colors.line }, + note: { paddingVertical: 8, paddingHorizontal: 12 }, + retry: { alignSelf: 'flex-start', marginLeft: 8, minHeight: 36, justifyContent: 'center', paddingHorizontal: 12, borderRadius: 8, backgroundColor: colors.bg3 }, + snoozedGlyph: { width: 44, alignItems: 'center' }, + wake: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, + swipeLeft: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 6, paddingLeft: 18, borderRadius: 10, marginBottom: 2 }, + swipe: { flexDirection: 'row', gap: 4, paddingLeft: 6, paddingBottom: 2 }, + swipeBtn: { width: 62, alignItems: 'center', justifyContent: 'center', gap: 2, borderRadius: 10 }, + swipeTall: { alignSelf: 'stretch' }, + swipeFill: { flex: 1 }, + menuTall: { alignSelf: 'stretch' }, + segs: { flexDirection: 'row', gap: 2, padding: 3, marginHorizontal: 4, marginBottom: 2, borderRadius: 11, backgroundColor: 'rgba(255, 255, 255, 0.05)' }, + seg: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 6, minHeight: 34, borderRadius: 8 }, + segOn: { backgroundColor: colors.bg3 }, + badge: { minWidth: 18, height: 18, paddingHorizontal: 5, borderRadius: 9, alignItems: 'center', justifyContent: 'center', backgroundColor: 'rgba(239, 199, 101, 0.2)' }, +}) diff --git a/mobile/src/features/chat/chatsOrder.ts b/mobile/src/features/chat/chatsOrder.ts new file mode 100644 index 0000000..54f2caf --- /dev/null +++ b/mobile/src/features/chat/chatsOrder.ts @@ -0,0 +1,20 @@ +// How the drawer orders the chats in play (web tasksnav/order.ts): Recent (latest +// first) or By task (chats on one task gathered under it, the next tasks below). +// Kept per device under the web's key; By task unless he picked Recent. +import { useSyncExternalStore } from 'react' + +export type ChatsOrder = 'recent' | 'task' + +const KEY = 'totem.chats.order' +const read = (): ChatsOrder => { try { return localStorage.getItem(KEY) === 'recent' ? 'recent' : 'task' } catch { return 'task' } } + +let order: ChatsOrder = read() +const subs = new Set<() => void>() + +export function setChatsOrder(next: ChatsOrder) { + order = next + try { localStorage.setItem(KEY, next) } catch { /* kept for this session */ } + subs.forEach((fn) => fn()) +} + +export const useChatsOrder = () => useSyncExternalStore((fn) => { subs.add(fn); return () => { subs.delete(fn) } }, () => order, () => order) diff --git a/mobile/src/features/chat/icons.ts b/mobile/src/features/chat/icons.ts index 7fd6fcf..2a8e327 100644 --- a/mobile/src/features/chat/icons.ts +++ b/mobile/src/features/chat/icons.ts @@ -14,3 +14,7 @@ export { default as IconDownload } from '@tabler/icons-react-native/dist/esm/ico export { default as IconFileOff } from '@tabler/icons-react-native/dist/esm/icons/IconFileOff.mjs' export { default as IconFileZip } from '@tabler/icons-react-native/dist/esm/icons/IconFileZip.mjs' export { default as IconArrowUpRight } from '@tabler/icons-react-native/dist/esm/icons/IconArrowUpRight.mjs' +// The drawer's task rows (By task): a sheet row's glyph, Personal and snooze. +export { default as IconTable } from '@tabler/icons-react-native/dist/esm/icons/IconTable.mjs' +export { default as IconUser } from '@tabler/icons-react-native/dist/esm/icons/IconUser.mjs' +export { default as IconZzz } from '@tabler/icons-react-native/dist/esm/icons/IconZzz.mjs' diff --git a/mobile/src/features/todos/SheetCard.tsx b/mobile/src/features/todos/SheetCard.tsx index df65462..59e06fe 100644 --- a/mobile/src/features/todos/SheetCard.tsx +++ b/mobile/src/features/todos/SheetCard.tsx @@ -45,7 +45,7 @@ export function sheetActions(item: SheetItem | SheetHiddenItem, source: string, ...(canMark && mark?.state !== 'done' ? [{ id: 'snooze', title: 'Snooze…', subtitle: 'For you only', image: 'moon.zzz', subactions: [ - ...snoozeTimes(now, item.dueDate).map((option): MenuAction => ({ id: `snooze:${option.value.toISOString()}`, title: option.label, subtitle: option.detail })), + ...snoozeTimes(now).map((option): MenuAction => ({ id: `snooze:${option.value.toISOString()}`, title: option.label, subtitle: option.detail })), { id: 'snooze:pick', title: 'Pick a date and time', image: 'calendar' }, ], } satisfies MenuAction] : []), @@ -231,9 +231,9 @@ export default function SheetCard({ item, source, now, dueSection, dim, folder, ) : null} ({ id: `snooze:${option.value.toISOString()}`, title: option.label, subtitle: option.detail })), + ...snoozeTimes(now).map((option): MenuAction => ({ id: `snooze:${option.value.toISOString()}`, title: option.label, subtitle: option.detail })), { id: 'snooze-more', title: '', displayInline: true, subactions: [{ id: 'snooze:pick', title: 'Pick a date and time', image: 'calendar' }] }, ]} themeVariant="dark" diff --git a/mobile/src/features/todos/SheetItemPage.tsx b/mobile/src/features/todos/SheetItemPage.tsx index 0642d43..71577d0 100644 --- a/mobile/src/features/todos/SheetItemPage.tsx +++ b/mobile/src/features/todos/SheetItemPage.tsx @@ -87,10 +87,10 @@ export default function SheetItemPage({ item, source, fetchedAt }: { item: Sheet .catch((cause) => { warn(); setMarkError(cause instanceof Error && cause.message ? cause.message : 'The row could not be marked.') }) } const snoozeMenu = () => showMenu([ - ...snoozeTimes(now, item.dueDate).map((option) => ({ label: `${option.label} (${option.detail})`, onPress: () => setMark('snoozed', option.value) })), + ...snoozeTimes(now).map((option) => ({ label: `${option.label} (${option.detail})`, onPress: () => setMark('snoozed', option.value) })), // The picker waits for the action sheet to finish closing: iOS refuses a second presentation mid-animation. { label: 'Pick a date and time', onPress: () => void setTimeout(() => setPick(true), 400) }, - ], { title: 'Snooze until', message: `For you only; ${source} is unchanged.` }) + ], { title: 'Snooze', message: `For you only; ${source} is unchanged.` }) const due = item.dueDate ? dueTone(item.dueDate, now, 'todo') : '' const dueColor = due === 'overdue' ? tone.red.color : due === 'today' ? tone.amber.color : colors.text return ( diff --git a/mobile/src/features/todos/TodoCard.tsx b/mobile/src/features/todos/TodoCard.tsx index 3726f2e..d497737 100644 --- a/mobile/src/features/todos/TodoCard.tsx +++ b/mobile/src/features/todos/TodoCard.tsx @@ -98,7 +98,7 @@ function dueActions(todo: Todo, now: Date, nested = false): MenuAction[] { function snoozeActions(todo: Todo, now: Date, nested = false): MenuAction[] { return [ - ...snoozeTimes(now, todo.dueDate).map((option): MenuAction => ({ + ...snoozeTimes(now).map((option): MenuAction => ({ id: `snooze:${option.value.toISOString()}`, title: option.label, subtitle: option.detail, })), ...group('snooze-more', [{ id: 'snooze:pick', title: 'Pick a date and time', image: 'calendar' }], nested), @@ -427,7 +427,7 @@ export default function TodoCard({ ) : null} {!done && onSnooze ? ( { swipe.current?.close(); act(nativeEvent.event) }} diff --git a/mobile/src/features/todos/TodoDetailScreen.tsx b/mobile/src/features/todos/TodoDetailScreen.tsx index 4e275b7..8f0dd3a 100644 --- a/mobile/src/features/todos/TodoDetailScreen.tsx +++ b/mobile/src/features/todos/TodoDetailScreen.tsx @@ -341,9 +341,9 @@ function TaskPage({ original, allTodos, issueStates, initialFocus }: { })) const snoozedUntil = todo.snoozedUntil && new Date(todo.snoozedUntil) > now ? todo.snoozedUntil : null // Rows are named, not timed: the time is worked out when one is picked, so a page left - // open for an hour does not snooze "in 20 minutes" into the past. + // open overnight does not snooze "tomorrow" to a day already here. const snoozeActions: MenuAction[] = [ - ...snoozeTimes(now, todo.dueDate).map((option): MenuAction => ({ id: `snooze:at:${option.label}`, title: option.label, subtitle: option.detail })), + ...snoozeTimes(now).map((option): MenuAction => ({ id: `snooze:at:${option.label}`, title: option.label, subtitle: option.detail })), { id: 'snooze-more', title: '', displayInline: true, subactions: [ { id: 'snooze:pick', title: 'Pick a date and time', image: 'calendar' }, @@ -387,7 +387,7 @@ function TaskPage({ original, allTodos, issueStates, initialFocus }: { if (id === 'snooze:pick') return void setTimeout(() => setPick('snooze'), 400) if (id === 'snooze:none') return void snooze(null) if (id.startsWith('snooze:at:')) { - const option = snoozeTimes(new Date(), todoRef.current.dueDate).find((item) => item.label === id.slice(10)) + const option = snoozeTimes(new Date()).find((item) => item.label === id.slice(10)) if (option) void snooze(option.value.toISOString()) return } @@ -490,7 +490,7 @@ function TaskPage({ original, allTodos, issueStates, initialFocus }: { valueColor={todo.recurrence ? colors.text : undefined} actions={repeatActions} onAction={onRow} menuTitle="Repeat" /> {!done || snoozedUntil ? ( + valueColor={snoozedUntil ? tone.amber.color : undefined} actions={snoozeActions} onAction={onRow} menuTitle="Snooze" /> ) : null} : } diff --git a/mobile/src/features/work/shared.test.mjs b/mobile/src/features/work/shared.test.mjs index 833adc1..b5237b6 100644 --- a/mobile/src/features/work/shared.test.mjs +++ b/mobile/src/features/work/shared.test.mjs @@ -1,5 +1,6 @@ // The drawer's task badges, a chat's strip and the link sheet read the web's task rules (web/src/work/groups.ts), -// copied byte for byte to mobile/src/lib/work/groups.ts. Their behaviour is tested +// copied byte for byte to mobile/src/lib/work/groups.ts, and the drawer's By task order reads +// web/src/tasksnav/lists.ts, copied to mobile/src/lib/tasksnav/lists.ts (tested on the web too). Their behaviour is tested // once, on the web (web/src/work/groups.test.ts); this file checks the copy has not // drifted, imports nothing at run time, and that node loads it as the app does. // Run with `node --test mobile/src/features/work/*.test.mjs` (also in the root npm test). @@ -18,6 +19,10 @@ test('lib/work/groups.ts is the web’s, byte for byte', () => { assert.equal(read('mobile/src/lib/work/groups.ts'), read('web/src/work/groups.ts'), 'mobile/src/lib/work/groups.ts has drifted from web/src/work/groups.ts') }) +test('lib/tasksnav/lists.ts (the drawer\u2019s By task order) is the web\u2019s, byte for byte', () => { + assert.equal(read('mobile/src/lib/tasksnav/lists.ts'), read('web/src/tasksnav/lists.ts'), 'mobile/src/lib/tasksnav/lists.ts has drifted from web/src/tasksnav/lists.ts') +}) + test('it imports only types, so it carries nothing of the web or React Native', () => { const source = read('web/src/work/groups.ts') for (const m of source.matchAll(/^\s*(import|export)\b([^'"]*?)from\s+['"]([^'"]+)['"]/gm)) { diff --git a/mobile/src/features/work/state.ts b/mobile/src/features/work/state.ts index 746f83b..7a0f3aa 100644 --- a/mobile/src/features/work/state.ts +++ b/mobile/src/features/work/state.ts @@ -13,7 +13,7 @@ import { useEffect, useMemo, useSyncExternalStore } from 'react' import { ApiError, createBoardTodo, getTodo, isAccountChanged } from '../../lib/api' import { getState as chatState } from '../../lib/chat/store' import { pushError } from '../../lib/toast' -import { rollsOnCompletion } from '../../lib/todos/board.ts' +import { rollsOnCompletion, wakeLabel } from '../../lib/todos/board.ts' import type { Todo } from '../../lib/todos/types' import { fromSheet, fromTodo, isOpenTodo, resolveRef, type WorkTask } from '../../lib/work/groups' import { boardActions } from '../todos/boardActions' @@ -119,6 +119,28 @@ export async function completeTask(ref: string): Promise { return undo(undoText('done', todo).text, () => { void actions().putBack(todo) }) } +/** Snooze until a time (a sheet row for the owner only), or with null wake it now; the Undo puts the old time back. */ +export async function snoozeTask(ref: string, until: Date | null): Promise { + const task = current(ref) + if (!task || task.done) return null + if (task.kind === 'sheet') { + const was = task.mark?.state === 'snoozed' ? task.mark.until ?? null : null + try { await markSheet(task.ref, until ? 'snoozed' : null, until) } + catch (cause) { if (!isAccountChanged(cause)) pushError(message(cause, 'The row could not be snoozed.')); return null } + if (!until) return null + return undo(`Snoozed until ${wakeLabel(until, new Date())}: ${quote(task.title)}.`, () => { + void markSheet(task.ref, was ? 'snoozed' : null, was ? new Date(was) : null).catch((cause) => pushError(message(cause, 'The row could not be put back.'))) + }) + } + const todo = task.todo! + const was = todo.snoozedUntil + if (!(await (until ? actions().snooze(todo, until.toISOString()) : actions().wake(todo)))) return null + if (!until) return null + return undo(`Snoozed until ${wakeLabel(until, new Date())}: ${quote(todo.title)}.`, () => { + void (was && Date.parse(was) > Date.now() ? actions().snooze(todo, was) : actions().wake(todo)) + }) +} + /** A new local task, filed under `folderId` when given. Returns it, or null when the bridge said no. */ export async function createTask(fields: { title: string; dueDate?: string | null; priority?: Todo['priority'] | null }, folderId: string | null): Promise { try { diff --git a/mobile/src/lib/tasksnav/lists.ts b/mobile/src/lib/tasksnav/lists.ts new file mode 100644 index 0000000..b5bfcbf --- /dev/null +++ b/mobile/src/lib/tasksnav/lists.ts @@ -0,0 +1,84 @@ +// What the chats panel lists of the owner's tasks: the open ones by when they are +// due, the ones he snoozed (soonest back first), and the chats in play gathered +// under the task each works on. Pure; ChatsNav and tasksnav/parts.tsx draw it. +import { byDue, dueLabel, resolveRef, type WorkTask } from '../work/groups' +import { inScope, type SidebarScope } from '../chat/sidebar' +import type { ChatThread, Project } from '../chat/types' + +export type TaskSectionId = 'overdue' | 'today' | 'soon' | 'later' | 'undated' +export interface TaskSection { id: TaskSectionId; label: string; tasks: WorkTask[] } + +const ORDER: TaskSectionId[] = ['overdue', 'today', 'soon', 'later', 'undated'] +const LABEL: Record = { overdue: 'Overdue', today: 'Today', soon: 'Next 7 days', later: 'Later', undated: 'No date' } + +/** Open and in sight: not done, not snoozed or archived. */ +export const isListed = (t: WorkTask) => !t.done && !t.hidden + +/** Open tasks under Overdue, Today, Next 7 days, Later and No date, each in due order; empty sections left out. */ +export function taskSections(tasks: readonly WorkTask[], now: Date): TaskSection[] { + const by = new Map() + for (const t of tasks) { + if (!isListed(t)) continue + const due = dueLabel(t.dueDate, now) + const id: TaskSectionId = !due ? 'undated' : due.tone === 'soon' ? 'soon' : due.tone + const list = by.get(id) || [] + list.push(t) + by.set(id, list) + } + return ORDER.filter((id) => by.has(id)).map((id) => ({ id, label: LABEL[id], tasks: by.get(id)!.sort(byDue) })) +} + +/** When a snoozed task or sheet row comes back, or null when it is not snoozed. */ +export function wakeOf(t: WorkTask): string | null { + if (t.todo) return t.todo.snoozedUntil + return t.mark?.state === 'snoozed' ? t.mark.until ?? null : null +} + +/** Tasks snoozed into the future, soonest back first (an archived task is hidden too, but is not snoozed). */ +export function snoozedTasks(tasks: readonly WorkTask[], now: number): WorkTask[] { + const at = (t: WorkTask) => Date.parse(wakeOf(t) || '') || 0 + return tasks.filter((t) => !t.done && t.hidden && at(t) > now).sort((a, b) => at(a) - at(b) || a.ref.localeCompare(b.ref)) +} + +/** What a task's chats are doing: one answering, one finished and waiting on him, or neither. */ +export function taskActivity(chats: readonly ChatThread[] | undefined, live: (id: string) => boolean): 'live' | 'waiting' | null { + if (!chats?.length) return null + if (chats.some((c) => live(c.id))) return 'live' + return chats.some((c) => c.needsReply) ? 'waiting' : null +} + +/** The tasks filed inside the panel's scope (a task's folder stands where a chat's project does). */ +export function scopedTasks(tasks: readonly WorkTask[], scope: SidebarScope, projects: Project[]): WorkTask[] { + return scope === 'all' ? tasks.slice() : tasks.filter((t) => inScope({ projectId: t.folderId ?? undefined }, scope, projects)) +} + +export interface TaskGroup { task: WorkTask; chats: ChatThread[] } +/** A row of the "by task" list: a task with its chats in play, or a chat on no open task. */ +export type PlayItem = { kind: 'task'; group: TaskGroup } | { kind: 'chat'; chat: ChatThread } + +/** + * The chats in play (in the order given: the panel's, latest first) gathered under + * their open task. A task lands where its latest chat would; a chat with no task, + * or whose task is done, snoozed, archived or unknown, stays a row of its own (a + * snoozed task is listed under Snoozed tasks, never twice). + */ +export function playByTask(chats: readonly ChatThread[], tasks: readonly WorkTask[]): PlayItem[] { + const open = new Map(tasks.filter(isListed).map((t) => [t.ref, t])) + const groups = new Map() + const out: PlayItem[] = [] + for (const c of chats) { + const task = c.taskId ? open.get(resolveRef(c.taskId, tasks)) : undefined + if (!task) { out.push({ kind: 'chat', chat: c }); continue } + const g = groups.get(task.ref) + if (g) { g.chats.push(c); continue } + const fresh = { task, chats: [c] } + groups.set(task.ref, fresh) + out.push({ kind: 'task', group: fresh }) + } + return out +} + +/** Due today or before: the count on the Tasks switch. */ +export function dueNow(sections: readonly TaskSection[]): number { + return sections.filter((s) => s.id === 'overdue' || s.id === 'today').reduce((n, s) => n + s.tasks.length, 0) +} diff --git a/mobile/src/lib/todos/format.ts b/mobile/src/lib/todos/format.ts index dd8b82e..3b1743e 100644 --- a/mobile/src/lib/todos/format.ts +++ b/mobile/src/lib/todos/format.ts @@ -54,79 +54,38 @@ export function dateLabel(value: string) { return new Intl.DateTimeFormat(undefined, { month: 'short', day: 'numeric' }).format(new Date(year, month - 1, day)) } -export function timeLabel(value: Date) { - return new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' }).format(value) -} - function dayTimeLabel(value: Date) { return new Intl.DateTimeFormat(undefined, { weekday: 'short', hour: 'numeric', minute: '2-digit' }).format(value) } -function dueDayLabel(value: Date) { - return new Intl.DateTimeFormat(undefined, { month: 'short', day: 'numeric' }).format(value) -} - -// Nine in the morning on the due date: the last moment a snooze can end and still leave the day to work with. -function dueMorning(dueDate: string) { - const [year, month, day] = dueDate.split('-').map(Number) - return new Date(year, month - 1, day, 9, 0, 0, 0) -} +export interface SnoozeTime { label: string; detail: string; value: Date } -// A week of lead time when there is a week to spare, otherwise the largest shorter run-up that still lands in the future. -function leadDays(daysUntilDue: number) { - if (daysUntilDue >= 8) return 7 - if (daysUntilDue >= 4) return 2 - if (daysUntilDue >= 2) return 1 - return 0 +// Nine in the morning `days` calendar days from now: stepped by day key, never by 24 hours, +// so the night the clocks change still lands on the right morning. +function morningIn(now: Date, days: number) { + const at = new Date(now) + at.setDate(at.getDate() + days) + at.setHours(9, 0, 0, 0) + return at } -export interface SnoozeTime { label: string; detail: string; value: Date } - -function dueTimes(now: Date, dueDate: string | null): SnoozeTime[] { - if (!dueDate) return [] - const due = dueMorning(dueDate) - if (due <= now) return [] - const today = new Date(now) - today.setHours(9, 0, 0, 0) - // Rounded, so a 23- or 25-hour day between them still counts as one day. - const daysUntilDue = Math.round((due.getTime() - today.getTime()) / 86_400_000) - const lead = leadDays(daysUntilDue) - const options: SnoozeTime[] = [] - if (lead) { - const runUp = new Date(due) - runUp.setDate(runUp.getDate() - lead) - const label = lead === 7 ? 'A week before it’s due' : lead === 2 ? 'Two days before it’s due' : 'The day before it’s due' - options.push({ label, detail: dueDayLabel(runUp), value: runUp }) - } - options.push({ label: 'The day it’s due', detail: dueDayLabel(due), value: due }) - return options +function dayDateTimeLabel(value: Date) { + return new Intl.DateTimeFormat(undefined, { weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }).format(value) } /** - * The snooze presets: two short ones counted in minutes (an instant is right there), - * then this evening, tomorrow and next Monday stepped by calendar day, then a run-up - * to the due date when the task has one still ahead. + * The snooze presets, the three the owner reaches for: tomorrow, three days and a + * whole week, each to nine in the morning. Anything else is the menu's own time picker. */ -export function snoozeTimes(now: Date, dueDate: string | null = null): SnoozeTime[] { - const minutes = new Date(now.getTime() + 20 * 60_000) - const hour = new Date(now.getTime() + 60 * 60_000) - const evening = new Date(now) - evening.setHours(18, 0, 0, 0) - if (evening <= now) evening.setDate(evening.getDate() + 1) - const tomorrow = new Date(now) - tomorrow.setDate(tomorrow.getDate() + 1) - tomorrow.setHours(9, 0, 0, 0) - const nextMonday = new Date(now) - const daysUntilMonday = (8 - nextMonday.getDay()) % 7 || 7 - nextMonday.setDate(nextMonday.getDate() + daysUntilMonday) - nextMonday.setHours(9, 0, 0, 0) +export function snoozeTimes(now: Date): SnoozeTime[] { + const tomorrow = morningIn(now, 1) + const three = morningIn(now, 3) + const week = morningIn(now, 7) return [ - { label: 'In 20 minutes', detail: timeLabel(minutes), value: minutes }, - { label: 'In 1 hour', detail: timeLabel(hour), value: hour }, - { label: 'This evening', detail: timeLabel(evening), value: evening }, { label: 'Tomorrow', detail: dayTimeLabel(tomorrow), value: tomorrow }, - { label: 'Next Monday', detail: dayTimeLabel(nextMonday), value: nextMonday }, - ...dueTimes(now, dueDate), + { label: 'For 3 days', detail: dayTimeLabel(three), value: three }, + // A week on is the same weekday as today, so it names the date. + { label: 'For a week', detail: dayDateTimeLabel(week), value: week }, ] } diff --git a/scripts/web-layout.test.mjs b/scripts/web-layout.test.mjs index 7ff8944..d8ef95e 100644 --- a/scripts/web-layout.test.mjs +++ b/scripts/web-layout.test.mjs @@ -485,7 +485,9 @@ test('a canvas widened at 1366 keeps its width while held and from its saved wid // scroll to fall back on): the old Tasks and Totems faces once put their rows // straight into the non-scrolling .vc-threads. This draws the real SidePanel and // MobileDrawer (web/src/chat/ChatsPanel.harness.tsx) with fictional chats, some -// linked to fictional tasks, and scrolls with the mouse wheel, as the owner does. +// linked to fictional tasks, and scrolls with the mouse wheel, as the owner does, +// in both orders: Recent (each linked chat a card with its task's badge) and By task +// (tasksnav/: linked chats gathered under their task's row, the next tasks below). // On a phone the drawer stays one scroll, with no list scrolling on its own inside it. const ago = (h) => new Date(Date.now() - h * 3600e3).toISOString() const panelApi = (url) => { @@ -508,18 +510,33 @@ const panelApi = (url) => { } test('the chats panel scrolls to its last chat, its cards fit, and the phone drawer stays one scroll', { skip: !executablePath || !esbuild }, async () => { - const served = await serveHarness({ entry: 'chat/ChatsPanel.harness.tsx', styles: ['styles.css', 'shell.css', 'chat/chat.css', 'work/work.css'], api: panelApi }) + const served = await serveHarness({ entry: 'chat/ChatsPanel.harness.tsx', styles: ['styles.css', 'shell.css', 'chat/chat.css', 'work/work.css', 'tasksnav/tasksnav.css'], api: panelApi }) const browser = await chromium.launch({ executablePath }) const lastTitle = 'Fictional chat 59' try { - for (const layout of [{ name: 'desktop' }, { name: 'macOS app', desktop: 'macos' }, { name: 'Windows app', desktop: 'windows' }, { name: 'phone', phone: true }]) { + const layouts = [{ name: 'desktop' }, { name: 'macOS app', desktop: 'macos' }, { name: 'Windows app', desktop: 'windows' }, { name: 'phone', phone: true }] + for (const [layout, order] of layouts.flatMap((l) => [[l, 'recent'], [l, 'task']])) { const page = await browser.newPage({ viewport: layout.phone ? { width: 390, height: 700 } : { width: 1200, height: 600 } }) + await page.addInitScript((order) => localStorage.setItem('totem.chats.order', order), order) await page.goto(`${served.url}?${new URLSearchParams({ ...(layout.phone ? { phone: '1' } : {}), ...(layout.desktop ? { desktop: layout.desktop } : {}) })}`) const frame = layout.phone ? '.sh-drawer' : '.sh-panel' - const where = layout.name - // Tasks load after the chats: wait for a card's task badge too. - await page.waitForFunction((frame) => [...document.querySelectorAll(`${frame} .sb-task-title`)].some((e) => e.textContent.startsWith('Fictional task')), frame, { timeout: 10000 }) - .catch(() => assert.fail(`${where}: no card showed its linked task`)) + const where = `${layout.name}, ${order === 'task' ? 'by task' : 'recent'}` + // Tasks load after the chats: wait for a card's task badge, or a group's task row, too. + const taskSel = order === 'task' ? '.tn-group .st-task-name' : '.sb-task-title' + await page.waitForFunction(([frame, sel]) => [...document.querySelectorAll(`${frame} ${sel}`)].some((e) => e.textContent.startsWith('Fictional task')), [frame, taskSel], { timeout: 10000 }) + .catch(() => assert.fail(`${where}: no ${order === 'task' ? 'group showed its task' : 'card showed its linked task'}`)) + if (order === 'task') { + const shape = await page.evaluate((frame) => ({ + groups: document.querySelectorAll(`${frame} .tn-group`).length, + pairs: [...document.querySelectorAll(`${frame} .tn-group-chats`)].filter((g) => g.children.length === 2).length, + badges: document.querySelectorAll(`${frame} .sb-task-title`).length, + next: !!document.querySelector(`${frame} .vc-threads-list > .tn-next`), + }), frame) + // 20 linked chats on 15 tasks (k0–k42 by 3, then k0–k12 again): five tasks hold two chats. + assert.deepEqual([shape.groups, shape.pairs], [15, 5], `${where}: one group per task, its chats under it`) + assert.equal(shape.badges, 0, `${where}: a grouped chat drops the badge its group's row already shows`) + assert.ok(shape.next, `${where}: the next tasks sit inside the scrolling list`) + } await page.waitForFunction(([frame, lastTitle]) => [...document.querySelectorAll(`${frame} .vc-thread-title`)].some((e) => e.textContent === lastTitle), [frame, lastTitle], { timeout: 10000 }) .catch(async () => assert.fail(`${where}: the harness never drew "${lastTitle}" (drew ${JSON.stringify(await page.evaluate((frame) => [...document.querySelectorAll(`${frame} .vc-thread-title`)].map((e) => e.textContent).slice(-3), frame))})`)) const box = await page.locator(frame).boundingBox() diff --git a/web/src/chat/ChatsNav.tsx b/web/src/chat/ChatsNav.tsx index f45ebc0..b824d27 100644 --- a/web/src/chat/ChatsNav.tsx +++ b/web/src/chat/ChatsNav.tsx @@ -9,7 +9,11 @@ import ChatsPanelDrafts from './ChatsPanelDrafts' import ComboPicker, { type ComboItem } from '../work/ComboPicker' import { folderOrder } from '../work/groups' import { attentionOf } from './attention' -import { keptOpenId } from './settle' +import { activeAt, keptOpenId } from './settle' +import { useTaskData, TaskGroupRows, TaskSections, TasksEmpty, SnoozedShelf, NavSeg, type PickTask } from '../tasksnav/parts' +import { dueNow, playByTask } from '../tasksnav/lists' +import { setChatsOrder, useChatsOrder } from '../tasksnav/order' +import { pickTask } from '../tasksnav/pick' import { sidebarLists, placeLabel, scopeLabel, validScope, inScope, type SidebarScope } from './sidebar' import type { ChatThread, Project } from './types' @@ -20,6 +24,11 @@ import type { ChatThread, Project } from './types' // live chat is a card naming where it lives and what it is doing, with its // linked task under the title, as T3 shows a thread's pull request. // +// Recent / By task at the top orders what is in play: latest first, or (the default) +// chats on one task gathered under it, latest group first, with the owner's next +// tasks under the chats (tasksnav/). A task's row starts a chat for it; its zzz +// snoozes it. +// // The scope button narrows the list to one project (with its folders) or Home, // the way T3's project filter does; it never moves him anywhere, and the open // project's page is one click from it. Totems' own chats are not here: they @@ -130,38 +139,87 @@ export function ChatsNav({ onOpenChat, chatShowing = true }: { onOpenChat: () => const project = t.projectId ? projects.find((p) => p.id === t.projectId) || null : null return } + // By task: the tasks in the panel's scope, and the chats in play gathered under theirs. + const order = useChatsOrder() + const byTask = order === 'task' + const d = useTaskData(scoped, now) + const pick = useCallback((ref) => { pickTask(ref); onOpenChat() }, [onOpenChat]) + const due = dueNow(d.sections) const { pinned, inbox, working, snoozed, settled } = lists + // Everything in play (Working too), latest first, gathered under the task each chat works on. + const play = useMemo(() => (byTask ? playByTask([...inbox, ...working].sort((a, b) => activeAt(b, now) - activeAt(a, now)), d.tasks) : []), [byTask, inbox, working, now, d.tasks]) + const grouped = useMemo(() => new Set(play.flatMap((i) => (i.kind === 'task' ? [i.group.task.ref] : []))), [play]) const nothing = !pinned.length && !inbox.length && !working.length const draftsProject = scoped !== 'all' && scoped !== 'home' ? scoped : null - return ( -
- + const tasksBadge = due > 0 ? {due} : null + // By task folds Working into the list, so its shelf is left out there. + const workingShelf = !byTask && working.length > 0 + const shelves = ( + <> + {workingShelf && ( + + {(rows) => rows.map(card)} + + )} + {snoozed.length > 0 && ( + + {(rows) => rows.map(slim('snoozed'))} + + )} + {settled.length > 0 && ( + + {(rows) => rows.map(slim('settled'))} + + )} + + ) + const empty = loaded && nothing && ( +
+ {snoozed.length || settled.length ? 'All settled. Nothing is waiting on you.' : scoped === 'all' ? 'Your chats will show up here.' : 'Chats here will show up in this list.'} +
+ ) + let list: React.ReactNode + if (byTask) { + // The panel's list with chats on the same task gathered under it, then the next tasks. + list = ( +
+ + {pinned.length > 0 &&
{pinned.map(card)}
} + {pinned.length > 0 && play.length > 0 &&
} + {play.map((i) => (i.kind === 'task' + ? + : card(i.chat)))} + {empty} +
+ + + +
+ {shelves} +
+ ) + } else { + list = (
{pinned.length > 0 &&
{pinned.map(card)}
} {pinned.length > 0 && inbox.length > 0 &&
} {inbox.map(card)} - {loaded && nothing && ( -
- {snoozed.length || settled.length ? 'All settled. Nothing is waiting on you.' : scoped === 'all' ? 'Your chats will show up here.' : 'Chats here will show up in this list.'} -
- )} - {working.length > 0 && ( - - {(rows) => rows.map(card)} - - )} - {snoozed.length > 0 && ( - - {(rows) => rows.map(slim('snoozed'))} - - )} - {settled.length > 0 && ( - - {(rows) => rows.map(slim('settled'))} - - )} + {empty} + {shelves}
+ ) + } + return ( +
+
+ By task{tasksBadge}, title: 'Chats gathered under their task, your next tasks below' }, + ]} /> +
+ + {list}
) } diff --git a/web/src/chat/useChatDrafts.test.ts b/web/src/chat/useChatDrafts.test.ts index a08c53c..6344523 100644 --- a/web/src/chat/useChatDrafts.test.ts +++ b/web/src/chat/useChatDrafts.test.ts @@ -51,3 +51,26 @@ describe('a retried message the bridge refused', () => { expect(drafts.keyAt({ kind: 'home' })).toBe(before) }) }) + +describe('a task picked from the new-chat page', () => { + const pickWith = (activeId: string | null) => renderHook(() => useChatDrafts({ + activeId, active: null, scopeProject: undefined, draftTaskId: null, draftKind: 'regular', setDraftKind: () => {}, + composer: { current: null }, slot: '', visible: false, editing: false, onEditFiles: () => {}, + })).result.current + + it('takes what was typed on Home with it', () => { + fake.threads = [] + const home = drafts.keyAt({ kind: 'home' }) + drafts.write(home, { text: 'draft a reply' }, Date.now()) + pickWith(null).startForTask('t1') + expect(drafts.get().drafts[drafts.keyAt({ kind: 'task', id: 't1' })]?.text).toBe('draft a reply') + }) + + it('leaves an open chat’s own draft with that chat (the side panel beside a chat)', () => { + fake.threads = [thread('c1', { messageCount: 2 })] + drafts.write('c1', { text: 'half a reply' }, Date.now()) + pickWith('c1').startForTask('t2') + expect(drafts.get().drafts.c1.text).toBe('half a reply') + expect(drafts.keyAt({ kind: 'task', id: 't2' })).not.toBe('c1') + }) +}) diff --git a/web/src/chat/useChatDrafts.ts b/web/src/chat/useChatDrafts.ts index 85140a5..8da7b75 100644 --- a/web/src/chat/useChatDrafts.ts +++ b/web/src/chat/useChatDrafts.ts @@ -81,6 +81,12 @@ export function useChatDrafts({ activeId, active, scopeProject, draftTaskId, dra else openProject(next.projectId) } const startIn = (id: string) => placeDraft({ taskId: null, projectId: id }) + /** A task picked in the chats panel: what he has typed in a new chat goes with it, as with `$`. */ + const startForTask = (ref: string) => { + // Beside an open chat (the side panel) the composer holds that chat's own draft, which stays with it. + if (activeId) { startTaskDraft(ref, taskHome(ref)); return } + placeDraft({ taskId: ref, projectId: taskHome(ref) }) + } /** `$`: the words, less the `$…`, and the tray's files go to the picked place. */ const pickDestination = (d: Destination, text: string) => { drafts.write(draftKey, { text }, at) @@ -169,7 +175,7 @@ export function useChatDrafts({ activeId, active, scopeProject, draftTaskId, dra const keepEdit = (threadId: string, text: string, files: Attachment[]) => keepEditIn(drafts, threadId, text, files, atRef.current) return { - draftKey, input: rec?.text || '', setInput, askFresh, startIn, pickDestination, takeForSend, fromDraft, onDiscarded, + draftKey, input: rec?.text || '', setInput, askFresh, startIn, startForTask, pickDestination, takeForSend, fromDraft, onDiscarded, onAttachmentsChange, showEditFiles, missingFiles, removeMissing, keepEdit, } } diff --git a/web/src/components/ChatView.tsx b/web/src/components/ChatView.tsx index e712f5a..eab2f05 100644 --- a/web/src/components/ChatView.tsx +++ b/web/src/components/ChatView.tsx @@ -54,6 +54,7 @@ import { useOwnerName } from '../useOwnerName' import { findLanding, landKey, useLandOn } from '../landing' import { AT_BOTTOM_PX, createFollow } from '../chat/follow' import ResizeHandle, { SIDE_PANEL_VAR } from './ResizeHandle' +import { installTaskPicker } from '../tasksnav/pick' function greeting(name: string) { const h = new Date().getHours() @@ -280,12 +281,19 @@ export default function ChatView({ onAuthError, visible = true, onOpenMenu, pane const onEditFiles = useCallback((files: Attachment[]) => setQueueEdit((e) => (e ? { ...e, files } : e)), []) // What the composer shows: an open chat's own draft, or the new-chat draft its place shows now. const { - draftKey, input, setInput, askFresh, startIn, pickDestination, takeForSend, fromDraft, onDiscarded, + draftKey, input, setInput, askFresh, startIn, startForTask, pickDestination, takeForSend, fromDraft, onDiscarded, onAttachmentsChange, showEditFiles, missingFiles, removeMissing, keepEdit, } = useChatDrafts({ activeId, active, scopeProject, draftTaskId, draftKind, setDraftKind, composer, visible, editing, onEditFiles, slot: !visible ? '' : empty && project ? 'project' : empty && !narrow ? 'empty' : 'dock', }) + // A task picked in the chats panel while this page shows: what is typed goes with it (tasksnav/pick.ts). + const startForTaskRef = useRef(startForTask) + startForTaskRef.current = startForTask + useEffect(() => { + if (!visible) return + return installTaskPicker((ref) => { startForTaskRef.current(ref); requestAnimationFrame(() => composer.current?.focus()) }) + }, [visible]) // A new chat starts on what was picked for it here, else its folder's or // project's model (threadChoice). A pick never follows him to another place, // and an open chat keeps its own model. diff --git a/web/src/components/TodosView.tsx b/web/src/components/TodosView.tsx index 19be7f1..3314191 100644 --- a/web/src/components/TodosView.tsx +++ b/web/src/components/TodosView.tsx @@ -779,7 +779,7 @@ export default function TodosView({ onAuthError, now: clock = () => new Date(), )} {bulkMenu?.kind === 'snooze' && ( setBulkMenu(null)} - items={[{ heading: 'Snooze until' }, ...snoozeTimes(now).map((option) => ({ key: option.label, label: option.label, detail: option.detail, onSelect: () => { void board.bulk(selectedIds, 'snooze', option.value.toISOString()); setSelection(new Set()) } }))]} /> + items={[{ heading: 'Snooze' }, ...snoozeTimes(now).map((option) => ({ key: option.label, label: option.label, detail: option.detail, onSelect: () => { void board.bulk(selectedIds, 'snooze', option.value.toISOString()); setSelection(new Set()) } }))]} /> )} {bulkMenu?.kind === 'priority' && ( setBulkMenu(null)} diff --git a/web/src/tasksnav/icons.ts b/web/src/tasksnav/icons.ts new file mode 100644 index 0000000..8eba0bb --- /dev/null +++ b/web/src/tasksnav/icons.ts @@ -0,0 +1,3 @@ +// The chats panel's task rows' glyphs: the chat's own set, plus the one it lacks. +export * from '../chat/icons' +export { default as IconMessagePlus } from '@tabler/icons-react/dist/esm/icons/IconMessagePlus.mjs' diff --git a/web/src/tasksnav/lists.test.ts b/web/src/tasksnav/lists.test.ts new file mode 100644 index 0000000..5f25f85 --- /dev/null +++ b/web/src/tasksnav/lists.test.ts @@ -0,0 +1,85 @@ +import { describe, expect, it } from 'vitest' +import { playByTask, scopedTasks, snoozedTasks, taskActivity, taskSections } from './lists' +import type { WorkTask } from '../work/groups' +import type { ChatThread } from '../chat/types' + +// Tuesday 24 November 2026, mid-afternoon. +const NOW = new Date(2026, 10, 24, 15, 0) +const task = (ref: string, f: Partial = {}): WorkTask => ({ + ref, kind: 'local', title: ref, dueDate: null, priority: 1, done: false, status: '', updatedAt: 0, folderId: null, ...f, +}) + +describe('taskSections', () => { + it('puts open tasks under when they are due, in due order, and leaves the rest out', () => { + const sections = taskSections([ + task('later', { dueDate: '2026-12-20' }), + task('undated'), + task('today', { dueDate: '2026-11-24' }), + task('overdue', { dueDate: '2026-11-20' }), + task('friday', { dueDate: '2026-11-27' }), + task('tomorrow', { dueDate: '2026-11-25' }), + task('done', { dueDate: '2026-11-24', done: true }), + task('snoozed', { dueDate: '2026-11-24', hidden: true }), + ], NOW) + expect(sections.map((s) => [s.label, s.tasks.map((t) => t.ref)])).toEqual([ + ['Overdue', ['overdue']], ['Today', ['today']], ['Next 7 days', ['tomorrow', 'friday']], ['Later', ['later']], ['No date', ['undated']], + ]) + }) + + it('sorts the most urgent first within a day', () => { + const [today] = taskSections([task('low', { dueDate: '2026-11-24', priority: 1 }), task('high', { dueDate: '2026-11-24', priority: 4 })], NOW) + expect(today.tasks.map((t) => t.ref)).toEqual(['high', 'low']) + }) +}) + +describe('snoozedTasks', () => { + it('lists tasks and sheet rows snoozed into the future, soonest back first', () => { + const todo = (until: string | null) => ({ snoozedUntil: until }) as WorkTask['todo'] + const list = snoozedTasks([ + task('week', { hidden: true, todo: todo('2026-12-01T15:00:00.000Z') }), + task('row', { kind: 'sheet', hidden: true, mark: { state: 'snoozed', at: '', until: '2026-11-25T15:00:00.000Z' } }), + task('lapsed', { hidden: true, todo: todo('2026-11-20T15:00:00.000Z') }), + task('archived', { hidden: true, todo: todo(null) }), + task('open', { todo: todo(null) }), + ], NOW.getTime()) + expect(list.map((t) => t.ref)).toEqual(['row', 'week']) + }) +}) + +describe('taskActivity', () => { + const chat = (id: string, needsReply = false) => ({ id, needsReply }) as ChatThread + it('says a chat is answering before it says one is waiting', () => { + expect(taskActivity([chat('a', true), chat('b')], (id) => id === 'b')).toBe('live') + expect(taskActivity([chat('a', true)], () => false)).toBe('waiting') + expect(taskActivity([chat('a')], () => false)).toBeNull() + expect(taskActivity(undefined, () => false)).toBeNull() + }) +}) + +describe('playByTask', () => { + const chat = (id: string, taskId?: string) => ({ id, taskId, messages: [{}] } as unknown as ChatThread) + it('gathers chats under their open task where its latest chat stands, and keeps the rest as rows', () => { + const tasks = [task('a'), task('b'), task('done', { done: true })] + const items = playByTask([chat('1', 'a'), chat('2'), chat('3', 'b'), chat('4', 'a'), chat('5', 'done')], tasks) + expect(items.map((i) => (i.kind === 'task' ? `${i.group.task.ref}:${i.group.chats.map((c) => c.id).join('+')}` : i.chat.id))).toEqual(['a:1+4', '2', 'b:3', '5']) + }) + it('leaves a snoozed task\u2019s chats as rows, so the task is listed once (under Snoozed tasks)', () => { + const items = playByTask([chat('1', 'z')], [task('z', { hidden: true })]) + expect(items.map((i) => i.kind)).toEqual(['chat']) + }) + it('finds a sheet row again after a row was inserted above it', () => { + const tasks = [task('sheet:7:12:abcd1234', { kind: 'sheet' })] + const items = playByTask([chat('1', 'sheet:7:11:abcd1234')], tasks) + expect(items[0].kind).toBe('task') + }) +}) + +describe('scopedTasks', () => { + const projects = [{ id: 'p', name: 'P' }, { id: 'f', name: 'F', parentId: 'p' }, { id: 'q', name: 'Q' }] as any + const tasks = [task('home'), task('inP', { folderId: 'p' }), task('inF', { folderId: 'f' }), task('inQ', { folderId: 'q' })] + it('keeps a project with its folders, or Home, or everything', () => { + expect(scopedTasks(tasks, 'p', projects).map((t) => t.ref)).toEqual(['inP', 'inF']) + expect(scopedTasks(tasks, 'home', projects).map((t) => t.ref)).toEqual(['home']) + expect(scopedTasks(tasks, 'all', projects)).toHaveLength(4) + }) +}) diff --git a/web/src/tasksnav/lists.ts b/web/src/tasksnav/lists.ts new file mode 100644 index 0000000..b5bfcbf --- /dev/null +++ b/web/src/tasksnav/lists.ts @@ -0,0 +1,84 @@ +// What the chats panel lists of the owner's tasks: the open ones by when they are +// due, the ones he snoozed (soonest back first), and the chats in play gathered +// under the task each works on. Pure; ChatsNav and tasksnav/parts.tsx draw it. +import { byDue, dueLabel, resolveRef, type WorkTask } from '../work/groups' +import { inScope, type SidebarScope } from '../chat/sidebar' +import type { ChatThread, Project } from '../chat/types' + +export type TaskSectionId = 'overdue' | 'today' | 'soon' | 'later' | 'undated' +export interface TaskSection { id: TaskSectionId; label: string; tasks: WorkTask[] } + +const ORDER: TaskSectionId[] = ['overdue', 'today', 'soon', 'later', 'undated'] +const LABEL: Record = { overdue: 'Overdue', today: 'Today', soon: 'Next 7 days', later: 'Later', undated: 'No date' } + +/** Open and in sight: not done, not snoozed or archived. */ +export const isListed = (t: WorkTask) => !t.done && !t.hidden + +/** Open tasks under Overdue, Today, Next 7 days, Later and No date, each in due order; empty sections left out. */ +export function taskSections(tasks: readonly WorkTask[], now: Date): TaskSection[] { + const by = new Map() + for (const t of tasks) { + if (!isListed(t)) continue + const due = dueLabel(t.dueDate, now) + const id: TaskSectionId = !due ? 'undated' : due.tone === 'soon' ? 'soon' : due.tone + const list = by.get(id) || [] + list.push(t) + by.set(id, list) + } + return ORDER.filter((id) => by.has(id)).map((id) => ({ id, label: LABEL[id], tasks: by.get(id)!.sort(byDue) })) +} + +/** When a snoozed task or sheet row comes back, or null when it is not snoozed. */ +export function wakeOf(t: WorkTask): string | null { + if (t.todo) return t.todo.snoozedUntil + return t.mark?.state === 'snoozed' ? t.mark.until ?? null : null +} + +/** Tasks snoozed into the future, soonest back first (an archived task is hidden too, but is not snoozed). */ +export function snoozedTasks(tasks: readonly WorkTask[], now: number): WorkTask[] { + const at = (t: WorkTask) => Date.parse(wakeOf(t) || '') || 0 + return tasks.filter((t) => !t.done && t.hidden && at(t) > now).sort((a, b) => at(a) - at(b) || a.ref.localeCompare(b.ref)) +} + +/** What a task's chats are doing: one answering, one finished and waiting on him, or neither. */ +export function taskActivity(chats: readonly ChatThread[] | undefined, live: (id: string) => boolean): 'live' | 'waiting' | null { + if (!chats?.length) return null + if (chats.some((c) => live(c.id))) return 'live' + return chats.some((c) => c.needsReply) ? 'waiting' : null +} + +/** The tasks filed inside the panel's scope (a task's folder stands where a chat's project does). */ +export function scopedTasks(tasks: readonly WorkTask[], scope: SidebarScope, projects: Project[]): WorkTask[] { + return scope === 'all' ? tasks.slice() : tasks.filter((t) => inScope({ projectId: t.folderId ?? undefined }, scope, projects)) +} + +export interface TaskGroup { task: WorkTask; chats: ChatThread[] } +/** A row of the "by task" list: a task with its chats in play, or a chat on no open task. */ +export type PlayItem = { kind: 'task'; group: TaskGroup } | { kind: 'chat'; chat: ChatThread } + +/** + * The chats in play (in the order given: the panel's, latest first) gathered under + * their open task. A task lands where its latest chat would; a chat with no task, + * or whose task is done, snoozed, archived or unknown, stays a row of its own (a + * snoozed task is listed under Snoozed tasks, never twice). + */ +export function playByTask(chats: readonly ChatThread[], tasks: readonly WorkTask[]): PlayItem[] { + const open = new Map(tasks.filter(isListed).map((t) => [t.ref, t])) + const groups = new Map() + const out: PlayItem[] = [] + for (const c of chats) { + const task = c.taskId ? open.get(resolveRef(c.taskId, tasks)) : undefined + if (!task) { out.push({ kind: 'chat', chat: c }); continue } + const g = groups.get(task.ref) + if (g) { g.chats.push(c); continue } + const fresh = { task, chats: [c] } + groups.set(task.ref, fresh) + out.push({ kind: 'task', group: fresh }) + } + return out +} + +/** Due today or before: the count on the Tasks switch. */ +export function dueNow(sections: readonly TaskSection[]): number { + return sections.filter((s) => s.id === 'overdue' || s.id === 'today').reduce((n, s) => n + s.tasks.length, 0) +} diff --git a/web/src/tasksnav/order.ts b/web/src/tasksnav/order.ts new file mode 100644 index 0000000..49d0d9a --- /dev/null +++ b/web/src/tasksnav/order.ts @@ -0,0 +1,20 @@ +// How the chats panel orders the chats in play: Recent (latest first, as T3 Code +// does) or By task (chats on one task gathered under it, the next tasks below). +// Per device, in localStorage; By task unless he picked Recent. +import { useSyncExternalStore } from 'react' + +export type ChatsOrder = 'recent' | 'task' + +const KEY = 'totem.chats.order' +const read = (): ChatsOrder => { try { return localStorage.getItem(KEY) === 'recent' ? 'recent' : 'task' } catch { return 'task' } } + +let order: ChatsOrder = read() +const subs = new Set<() => void>() + +export function setChatsOrder(next: ChatsOrder) { + order = next + try { localStorage.setItem(KEY, next) } catch { /* private window */ } + subs.forEach((fn) => fn()) +} + +export const useChatsOrder = () => useSyncExternalStore((fn) => { subs.add(fn); return () => { subs.delete(fn) } }, () => order) diff --git a/web/src/tasksnav/parts.tsx b/web/src/tasksnav/parts.tsx new file mode 100644 index 0000000..ea64c1b --- /dev/null +++ b/web/src/tasksnav/parts.tsx @@ -0,0 +1,250 @@ +// The tasks in the chats panel's By task order (ChatsNav.tsx): the data (open tasks +// in the panel's scope by due day, snoozed tasks, each task's chats), a task's row +// with its check, snooze and new-chat buttons, a task with its chats in play under +// it, and the Recent / By task switch. +import React, { useCallback, useMemo, useRef, useState } from 'react' +import { useChat } from '../chat/store' +import { ThreadItem } from '../chat/ThreadList' +import type { SidebarScope } from '../chat/sidebar' +import ProjectIcon from '../chat/ProjectIcon' +import { TI } from '../chat/ui' +import { IconChevronDown, IconChevronUp, IconCircle, IconCircleCheck, IconTable, IconZzz, IconMessagePlus, IconUser, IconAlarmOff, IconRefresh } from './icons' +import { SnoozeMenu } from '../todos/TaskMenus' +import { wakeLabel } from '../todos/board' +import { chatsByTask, dueLabel, folderOf, snoozeSubject, type WorkTask } from '../work/groups' +import { completeTask, loadWork, snoozeTask, useWork } from '../work/state' +import { PERSONAL } from '../todos/folders' +import { scopedTasks, snoozedTasks, taskActivity, taskSections, wakeOf, type TaskGroup, type TaskSectionId } from './lists' +import type { Project } from '../chat/types' +import '../work/work.css' +import './tasksnav.css' + +export function useTaskData(scope: SidebarScope, now: number) { + const tasks = useWork((s) => s.tasks) + const loaded = useWork((s) => s.loaded) + const error = useWork((s) => s.error) + const threads = useChat((s) => s.threads) + const projects = useChat((s) => s.projects) + const runs = useChat((s) => s.runs) + const draftTaskId = useChat((s) => (!s.activeId ? s.draftTaskId : null)) + const live = useCallback((id: string) => !!runs[id], [runs]) + const scoped = useMemo(() => scopedTasks(tasks, scope, projects), [tasks, scope, projects]) + const sections = useMemo(() => taskSections(scoped, new Date(now)), [scoped, now]) + const snoozed = useMemo(() => snoozedTasks(scoped, now), [scoped, now]) + const byTask = useMemo(() => chatsByTask(threads, tasks), [threads, tasks]) + const open = sections.reduce((n, s) => n + s.tasks.length, 0) + return { now, tasks, projects, runs, live, loaded, error, draftTaskId, sections, snoozed, byTask, open } +} + +export type TaskData = ReturnType + +/** What the panel does with a picked task: start a chat for it in its folder (pick.ts), and show the chat page. */ +export type PickTask = (ref: string) => void + +/** Nothing to list, or the list could not be read (said, with Retry; never "No open tasks"). */ +export function TasksEmpty({ d }: { d: TaskData }) { + if (d.error && !d.open) { + return ( +
+ Couldn’t load your tasks · {d.error} + +
+ ) + } + return d.loaded && !d.open ?

No open tasks.

: null +} + +/** A task's folder, small: its icon and name, Personal when unfiled. */ +export function FolderTag({ task, projects }: { task: WorkTask; projects: Project[] }) { + const folder = folderOf(task, projects) + const parent = folder?.parentId ? projects.find((p) => p.id === folder.parentId) : undefined + return ( + + {folder ? : } + {folder?.name || PERSONAL} + + ) +} + +export function DueTag({ task, now }: { task: WorkTask; now: Date }) { + const due = dueLabel(task.dueDate, now) + return due ? {due.text} : null +} + +/** The round check: done for a local task, done for him alone for a sheet row (the sheet is untouched). */ +export function TaskCheck({ task }: { task: WorkTask }) { + const sheet = task.kind === 'sheet' + return ( + + ) +} + +/** The zzz button and its menu: tomorrow, three days, a week, or a time. */ +export function SnoozeButton({ task, now, onOpenChange }: { task: WorkTask; now: Date; onOpenChange?: (open: boolean) => void }) { + const [open, setOpen] = useState(false) + const ref = useRef(null) + const toggle = (v: boolean) => { setOpen(v); onOpenChange?.(v) } + return ( + <> + + {open && toggle(false)} + onSnooze={(until) => void snoozeTask(task.ref, until)} onWake={() => void snoozeTask(task.ref, null)} + />} + + ) +} + +/** + * One task: its check, its title with the folder and due day under it, and on hover + * Snooze and New chat. A click on the row starts a chat for it. + */ +export function TaskLine({ task, d, pick, compact = false, head = false }: { + task: WorkTask; d: TaskData; pick: PickTask; compact?: boolean + /** The head of a group, with its chats listed under it: no chat count. */ + head?: boolean +}) { + const [menu, setMenu] = useState(false) + const now = new Date(d.now) + const chats = d.byTask.get(task.ref) + const activity = taskActivity(chats, d.live) + const selected = d.draftTaskId === task.ref + const start = () => pick(task.ref) + // The row picked for the chat being written stays in view (the list is long). + const ref = useRef(null) + // Only when it becomes the pick, never on arrival, which would scroll the composer away. + const was = useRef(selected) + React.useEffect(() => { + if (selected && !was.current) ref.current?.scrollIntoView?.({ block: 'nearest' }) + was.current = selected + }, [selected]) + return ( +
+ + + +
+ + +
+
+ ) +} + +/** A snoozed task: when it is back, and Wake now. */ +export function SnoozedLine({ task, d }: { task: WorkTask; d: TaskData }) { + const wake = wakeOf(task) + return ( +
+ + + {task.title} + + + {wake && Back {wakeLabel(new Date(wake), new Date(d.now))}} + + +
+ +
+
+ ) +} + +/** "Snoozed tasks (n)": a folding heading like the due sections', over the snoozed tasks (Wake now on each). */ +export function SnoozedShelf({ d }: { d: TaskData }) { + const [open, setOpen] = useState(false) + if (!d.snoozed.length) return null + return ( +
+ + {open && d.snoozed.map((t) => )} +
+ ) +} + +/** A task with its chats in play under it: the task's row, then each chat as a slim row. */ +export function TaskGroupRows({ group, d, pick, activeId, onOpen }: { group: TaskGroup; d: TaskData; pick: PickTask; activeId: string | null; onOpen: (id: string) => void }) { + return ( +
+ +
+ {group.chats.map((t) => )} +
+
+ ) +} + +const FOLDED_KEY = 'totem.nav.folded' +const readFolded = (): TaskSectionId[] => { try { const v = JSON.parse(localStorage.getItem(FOLDED_KEY) || 'null'); return Array.isArray(v) ? v : ['later', 'undated'] } catch { return ['later', 'undated'] } } + +/** Overdue, Today, Next 7 days, Later, No date: folding heads (Later and No date start folded), each over its tasks. */ +export function TaskSections({ d, pick, skip }: { d: TaskData; pick: PickTask; skip?: ReadonlySet }) { + const [folded, setFolded] = useState(readFolded) + const toggle = (id: TaskSectionId) => setFolded((cur) => { + const next = cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id] + try { localStorage.setItem(FOLDED_KEY, JSON.stringify(next)) } catch { /* private window */ } + return next + }) + return ( + <> + {d.sections.map((s) => { + const tasks = skip ? s.tasks.filter((t) => !skip.has(t.ref)) : s.tasks + if (!tasks.length) return null + const shut = folded.includes(s.id) + // Folded, the task picked for the chat being written still shows. + const rows = shut ? tasks.filter((t) => t.ref === d.draftTaskId) : tasks + return ( +
+ + {rows.map((t) => )} +
+ ) + })} + + ) +} + +/** A two-way switch at the top of the panel. */ +export function NavSeg({ value, options, onChange, label }: { value: T; options: Array<{ id: T; label: React.ReactNode; title?: string }>; onChange: (v: T) => void; label: string }) { + return ( +
+ {options.map((o) => ( + + ))} +
+ ) +} diff --git a/web/src/tasksnav/pick.ts b/web/src/tasksnav/pick.ts new file mode 100644 index 0000000..57ec984 --- /dev/null +++ b/web/src/tasksnav/pick.ts @@ -0,0 +1,19 @@ +// A task picked in the chats panel starts a chat for it. The chat view, while it +// shows a new chat's composer, takes the pick itself, so what he has typed goes +// with the task (useChatDrafts.startForTask, the same move `$` makes); anywhere +// else the task gets a fresh draft in its folder. +import { startTaskDraft } from '../chat/store' +import { taskHome } from '../work/state' + +let picker: ((ref: string) => void) | null = null + +/** ChatView's handler while it is on screen; returns the uninstall. */ +export function installTaskPicker(fn: (ref: string) => void): () => void { + picker = fn + return () => { if (picker === fn) picker = null } +} + +export function pickTask(ref: string) { + if (picker) picker(ref) + else startTaskDraft(ref, taskHome(ref)) +} diff --git a/web/src/tasksnav/tasksnav.css b/web/src/tasksnav/tasksnav.css new file mode 100644 index 0000000..8bd3716 --- /dev/null +++ b/web/src/tasksnav/tasksnav.css @@ -0,0 +1,101 @@ +/* The chats panel's By task order (tasksnav/, ChatsNav.tsx): chats gathered under + their task, the next tasks below. Namespaced st-* (a task's row) and + tn-* (the panel's pieces). Colours come from the shell's variables, so every + background palette applies; the panel is outside .vc, so it brings the chat's. */ +.sb-panel { + --vc-text: color-mix(in srgb, var(--text) 94%, transparent); + --vc-soft: color-mix(in srgb, var(--text) 62%, transparent); + --vc-faint: color-mix(in srgb, var(--text) 40%, transparent); + --vc-line: var(--line-2); +} + +/* --- shared bits ----------------------------------------------------------------------- */ +.st-empty { margin: 10px 4px; color: var(--vc-faint); font-size: 13px; } +.st-error { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: #f0cd72; } +.st-error .st-more { display: inline-flex; align-items: center; gap: 5px; margin: 0; } + +/* A task's row: check, title over folder, due chip, then Snooze and New chat on hover. */ +.st-task { + position: relative; display: flex; align-items: center; gap: 6px; min-height: 46px; padding: 4px 6px 4px 0; border-radius: 10px; +} +.st-task:hover, .st-task:focus-within, .st-task.menu-open { background: color-mix(in srgb, var(--text) 5%, transparent); } +.st-task.on { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); } +.st-task.compact { min-height: 40px; } +.st-check { margin-left: 4px; } +.st-task-main { + flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 2px 0; + background: none; border: 0; color: inherit; text-align: left; font: inherit; cursor: pointer; +} +.st-task-main.static { cursor: default; } +.st-task-title { display: flex; align-items: center; gap: 7px; max-width: 100%; } +.st-task-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--vc-text); } +.st-task.compact .st-task-name { font-size: 13.5px; } +.st-task-sub { display: flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; font-size: 12px; color: var(--vc-faint); } +.st-folder { display: inline-flex; align-items: center; gap: 5px; min-width: 0; } +.st-folder > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.st-folder .ti, .st-folder .vc-proj-icon { flex: none; opacity: .85; } +.st-count { flex: none; } +.st-task .wk-due { margin-right: 2px; } +.st-task-acts { display: flex; align-items: center; gap: 1px; flex: none; } +/* Pointer devices see the actions on hover; touch always sees them. */ +@media (hover: hover) { + /* Over the due chip, as the chats panel's cards do, so a resting row keeps its full width. */ + .st-task-acts { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); } + .st-task:not(:hover):not(:focus-within):not(.menu-open) .st-task-acts { opacity: 0; pointer-events: none; } + .st-task:is(:hover, :focus-within, .menu-open) > .wk-due { visibility: hidden; } + .st-task-main { padding-right: 4px; } +} +.st-task.snoozed { min-height: 40px; padding-left: 10px; } +.st-snoozed-glyph { color: var(--vc-faint); flex: none; } +.st-wake { flex: none; white-space: nowrap; } +.st-wake::before { content: '·'; margin-right: 8px; } + +.st-more { + align-self: flex-start; margin: 4px 4px 0; height: 28px; padding: 0 10px; border-radius: 8px; + background: none; border: 0; color: var(--vc-soft); font-size: 12.5px; cursor: pointer; +} +.st-more:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); } + + +/* --- in the panel -------------------------------------------------------------------- */ +.sb-panel .st-task { padding-right: 4px; border-radius: 9px; } +.sb-panel .st-task.compact { min-height: 38px; } +.sb-panel .st-task-name { font-size: 13px; } +.sb-panel .st-task-sub { font-size: 11.5px; } +.sb-panel .st-check { margin-left: 2px; } +.sb-panel .wk-due { font-size: 11.5px; } + +/* The switch at the top: Recent / By task. */ +.tn-top { padding: 2px 6px 2px; } +.tn-seg { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: color-mix(in srgb, var(--text) 5%, transparent); } +.tn-seg button { + flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 26px; border: 0; border-radius: 7px; + background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; +} +.tn-seg button:hover { color: var(--text); } +.tn-seg button.on { background: var(--raise, var(--bg-3)); color: var(--text); box-shadow: 0 1px 2px #0005; } +.tn-badge { + display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; + background: color-mix(in srgb, var(--amber) 22%, transparent); color: var(--amber); font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; +} + +/* Section heads in the task lists: the shelves' look. */ +.tn-section { display: flex; flex-direction: column; gap: 1px; margin-top: 6px; } +.tn-section.overdue .tn-section-head { color: #ff9aac; } +.tn-section.today .tn-section-head { color: #f3c969; } + +/* A task with its chats under it: the task's row, then its chats on a thread line. */ +.tn-group { display: flex; flex-direction: column; margin: 2px 0; } +.tn-group .st-task.head .st-task-name { font-weight: 600; } +.tn-group-chats { position: relative; margin-left: 13px; padding-left: 8px; border-left: 1px solid color-mix(in srgb, var(--text) 12%, transparent); } +.tn-group-chats .vc-thread-main { height: 30px; } +.tn-group-chats .vc-thread-title { font-size: 13px; } + + +/* The next tasks sit under the chats in play, ruled off above and below from the chats' shelves. */ +.tn-next { + margin: 10px 0 8px; padding: 4px 0 8px; + border-top: 1px dashed color-mix(in srgb, var(--line) 90%, transparent); + border-bottom: 1px dashed color-mix(in srgb, var(--line) 90%, transparent); +} +.tn-next:not(:has(.tn-section, .st-empty)) { display: none; } diff --git a/web/src/todos/TaskMenus.tsx b/web/src/todos/TaskMenus.tsx index d2f2321..772fcdd 100644 --- a/web/src/todos/TaskMenus.tsx +++ b/web/src/todos/TaskMenus.tsx @@ -21,8 +21,8 @@ export function SnoozeMenu({ todo, anchor, onClose, now, onSnooze, onWake }: Com const valid = at && !Number.isNaN(at.getTime()) && at > now const snoozed = Boolean(todo.snoozedUntil && new Date(todo.snoozedUntil) > now) const items: MenuEntry[] = [ - { heading: snoozed ? `Snoozed until ${wakeLabel(new Date(todo.snoozedUntil!), now)}` : 'Snooze until' }, - ...snoozeTimes(now, todo.dueDate).map((option) => ({ + { heading: snoozed ? `Snoozed until ${wakeLabel(new Date(todo.snoozedUntil!), now)}` : 'Snooze' }, + ...snoozeTimes(now).map((option) => ({ key: option.label, label: option.label, detail: option.detail, onSelect: () => onSnooze(option.value), })), ...(snoozed ? ['separator' as const, { key: 'wake', label: 'Wake now', icon: SunIcon, onSelect: onWake }] : []), diff --git a/web/src/todos/format.test.ts b/web/src/todos/format.test.ts index ef729c9..13e4a4e 100644 --- a/web/src/todos/format.test.ts +++ b/web/src/todos/format.test.ts @@ -5,8 +5,8 @@ import { addDays, dateKey, dateLabel, dueDateChoices, dueText, dueTone, isDayKey // Monday 14 September 2026, 15:06 local: the moment the card's own snooze tests use. const NOW = new Date(2026, 8, 14, 15, 6) const parts = (value: Date) => [value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes()] -const option = (now: Date, label: string, dueDate: string | null = null) => { - const found = snoozeTimes(now, dueDate).find((item) => item.label === label) +const option = (now: Date, label: string) => { + const found = snoozeTimes(now).find((item) => item.label === label) if (!found) throw new Error(`no "${label}" snooze`) return found } @@ -87,60 +87,28 @@ describe('dueText', () => { }) describe('snoozeTimes', () => { - it('offers the quick presets, the short ones exactly 20 and 60 minutes on', () => { - const now = new Date('2026-09-14T19:06:00.000Z') - const options = snoozeTimes(now) - expect(options.map((item) => item.label)).toEqual(['In 20 minutes', 'In 1 hour', 'This evening', 'Tomorrow', 'Next Monday']) - expect(options[0].value.toISOString()).toBe('2026-09-14T19:26:00.000Z') - expect(options[1].value.toISOString()).toBe('2026-09-14T20:06:00.000Z') + it('offers tomorrow, three days and a week', () => { + expect(snoozeTimes(NOW).map((item) => item.label)).toEqual(['Tomorrow', 'For 3 days', 'For a week']) }) it.each([ - ['This evening', [2026, 8, 14, 18, 0]], ['Tomorrow', [2026, 8, 15, 9, 0]], - ['Next Monday', [2026, 8, 21, 9, 0]], - ] as const)('anchors %s to its local calendar time', (label, expected) => { + ['For 3 days', [2026, 8, 17, 9, 0]], + ['For a week', [2026, 8, 21, 9, 0]], + ] as const)('anchors %s to nine in the morning, local time', (label, expected) => { expect(parts(option(NOW, label).value)).toEqual(expected) }) - it('moves This evening to tomorrow once six has passed', () => { - expect(parts(option(new Date(2026, 8, 14, 18, 30), 'This evening').value)).toEqual([2026, 8, 15, 18, 0]) - }) - - it.each([ - ['2026-10-05', 'A week before it’s due', [2026, 8, 28]], - ['2026-09-19', 'Two days before it’s due', [2026, 8, 17]], - ['2026-09-17', 'The day before it’s due', [2026, 8, 16]], - ] as const)('offers a run-up sized to the time left before %s', (dueDate, label, [year, month, day]) => { - expect(parts(option(NOW, label, dueDate).value)).toEqual([year, month, day, 9, 0]) - }) - - it('snoozes to the morning of the due date', () => { - expect(option(NOW, 'The day it’s due', '2026-09-19').value.toISOString()).toBe(new Date(2026, 8, 19, 9, 0).toISOString()) - }) - - it.each([ - ['tomorrow', '2026-09-15', ['The day it’s due']], - ['today', '2026-09-14', []], - ['in the past', '2026-09-10', []], - ] as const)('drops the run-up when the task is due %s', (_when, dueDate, extra) => { - expect(snoozeTimes(NOW, dueDate).slice(5).map((item) => item.label)).toEqual(extra) - }) - - it('offers no due-date snooze without a due date', () => { - expect(snoozeTimes(NOW, null)).toHaveLength(5) - }) - - it('steps Tomorrow and Next Monday by calendar day on the nights the clocks change', () => { + it('steps by calendar day on the nights the clocks change', () => { inNewYork() // Saturday 7 March, 23:30: the night before the 23-hour day. const spring = new Date(2026, 2, 7, 23, 30) expect(parts(option(spring, 'Tomorrow').value)).toEqual([2026, 2, 8, 9, 0]) - expect(parts(option(spring, 'Next Monday').value)).toEqual([2026, 2, 9, 9, 0]) + expect(parts(option(spring, 'For 3 days').value)).toEqual([2026, 2, 10, 9, 0]) // Sunday 1 November, 00:30: the start of the 25-hour day. const fall = new Date(2026, 10, 1, 0, 30) expect(parts(option(fall, 'Tomorrow').value)).toEqual([2026, 10, 2, 9, 0]) - expect(parts(option(fall, 'The day before it’s due', '2026-11-03').value)).toEqual([2026, 10, 2, 9, 0]) + expect(parts(option(fall, 'For a week').value)).toEqual([2026, 10, 8, 9, 0]) }) }) diff --git a/web/src/todos/format.ts b/web/src/todos/format.ts index dd8b82e..3b1743e 100644 --- a/web/src/todos/format.ts +++ b/web/src/todos/format.ts @@ -54,79 +54,38 @@ export function dateLabel(value: string) { return new Intl.DateTimeFormat(undefined, { month: 'short', day: 'numeric' }).format(new Date(year, month - 1, day)) } -export function timeLabel(value: Date) { - return new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' }).format(value) -} - function dayTimeLabel(value: Date) { return new Intl.DateTimeFormat(undefined, { weekday: 'short', hour: 'numeric', minute: '2-digit' }).format(value) } -function dueDayLabel(value: Date) { - return new Intl.DateTimeFormat(undefined, { month: 'short', day: 'numeric' }).format(value) -} - -// Nine in the morning on the due date: the last moment a snooze can end and still leave the day to work with. -function dueMorning(dueDate: string) { - const [year, month, day] = dueDate.split('-').map(Number) - return new Date(year, month - 1, day, 9, 0, 0, 0) -} +export interface SnoozeTime { label: string; detail: string; value: Date } -// A week of lead time when there is a week to spare, otherwise the largest shorter run-up that still lands in the future. -function leadDays(daysUntilDue: number) { - if (daysUntilDue >= 8) return 7 - if (daysUntilDue >= 4) return 2 - if (daysUntilDue >= 2) return 1 - return 0 +// Nine in the morning `days` calendar days from now: stepped by day key, never by 24 hours, +// so the night the clocks change still lands on the right morning. +function morningIn(now: Date, days: number) { + const at = new Date(now) + at.setDate(at.getDate() + days) + at.setHours(9, 0, 0, 0) + return at } -export interface SnoozeTime { label: string; detail: string; value: Date } - -function dueTimes(now: Date, dueDate: string | null): SnoozeTime[] { - if (!dueDate) return [] - const due = dueMorning(dueDate) - if (due <= now) return [] - const today = new Date(now) - today.setHours(9, 0, 0, 0) - // Rounded, so a 23- or 25-hour day between them still counts as one day. - const daysUntilDue = Math.round((due.getTime() - today.getTime()) / 86_400_000) - const lead = leadDays(daysUntilDue) - const options: SnoozeTime[] = [] - if (lead) { - const runUp = new Date(due) - runUp.setDate(runUp.getDate() - lead) - const label = lead === 7 ? 'A week before it’s due' : lead === 2 ? 'Two days before it’s due' : 'The day before it’s due' - options.push({ label, detail: dueDayLabel(runUp), value: runUp }) - } - options.push({ label: 'The day it’s due', detail: dueDayLabel(due), value: due }) - return options +function dayDateTimeLabel(value: Date) { + return new Intl.DateTimeFormat(undefined, { weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }).format(value) } /** - * The snooze presets: two short ones counted in minutes (an instant is right there), - * then this evening, tomorrow and next Monday stepped by calendar day, then a run-up - * to the due date when the task has one still ahead. + * The snooze presets, the three the owner reaches for: tomorrow, three days and a + * whole week, each to nine in the morning. Anything else is the menu's own time picker. */ -export function snoozeTimes(now: Date, dueDate: string | null = null): SnoozeTime[] { - const minutes = new Date(now.getTime() + 20 * 60_000) - const hour = new Date(now.getTime() + 60 * 60_000) - const evening = new Date(now) - evening.setHours(18, 0, 0, 0) - if (evening <= now) evening.setDate(evening.getDate() + 1) - const tomorrow = new Date(now) - tomorrow.setDate(tomorrow.getDate() + 1) - tomorrow.setHours(9, 0, 0, 0) - const nextMonday = new Date(now) - const daysUntilMonday = (8 - nextMonday.getDay()) % 7 || 7 - nextMonday.setDate(nextMonday.getDate() + daysUntilMonday) - nextMonday.setHours(9, 0, 0, 0) +export function snoozeTimes(now: Date): SnoozeTime[] { + const tomorrow = morningIn(now, 1) + const three = morningIn(now, 3) + const week = morningIn(now, 7) return [ - { label: 'In 20 minutes', detail: timeLabel(minutes), value: minutes }, - { label: 'In 1 hour', detail: timeLabel(hour), value: hour }, - { label: 'This evening', detail: timeLabel(evening), value: evening }, { label: 'Tomorrow', detail: dayTimeLabel(tomorrow), value: tomorrow }, - { label: 'Next Monday', detail: dayTimeLabel(nextMonday), value: nextMonday }, - ...dueTimes(now, dueDate), + { label: 'For 3 days', detail: dayTimeLabel(three), value: three }, + // A week on is the same weekday as today, so it names the date. + { label: 'For a week', detail: dayDateTimeLabel(week), value: week }, ] } diff --git a/web/src/work/state.ts b/web/src/work/state.ts index eed6121..ed76706 100644 --- a/web/src/work/state.ts +++ b/web/src/work/state.ts @@ -12,7 +12,7 @@ import { AuthError, getSheetFeed, getTodo, getTodoBoard } from '../api' import { pushError, pushToast } from '../toast' import { getState as chatState } from '../chat/store' import { announcing, onTasksChanged } from '../todos/bus' -import { wakeLabel } from '../todos/board' +import { rollsOnCompletion, wakeLabel } from '../todos/board' import type { SheetFeed, Todo, TodoPatch } from '../todos/types' import { fromSheet, fromTodo, isOpenTodo, resolveRef, type WorkTask } from './groups' @@ -224,8 +224,10 @@ export async function completeTask(ref: string) { try { const { todo } = await moveBoardTodo(ref, 'done') replaceTask({ ...local(todo), done: true }) - pushToast(`Done: ${quote(before.title)}`, 'info', { action: { label: 'Undo', onClick: () => { void reopenTask(ref) } } }) - // A repeating task rolled its next occurrence on the bridge. + // A repeating task rolled its next occurrence on the bridge, which only rolls once: + // reopening this one would leave two open copies, so it gets no Undo (board.ts afterDone). + if (before.todo && rollsOnCompletion(before.todo)) pushToast(`Done: ${quote(before.title)}. The next one is on your list.`, 'info') + else pushToast(`Done: ${quote(before.title)}`, 'info', { action: { label: 'Undo', onClick: () => { void reopenTask(ref) } } }) void loadWork() } catch (e) { replaceTask(before) diff --git a/web/vitest.config.ts b/web/vitest.config.ts index a41e2d2..6cee431 100644 --- a/web/vitest.config.ts +++ b/web/vitest.config.ts @@ -4,6 +4,6 @@ export default defineConfig({ test: { environment: 'jsdom', setupFiles: ['src/todos/test-setup.ts'], - include: ['src/{todos,goals,journal,chat,messages,totems,sources,recs,connections,cliproxy,dev,work}/**/*.test.{ts,tsx}', 'src/*.test.{ts,tsx}'], + include: ['src/{todos,goals,journal,chat,messages,totems,sources,recs,connections,cliproxy,dev,work,tasksnav}/**/*.test.{ts,tsx}', 'src/*.test.{ts,tsx}'], }, })