Skip to content

Commit cdb49d9

Browse files
Consolidated frontend: TM-161/153/151/156/148/8825/8281 (stage batch) (#175)
* feat(TM-161): add emoji reactions to task comments Adds reactions to comments in TaskComments.vue: - reaction chips per comment (emoji + count), highlighted when the current user has reacted; click to toggle - a "+" picker exposing a default emoji set (DEFAULT_REACTION_EMOJIS) - optimistic update on toggle with rollback on API failure New pure, fully-unit-tested helpers in src/utils/commentReactions.ts: - toggleReaction(reactions, emoji, user) — immutable optimistic toggle - normalizeReactions(raw, currentUserId) — defensive API normalization (derives count/reacted from users, drops malformed/zero-count entries) API layer: toggleCommentReaction(commentId, emoji, currentUserId) in src/actions/tmgr/comments.ts -> POST /comments/{id}/reactions/toggle, returns the normalized ReactionSummary[]. Test runner enablement (same as TM-8401, jest was unrunnable on master): jest.config.js -> .cjs, ts-jest lib:[ES2021] tsconfig, npm test uses default discovery. 29 tests green; npm run build green. NOTE: backend (TMBE) must persist reactions and expose the toggle endpoint + include `reactions` on the comment payload. Frontend degrades gracefully (empty bar) until the endpoint exists. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-161): ignore stale out-of-order reaction toggle responses (codex P2) Guard each comment's toggle with a per-comment sequence number so a slower earlier request can no longer overwrite the state produced by a later one. Only the latest request applies its server response (or its rollback). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(TM-153): keyboard navigation of the task list ArrowUp/ArrowDown move a visible focus between task rows and Enter opens the focused task (same as clicking it) in TasksListComponent.vue: - window keydown handler scoped so it does NOT fire while typing in inputs/textareas/selects/contenteditable/editor surfaces, nor while any task modal is open - ignores modified combos (Ctrl/Alt/Meta/Shift) so it never clashes with App.vue's Ctrl+Alt+Arrow workspace switching - focus stops sensibly at the ends (no wrap); focused row gets a visible ring; focus scrolls into view and resets when the list changes Navigation logic lives in pure, unit-tested helpers (src/utils/listKeyboardNavigation.ts): nextFocusIndex() and shouldIgnoreNavigationTarget(). 12 unit tests. Scope: main tasks LIST view (per task guidance; board left as follow-up). Test-runner enablement (jest was unrunnable on master): jest.config.js -> .cjs, ts-jest lib:[ES2021] tsconfig, npm test uses default discovery. npm test green (32 tests); npm run build green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-153): don't hijack Enter from focused interactive controls (codex P2) When a row is focused via the arrow keys, the window-level Enter handler previously opened the focused task even if real browser focus was on a button/link/pagination control, breaking keyboard activation of those controls. Enter now bails when the event target is interactive (isInteractiveTarget), letting the browser activate the control. Adds isInteractiveTarget() + 5 unit tests (37 total). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(TM-151): hint to configure category when GitHub repo / Cursor agent unset When a task's category has no GitHub repository linked or no Cursor agent configured, clicking the Git activity / Cursor agent buttons now shows an explanatory dialog with a CTA that navigates to the category settings, instead of opening a feature that cannot work. When the integration IS configured (or its status is still unknown), behaviour is unchanged. - src/utils/categoryIntegrationHint.ts: pure, unit-tested show-logic (getCategoryIntegrationHint / isCategoryIntegrationConfigured) - NewForm.vue: loads category GitHub + Cursor status after task load, openCursorAgent()/openGitActivity() gate the modals, goToCategorySettings() routes to WorkspaceCategoryEdit; hint Dialog added - 6 unit tests for the show-logic Does NOT modify jest.config/package.json (unmerged stack #165/166/167); tests verified via an out-of-tree jest config. npm run build green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-151): track integration loaded-state per integration (codex P2) Previously a single categoryIntegrationLoaded flag was set when either status request fulfilled, so a failed getCursorStatus (or GitHub status) forced its boolean to false and wrongly showed the hint / blocked the modal for an integration whose status was actually unknown. Now GitHub and Cursor each have their own loaded flag, set only when that specific request fulfils; a hint shows only when that integration's status is known AND unconfigured. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(TM-148): remove requestDeduplicator, fold single-flight into requestCache The standalone requestDeduplicator masked the real cause of duplicate GETs: requestCache only stored *resolved* values, so the cache entry was populated only after a response returned. Concurrent callers during that in-flight window all missed the cache and each fired their own request — the deduplicator was a second, parallel Map patching that gap. Root-cause fix: make requestCache itself promise-aware (single-flight). New requestCache.getOrFetch(key, fn, { ttl, cache }) registers the in-flight Promise synchronously before the first await, so concurrent identical requests coalesce onto one Promise — there is no miss window left for the deduplicator to cover. On success it stores the result under ttl; on rejection it drops the in-flight entry so retries refetch and errors are never cached. `cache: false` coalesces without persisting. - Add getOrFetch + clearInFlight to requestCache; clear() now also drops in-flight. - Migrate all call sites: notifications.getUnreadCount, tasks.getSortedTasksByStatus, pomodoro.getPomodoroState. - store/index.js: requestDeduplicator.clear() -> requestCache.clearInFlight() (logout relies on requestCache.clear() which now clears both). - Delete src/utils/requestDeduplicator.ts and update the CLAUDE.md data-flow doc. - Add TDD coverage for coalescing, ttl expiry, null caching, cache:false, error-not-cached, clearInFlight, and clear. Note: getPomodoroState previously had a dead `cached !== undefined` early-return (requestCache.get never returns undefined) that could short-circuit to null without fetching; routing it through getOrFetch (has()-based presence) restores correct fetch-on-miss while still caching null results. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-148): prevent poison in-flight entry on synchronous fetchFn throw Codex review [P2]: if fetchFn threw synchronously, the async IIFE's `finally { inFlight.delete(key) }` ran during the synchronous phase — before `inFlight.set(key, request)` — so the rejected promise was then stored and never cleaned up. Every subsequent call for that key returned the stale rejected promise and retries never refetched. Fix: invoke fetchFn eagerly inside try/catch, converting a synchronous throw into Promise.reject, then build the set/cleanup chain on top. The `.finally(delete)` now always runs in a later microtask, after the synchronous `inFlight.set`, so the entry is reliably cleared on both resolve and reject. fetchFn is still invoked synchronously, preserving same-tick coalescing. Adds a regression test: fetchFn throwing synchronously must clear the in-flight entry and allow the next call to refetch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(TM-156): active cursor agents indicator with jump-to-task Adds a header indicator (next to the notification bell, in CustomSidebar) that lists currently-active cursor/cloud agents (status CREATING/RUNNING) and navigates to the agent's task on click. - actions/tmgr/cursor.ts: getActiveCursorAgents() against the expected global endpoint GET /cursor-agents/active (tolerant of array | {agents} | {data} shapes, mirroring getCursorAgents). - utils/cursorAgents.ts: pure, unit-tested helpers — isActiveCursorAgent, filterActiveCursorAgents, cursorAgentLabel, cursorAgentTaskRoute (builds the WorkspaceTask route /:workspace_code/tasks/:task_id). - components/cursor/ActiveCursorAgents.vue: shadcn DropdownMenu indicator with count badge, RUNNING/CREATING status dots, empty/loading states, 20s polling + reload on open, dark-mode variants. Network errors are swallowed to an empty list so the UI degrades gracefully until the backend endpoint ships. - CustomSidebar.vue: mount the indicator beside NotificationBell. TDD: src/utils/__tests__/cursorAgents.test.ts (8 tests). BACKEND DEPENDENCY (FE built on the expected contract, not blocking): there is no global "active agents" endpoint yet — only per-task GET /tasks/{id}/cursor-agent. Needs GET /cursor-agents/active returning the current user's CREATING/RUNNING agents. Reported to PM for a Java ticket. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-156): route jump-to-task via the agent's own workspace Codex review [P2]: with a global active-agents list, clicking an agent whose task lives in another workspace navigated to /:current_workspace/tasks/:task_id, landing on the wrong workspace (or failing to load the task) in multi-workspace use. Fix: cursorAgentTaskRoute now prefers the agent's own workspace_code and only falls back to the current workspace when the agent doesn't carry one. Add optional workspace_code to the CursorAgent type (populated by the new GET /cursor-agents/active endpoint). +2 regression tests (cross-workspace jump; null/empty fallback). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-156): never guess workspace for a global agent jump (codex P2) Codex round 2: falling back to the current workspace when an agent has no workspace_code still misroutes cross-workspace agents (the task opens under the wrong workspace context). For a global list the FE must not assume the current workspace. - cursorAgentTaskRoute now returns null unless the agent carries its own workspace_code (no current-workspace guessing); add canJumpToCursorAgentTask. - ActiveCursorAgents.vue: agents without a known workspace are shown but rendered non-jumpable (DropdownMenuItem :disabled, jump arrow hidden); drop the now-unused current-workspace resolution. - Tests updated: route built only from the agent's own workspace_code, null otherwise; canJumpToCursorAgentTask coverage. This makes workspace_code a REQUIRED field of the GET /cursor-agents/active contract (reported to PM), not nice-to-have. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(TM-156): make workspace_code a required field of the active-agents contract (codex P2) Codex: with the no-guessing route, if the global endpoint returns only the minimum fields (no workspace_code) every item becomes non-jumpable, defeating the advertised jump-to-task. Resolve per codex's first suggested option — make workspace_code part of the REQUIRED backend contract: - types/cursor.ts: add ActiveCursorAgent (CursorAgent + required workspace_code), documenting the GET /cursor-agents/active contract. - actions/tmgr/cursor.ts: getActiveCursorAgents() now returns ActiveCursorAgent[] with a contract comment. canJumpToCursorAgentTask / cursorAgentTaskRoute stay as runtime defense-in-depth against a contract violation, but under the (now required) contract every agent carries its workspace and the jump always works. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-153): suppress list nav while modalStack modals are open (codex P2) isAnyModalOpen only checked currentTaskIdForModal/showCreatingTaskModal/openModals, so a modal that registers solely in state.modalStack (e.g. TasksMultipleActionsModal) left the window keydown handler active — ArrowUp/Down/Enter could move focus or open a task behind the modal. Include modalStack.length in the guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-161): per-(comment,emoji) reaction toggles; never clobber concurrent emojis (codex P2) The seq-guard from 9e8097d was keyed only by comment id, so two quick toggles of DIFFERENT emojis on the same comment raced: the later response applied and the earlier successful one was discarded (server had both, UI showed one until reload). Fix: - Key the in-flight sequence guard per (comment, emoji), so toggles of distinct emojis no longer invalidate one another. - Replace the wholesale `comment.reactions = server` with mergeServerReactionForEmoji(current, source, emoji): apply only the toggled emoji's authoritative state (from the server on success, the pre-toggle snapshot on error) onto the current list, leaving other emojis untouched. Adds regression tests for the race (mergeServerReactionForEmoji): a slow emoji response must not clobber a concurrently-toggled different emoji; targeted removal/update; immutability. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-153): track focused task by id so in-place list updates keep focus (codex P2) focusedIndex is a raw index, but the parent mutates the tasks array in place (unshift/splice on live updates), so after an insert/removal above the focused row the ring + Enter targeted the wrong task. Track focusedTaskId and reconcile the index whenever the task id-sequence changes (focusOrderKey watcher); clear focus when the task leaves the list. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-153): scope list keyboard nav to the focused list (codex P2) The window keydown handler previously fired regardless of where focus was, so ArrowUp/Down anywhere on the page (body, header, content above the list) moved the task highlight and swallowed normal key behavior. Make the list root focusable (tabindex) and only handle keys when focus is within the list (root.contains(event.target)), so the shortcut no longer leaks outside it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-161): serialize same-emoji reaction toggles per (comment,emoji) (codex P2) Codex round 2: the per-(comment,emoji) sequence guard fixed cross-emoji clobbering but left a same-emoji ordering hole — the reaction endpoint is a STATEFUL toggle, so its final state depends on the order requests are processed server-side, not the order responses arrive. Rapidly toggling the same emoji could leave the UI showing the opposite state until reload. Fix: serialize in-flight toggles per (comment,emoji) via a new tested keyedSerializer util, so same-emoji requests reach the server in click order and the last settled response is authoritative; different emojis stay independent and still merge per-emoji (no cross-emoji clobber). - src/utils/keyedSerializer.ts: createKeyedSerializer() — per-key async serialization; rejects don't break the chain; no unhandledRejection for fire-and-forget callers. - src/utils/__tests__/keyedSerializer.test.ts: ordering, cross-key overlap, reject-continues. - TaskComments.vue: drop the per-comment seq guard; optimistic flip per click, then serializeReaction(`${comment.id}:${emoji}`, …) running the merge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-161): single in-flight reaction toggle per (comment,emoji); drop queue (codex P2) Codex round 3: serializing toggles fixed successful ordering but a FAILED earlier same-emoji request left queued toggles flipping a server state that never changed (add-then-remove with the add failing => server ends with the reaction though the user's last click removed it). Driving a stateful toggle endpoint with a client queue is inherently unsafe. Fix: allow only ONE in-flight toggle per (comment,emoji). A second rapid click on the same emoji is ignored until the first settles, so every request acts on settled, known server state — no queue to diverge on failure. Different emojis stay independent (different keys) and still merge per-emoji, so they never block or clobber each other. - TaskComments.vue: reactionInFlight Set guard; remove the serializer/queue. - Remove now-unused keyedSerializer util + tests. - Keep mergeServerReactionForEmoji (+ the cross-emoji race regression test). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-153): roving-tabindex so Enter targets the highlighted row (codex P2) Remaining codex P2 (Enter vs DOM-focus desync): arrows only moved the visual focusedIndex, so when DOM focus sat on a card/button elsewhere, Enter activated that control instead of opening the highlighted row. Design call — roving tabindex: rows get tabindex="-1" and arrow-nav moves real DOM focus onto the highlighted row (in scrollFocusedIntoView, focus({preventScroll})). Now DOM focus == visual focus, so Enter on the row opens that row; if the user Tabs to an in-row control, focus is on the control and Enter activates it (isInteractiveTarget already handles that). Precedence: an explicitly focused in-row control wins; otherwise Enter opens the highlighted row. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-161): accept raw-array reaction responses (Java shape) (codex P2) Codex: toggleCommentReaction destructured `{ data: { data } }`, so when the endpoint returns a raw array (the Java-style shape other endpoints already handle) `data` was undefined and normalizeReactions returned [], making the reaction vanish right after a successful toggle. Fix: add a tested extractReactionsPayload(body) that accepts a raw array or a { data } / { reactions } wrapper, and route the toggle response through it before normalizing. +5 regression tests for the response shapes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-153): use explicit listRoot ref instead of $el (codex P1) TasksListComponent is multi-root (<div> + <Confirm>), so Vue 3 exposes $el as a fragment placeholder, not the list element. That made root.contains(target) never match and $el.querySelector() find no rows — so ArrowUp/Down/Enter navigation (and the roving-tabindex focus) silently did nothing. Fix: bind ref="listRoot" on the list container and use this.$refs.listRoot for both containment (handleListKeydown) and row lookup/focus (scrollFocusedIntoView). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-153): start list nav at page level without pre-focusing (codex P2) Codex: the containment guard (focus must be inside listRoot) meant ArrowUp/Down/ Enter did nothing until the user clicked or tabbed into the list — so on initial load, after a modal closes, or with focus in surrounding layout, the advertised page-level task-list navigation never started. Fix: also handle the keys when there is no meaningful focus (event.target is <body>/<html>), in addition to focus inside the list. Focus parked inside some other element is still left alone, and inputs/editors remain excluded via shouldIgnoreNavigationTarget. TasksListComponent renders once per page (list view and category view both bind a single instance), so there is no multi-list conflict from page-level handling. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-148): align task-status cache key with the invalidation pattern (tmgr #8827) getSortedTasksByStatus cached under requestCache.generateKey(`tasks/status/${id}`) (slash), but every mutating task action invalidates with /^tasks-status-/ (hyphen). The pattern could never match the key, so board results cached via getBatchTasksByStatuses (useCache=true, 30s TTL) stayed stale for up to ~30s after create/update/delete/reorder. Fix: generate the cache key in the `tasks-status-` namespace the 8 invalidation sites already use (the HTTP URL stays `tasks/status/...`). +3 regression tests covering the alignment, the legacy-key non-match, and the namespace. Follow-up from the TM-148 review (PR #169). jest.config left untouched (unmerged stack) — tests run via inline --config. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-151): reload integration status when the category changes (codex P2) The hint used categoryHasRepository/categoryCursorConfigured cached for the category loaded at open time; changing form.project_category_id via either category combobox did not refresh it, so after moving a task between a configured and unconfigured category the hint could be wrong. Watch form.project_category_id and reload the integration state on change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-151): ignore stale integration-status responses on category change (codex P2) If the category changes while a loadCategoryIntegrationState() request is in flight, the older response could resolve later and overwrite the state for the wrong category. Capture the requested categoryId and bail after the await when form.project_category_id no longer matches. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(TM-8825): lock frontend jest test runner; drop dead Vue scaffold spec Tech-debt follow-up to TM-8401 (PR #165). Master's test runner was broken: jest.config.js used module.exports under "type":"module" (fails to load), and `npm test` pointed at a nonexistent ./tests path. - Rename jest.config.js -> jest.config.cjs so the CommonJS config loads cleanly under the package's ESM type; pin ts-jest target/lib (ES2021). - testMatch limited to TS specs (**/__tests__/**/*.test.ts, *.spec|test.ts). - Remove src/components/Index/Index.spec.js: a vue-cli scaffold stub with only commented-out, zero-assertion cases. Consciously deleted rather than wiring vue-jest/babel to run a no-op (per TM-8825 scope). - Fix package.json test script: `jest --verbose ./tests` -> `jest --verbose`. Validation: npx jest --verbose -> 20/20 passing (dashboard-types.test.ts). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(TM-8281): hours+minutes overtime in lists + status-column tooltip Finish the task-overtime display: - Extract a reusable formatOvertime(seconds) util ('1h 23m' / '23m' / '1h', null when <=0 or sub-minute) so sub-hour overtime stays visible instead of rounding to '0.0h'. Reuse it in getTaskOvertime (DRY, identical output). - selectedSummary now shows '+1h 23m overtime' instead of hours-only '+X.Xh'. - Add a hover tooltip (title) on the per-row time in the status column showing that row's overtime (e.g. '+1h 23m overtime'). Unit tests for the formatter (sub-minute/sub-hour/whole-hour/combined). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8c5f54c commit cdb49d9

29 files changed

Lines changed: 2757 additions & 858 deletions

‎CLAUDE.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ The codebase splits languages by role — keep this convention when adding files
2828
### Data flow: API → Cache → Vuex → Components
2929
The performance layer in `src/utils/` is load-bearing — actions in `src/actions/tmgr/*` are expected to use it:
3030

31-
1. **`requestCache`** (`src/utils/requestCache.ts`) — TTL-keyed in-memory cache. Reference data (workspaces, statuses, categories, members) is cached for 5 min; per-task data for ~1 min. **Mutating actions must call `requestCache.invalidate(key | regex)`** or stale data will render. `store.dispatch('logout')` clears the cache.
32-
2. **`requestDeduplicator`** (`src/utils/requestDeduplicator.ts`) — collapses concurrent identical GETs into a single in-flight Promise. Wrap network calls in `requestDeduplicator.deduplicate(key, fn)` after the cache miss.
33-
3. **`$axios`** (`src/plugins/axios.ts`) — single instance with 30s timeout, bearer token from `store.state.token`, auto-retry (×2, exponential) on 5xx, and auto-`logout` dispatch on 401.
31+
1. **`requestCache`** (`src/utils/requestCache.ts`) — TTL-keyed, single-flight in-memory cache. Reference data (workspaces, statuses, categories, members) is cached for 5 min; per-task data for ~1 min. **Mutating actions must call `requestCache.invalidate(key | regex)`** or stale data will render. `store.dispatch('logout')` clears the cache. Wrap GETs in `requestCache.getOrFetch(key, fn, { ttl, cache })`: it serves a fresh cached value, otherwise coalesces concurrent identical requests onto a single in-flight Promise (registered synchronously, so there is no miss window for duplicates), then stores the result under `ttl`. Pass `cache: false` to coalesce without persisting.
32+
2. **`$axios`** (`src/plugins/axios.ts`) — single instance with 30s timeout, bearer token from `store.state.token`, auto-retry (×2, exponential) on 5xx, and auto-`logout` dispatch on 401.
3433

3534
### Vuex (root store + modules)
3635
`src/store/index.js` holds auth/session/UI flags; modules live in `src/store/modules/` (`pusher`, `boardFilters`, `featureToggles`). Reference collections are kept **normalized**: `workspaces` + `workspacesById`, `workspaceStatuses` + `workspaceStatusesById`. Prefer the `*ById` lookups and the `currentWorkspace` / `userSettingByKey` getters over scanning arrays.

‎jest.config.cjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
// CommonJS config (.cjs) because package.json sets "type": "module";
3+
// a plain jest.config.js with module.exports fails to load under ESM.
24
module.exports = {
35
preset: 'ts-jest',
46
testEnvironment: 'node',
7+
// TS-only test runner. Vue SFC component tests are intentionally not run
8+
// here (see TM-8825): the only such test was a no-op vue-cli scaffold stub
9+
// and was removed rather than wiring up vue-jest/babel for zero assertions.
510
testMatch: ['**/__tests__/**/*.test.ts', '**/?(*.)+(spec|test).ts'],
611
transform: {
712
'^.+\\.tsx?$': [

‎src/actions/tmgr/comments.ts‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import $axios from '@/plugins/axios';
22
import { requestCache } from '@/utils/requestCache';
3+
import type { ReactionSummary } from '@/utils/commentReactions';
4+
import {
5+
normalizeReactions,
6+
extractReactionsPayload,
7+
} from '@/utils/commentReactions';
38

49
export interface Comment {
510
message: string;
611
}
712

8-
export const getComments = async (taskId: number, useCache: boolean = false): Promise<Comment[]> => {
13+
export const getComments = async (
14+
taskId: number,
15+
useCache: boolean = false,
16+
): Promise<Comment[]> => {
917
const cacheKey = `comments-task-${taskId}`;
10-
18+
1119
if (useCache) {
1220
const cached = requestCache.get<Comment[]>(cacheKey);
1321
if (cached) {
@@ -60,3 +68,19 @@ export const deleteComment = async (commentId: number) => {
6068
data: { data },
6169
} = await $axios.delete(`/comments/${commentId}`);
6270
};
71+
72+
export const toggleCommentReaction = async (
73+
commentId: number,
74+
emoji: string,
75+
currentUserId?: number,
76+
): Promise<ReactionSummary[]> => {
77+
const response = await $axios.post(
78+
`/comments/${commentId}/reactions/toggle`,
79+
{ emoji },
80+
);
81+
82+
return normalizeReactions(
83+
extractReactionsPayload(response.data),
84+
currentUserId,
85+
);
86+
};

‎src/actions/tmgr/cursor.ts‎

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,92 @@
11
import $axios from '@/plugins/axios';
2-
import type { CursorAgent, CursorStatus, GitHubBranch } from '@/types/cursor';
2+
import type {
3+
ActiveCursorAgent,
4+
CursorAgent,
5+
CursorStatus,
6+
GitHubBranch,
7+
} from '@/types/cursor';
38

4-
export async function launchCursorAgent(taskId: number, sourceBranch?: string): Promise<CursorAgent> {
5-
const response = await $axios.post(`/tasks/${taskId}/cursor-agent`, {
6-
source_branch: sourceBranch,
7-
});
8-
return response.data.agent;
9+
export async function launchCursorAgent(
10+
taskId: number,
11+
sourceBranch?: string,
12+
): Promise<CursorAgent> {
13+
const response = await $axios.post(`/tasks/${taskId}/cursor-agent`, {
14+
source_branch: sourceBranch,
15+
});
16+
return response.data.agent;
917
}
1018

11-
export async function getGitHubBranches(taskId: number, search?: string): Promise<GitHubBranch[]> {
12-
const params = search ? { search } : {};
13-
const response = await $axios.get(`/tasks/${taskId}/cursor-agent/branches`, { params });
14-
return response.data.branches;
19+
export async function getGitHubBranches(
20+
taskId: number,
21+
search?: string,
22+
): Promise<GitHubBranch[]> {
23+
const params = search ? { search } : {};
24+
const response = await $axios.get(`/tasks/${taskId}/cursor-agent/branches`, {
25+
params,
26+
});
27+
return response.data.branches;
1528
}
1629

1730
export async function getCursorAgents(taskId: number): Promise<CursorAgent[]> {
18-
const response = await $axios.get(`/tasks/${taskId}/cursor-agent`);
19-
const body = response.data;
20-
if (Array.isArray(body)) return body as CursorAgent[];
21-
return (body?.agents ?? body?.data ?? []) as CursorAgent[];
31+
const response = await $axios.get(`/tasks/${taskId}/cursor-agent`);
32+
const body = response.data;
33+
if (Array.isArray(body)) return body as CursorAgent[];
34+
return (body?.agents ?? body?.data ?? []) as CursorAgent[];
2235
}
2336

24-
export async function stopCursorAgent(taskId: number, agentId: number): Promise<void> {
25-
await $axios.post(`/tasks/${taskId}/cursor-agent/${agentId}/stop`);
37+
// Global list of the user's currently-running cursor agents.
38+
// Contract: each item MUST carry workspace_code (see ActiveCursorAgent) so the
39+
// indicator can jump to the agent's task in its own workspace.
40+
export async function getActiveCursorAgents(): Promise<ActiveCursorAgent[]> {
41+
const response = await $axios.get('/cursor-agents/active');
42+
const body = response.data;
43+
if (Array.isArray(body)) return body as ActiveCursorAgent[];
44+
return (body?.agents ?? body?.data ?? []) as ActiveCursorAgent[];
45+
}
46+
47+
export async function stopCursorAgent(
48+
taskId: number,
49+
agentId: number,
50+
): Promise<void> {
51+
await $axios.post(`/tasks/${taskId}/cursor-agent/${agentId}/stop`);
2652
}
2753

2854
export async function sendFollowUp(
29-
taskId: number,
30-
agentId: number,
31-
prompt: string
55+
taskId: number,
56+
agentId: number,
57+
prompt: string,
3258
): Promise<void> {
33-
await $axios.post(`/tasks/${taskId}/cursor-agent/${agentId}/followup`, {
34-
prompt,
35-
});
59+
await $axios.post(`/tasks/${taskId}/cursor-agent/${agentId}/followup`, {
60+
prompt,
61+
});
3662
}
3763

38-
export async function getCursorConversation(taskId: number, agentId: number): Promise<any> {
39-
const response = await $axios.get(`/tasks/${taskId}/cursor-agent/${agentId}/conversation`);
40-
return response.data;
64+
export async function getCursorConversation(
65+
taskId: number,
66+
agentId: number,
67+
): Promise<any> {
68+
const response = await $axios.get(
69+
`/tasks/${taskId}/cursor-agent/${agentId}/conversation`,
70+
);
71+
return response.data;
4172
}
4273

43-
export async function updateCursorApiKey(categoryId: number, apiKey: string): Promise<void> {
44-
await $axios.put(`/categories/${categoryId}/cursor-api-key`, {
45-
cursor_api_key: apiKey,
46-
});
74+
export async function updateCursorApiKey(
75+
categoryId: number,
76+
apiKey: string,
77+
): Promise<void> {
78+
await $axios.put(`/categories/${categoryId}/cursor-api-key`, {
79+
cursor_api_key: apiKey,
80+
});
4781
}
4882

4983
export async function deleteCursorApiKey(categoryId: number): Promise<void> {
50-
await $axios.delete(`/categories/${categoryId}/cursor-api-key`);
84+
await $axios.delete(`/categories/${categoryId}/cursor-api-key`);
5185
}
5286

53-
export async function getCursorStatus(categoryId: number): Promise<CursorStatus> {
54-
const response = await $axios.get(`/categories/${categoryId}/cursor-status`);
55-
return response.data;
87+
export async function getCursorStatus(
88+
categoryId: number,
89+
): Promise<CursorStatus> {
90+
const response = await $axios.get(`/categories/${categoryId}/cursor-status`);
91+
return response.data;
5692
}

‎src/actions/tmgr/notifications.ts‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import $axios from '@/plugins/axios';
22
import { requestCache } from '@/utils/requestCache';
3-
import { requestDeduplicator } from '@/utils/requestDeduplicator';
43

54
export interface Notification {
65
id: number;
@@ -60,7 +59,7 @@ export interface UpdateNotificationSettingsPayload {
6059

6160
export const getNotifications = async (
6261
page: number = 1,
63-
perPage: number = 20
62+
perPage: number = 20,
6463
): Promise<NotificationPaginatedResponse> => {
6564
const response = await $axios.get('/notifications', {
6665
params: { page, per_page: perPage },
@@ -70,20 +69,15 @@ export const getNotifications = async (
7069

7170
export const getUnreadCount = async (): Promise<number> => {
7271
const cacheKey = 'notifications-unread-count';
73-
74-
return requestDeduplicator.deduplicate(cacheKey, async () => {
75-
const cached = requestCache.get<number>(cacheKey);
76-
if (cached !== null) {
77-
return cached;
78-
}
7972

80-
const response = await $axios.get('/notifications/unread-count');
81-
const count = response.data.count;
82-
83-
requestCache.set(cacheKey, count, 10000);
84-
85-
return count;
86-
});
73+
return requestCache.getOrFetch(
74+
cacheKey,
75+
async () => {
76+
const response = await $axios.get('/notifications/unread-count');
77+
return response.data.count as number;
78+
},
79+
{ ttl: 10000 },
80+
);
8781
};
8882

8983
export const markAsRead = async (id: number): Promise<Notification> => {
@@ -102,13 +96,14 @@ export const deleteNotification = async (id: number): Promise<void> => {
10296
await $axios.delete(`/notifications/${id}`);
10397
};
10498

105-
export const getNotificationSettings = async (): Promise<NotificationSettingsResponse> => {
106-
const response = await $axios.get('/notification-settings');
107-
return response.data;
108-
};
99+
export const getNotificationSettings =
100+
async (): Promise<NotificationSettingsResponse> => {
101+
const response = await $axios.get('/notification-settings');
102+
return response.data;
103+
};
109104

110105
export const updateNotificationSettings = async (
111-
payload: UpdateNotificationSettingsPayload
106+
payload: UpdateNotificationSettingsPayload,
112107
): Promise<NotificationSettings> => {
113108
const response = await $axios.put('/notification-settings', payload);
114109
return response.data.settings;

‎src/actions/tmgr/pomodoro.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import $axios from '@/plugins/axios';
22
import store from '@/store';
33
import { requestCache } from '@/utils/requestCache';
4-
import { requestDeduplicator } from '@/utils/requestDeduplicator';
54
import { patchUserSettings } from '@/actions/tmgr/user';
65

76
export type PomodoroPhase = 'focus' | 'short' | 'long';
@@ -49,16 +48,17 @@ export const getPomodoroState = async (
4948
taskId: number,
5049
): Promise<PomodoroState | null> => {
5150
const key = stateKey(taskId);
52-
const cached = requestCache.get<PomodoroState | null>(key);
53-
if (cached !== undefined) return cached;
5451

55-
return requestDeduplicator.deduplicate(key, async () => {
56-
const {
57-
data: { data },
58-
} = await $axios.get(`tasks/${taskId}/pomodoro`);
59-
requestCache.set(key, data ?? null, 30_000);
60-
return data ?? null;
61-
});
52+
return requestCache.getOrFetch(
53+
key,
54+
async () => {
55+
const {
56+
data: { data },
57+
} = await $axios.get(`tasks/${taskId}/pomodoro`);
58+
return (data ?? null) as PomodoroState | null;
59+
},
60+
{ ttl: 30_000 },
61+
);
6262
};
6363

6464
export const enablePomodoro = async (

0 commit comments

Comments
 (0)