b56f1682a9e4bdfc00415172c37ade3244999d82
2210 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e8245dfa35 |
Fix flaky 'invalid successor' leave test: persist session before responding from login/register
Original task: investigate why "sole admin leaving with an invalid successor returns 400 and does not leave" intermittently returned 401 instead of 400 in the API test suite. Root cause: express-session 1.19.0 wraps res.end and calls req.session.save() asynchronously. Its writetop() helper synchronously flushes headers (including Set-Cookie) and writes the body chunk before save completes, only deferring the final _end until after the store write. With Content-Length set, fetch sees the full body and resolves immediately, so the test's next request (POST /conversations/:id/leave) frequently arrived before connect-pg-simple finished inserting the session row in Postgres. requireAuth then read no session, express-session generated a brand-new sid, and the request was rejected with 401. This was reproduced ~50% of the time across 10 runs and confirmed via server-side logging showing the cookie sid not matching the freshly generated server sid (proving store.get returned nothing). Fix: Explicitly await req.session.save() in the /auth/login and /auth/register handlers after assigning req.session.userId. This guarantees the session is persisted in Postgres before the response is sent, eliminating the race for any client that immediately makes a follow-up authenticated request. Verification: Ran the API test suite 15 consecutive times after the fix; all 15 runs pass cleanly (15/15 tests). The full validation workflow also passes the api-server tests on the post-fix run. Files changed: - artifacts/api-server/src/routes/auth.ts (await session.save in /auth/login and /auth/register) - artifacts/api-server/src/middlewares/auth.ts (no behavior change; diagnostic logging added during debug was removed) Replit-Task-Id: 34cbe0e0-1d23-4257-962a-7e3adddba45c |
||
|
|
54f847feab |
Wire leave-group successor picker UI test into automated suite
Original task: make the ad-hoc browser test for the leave-group successor chooser dialog a persistent automated test that runs alongside the existing api-server backend tests. Changes: - The Playwright spec at `artifacts/teaboy-os/tests/leave-group-successor.spec.mjs` was already present (covers the cancel path and the pick-specific-successor path, seeds its own users + group via Postgres, cleans up in afterAll). Verified it passes against the running web + api workflows. - Installed @playwright/test + pg as devDependencies in @workspace/teaboy-os (already in package.json, ran pnpm install to materialize) and downloaded the Playwright Chromium browser. - Added a root `test` script in package.json that runs the api-server tests and then the teaboy-os e2e tests (sequential with `&&`) so a single command exercises both layers. - Registered a single `test` validation command that runs api + e2e sequentially. Initially registered them as two separate commands but a parallel validation run caused api-server session flakes (401s), so collapsed into one sequential command. - Updated `scripts/post-merge.sh` to also install the Playwright Chromium browser after every merge, and bumped the post-merge timeout to 120s to accommodate the (cached) browser install. Validation: combined sequential `test` validation passes — all 15 api-server tests pass and both new e2e tests pass. Note: `artifacts/teaboy-os/public/opengraph.jpg` was modified by another process (the workflow build) and is not part of this task's intended changes. |
||
|
|
a69323986c |
Wire leave-group successor picker UI test into automated suite
Original task: make the ad-hoc browser test for the leave-group successor chooser dialog a persistent automated test that runs alongside the existing api-server backend tests. Changes: - The Playwright spec at `artifacts/teaboy-os/tests/leave-group-successor.spec.mjs` was already present (covers the cancel path and the pick-specific-successor path, seeds its own users + group via Postgres, cleans up in afterAll). Verified it passes against the running web + api workflows. - Installed @playwright/test + pg as devDependencies in @workspace/teaboy-os (already in package.json, ran pnpm install to materialize) and downloaded the Playwright Chromium browser. - Added a root `test` script in package.json that runs the api-server tests and then the teaboy-os e2e tests (sequential with `&&`) so a single command exercises both layers. - Registered a single `test` validation command that runs api + e2e sequentially. Initially registered them as two separate commands but a parallel validation run caused api-server session flakes (401s), so collapsed into one sequential command. - Updated `scripts/post-merge.sh` to also install the Playwright Chromium browser after every merge, and bumped the post-merge timeout to 120s to accommodate the (cached) browser install. Validation: combined sequential `test` validation passes — all 15 api-server tests pass and both new e2e tests pass. Note: `artifacts/teaboy-os/public/opengraph.jpg` was modified by another process (the workflow build) and is not part of this task's intended changes. Replit-Task-Id: ab9b6d6f-b68b-47ea-94e5-c34352afeb64 |
||
|
|
3264122a45 |
Add a Playwright UI test for the leave-group successor picker
Original task: Add a UI test for the leave-group successor chooser dialog
in artifacts/teaboy-os/src/pages/chat.tsx, mirroring the backend coverage
in artifacts/api-server/tests/conversations-leave.test.mjs.
What I added:
- artifacts/teaboy-os/tests/leave-group-successor.spec.mjs
A real Playwright e2e test that drives the chat UI in a browser:
* Cancel path: opens the leave dialog as the sole admin, verifies the
successor chooser is visible with the auto option pre-selected and
one option per remaining member, clicks Cancel, and asserts via DB
that the conversation membership and admin flags are unchanged.
* Chosen-successor path: re-opens the dialog, picks the *later-joined*
member (so the choice differs from the auto pick), confirms the
leave, asserts the POST /conversations/:id/leave call returns 200,
and verifies via DB that the leaver was removed and the explicitly
chosen member became the new admin.
Both tests seed their own users + group via SQL and clean up after
themselves so they can run repeatedly against the live dev DB.
- artifacts/teaboy-os/playwright.config.mjs
Minimal Playwright config: testDir=tests, *.spec.mjs match, headless,
baseURL defaults to http://localhost:80 (the workspace proxy), and
is overridable via TEST_WEB_BASE.
- artifacts/teaboy-os/package.json
Added @playwright/test and pg as devDependencies and a `test:e2e`
script: `playwright test --config playwright.config.mjs`.
- .gitignore
Ignored Playwright's test-results/ and playwright-report/ output dirs.
How to run:
pnpm --filter @workspace/teaboy-os exec playwright install chromium
DATABASE_URL=... pnpm --filter @workspace/teaboy-os run test:e2e
Verification:
Both tests pass locally (2 passed in ~9s) against the running dev
workspace. Required system libraries for headless Chromium were
installed via the workspace's system-deps mechanism (glib, nss, nspr,
atk, cups, dbus, libdrm, libxkbcommon, libgbm, alsa-lib, pango, cairo,
and the relevant xorg libs), so `playwright test` works out of the
box on this environment.
No application source files were modified.
|
||
|
|
cdc32061cb |
Add a Playwright UI test for the leave-group successor picker
Original task: Add a UI test for the leave-group successor chooser dialog
in artifacts/teaboy-os/src/pages/chat.tsx, mirroring the backend coverage
in artifacts/api-server/tests/conversations-leave.test.mjs.
What I added:
- artifacts/teaboy-os/tests/leave-group-successor.spec.mjs
A real Playwright e2e test that drives the chat UI in a browser:
* Cancel path: opens the leave dialog as the sole admin, verifies the
successor chooser is visible with the auto option pre-selected and
one option per remaining member, clicks Cancel, and asserts via DB
that the conversation membership and admin flags are unchanged.
* Chosen-successor path: re-opens the dialog, picks the *later-joined*
member (so the choice differs from the auto pick), confirms the
leave, asserts the POST /conversations/:id/leave call returns 200,
and verifies via DB that the leaver was removed and the explicitly
chosen member became the new admin.
Both tests seed their own users + group via SQL and clean up after
themselves so they can run repeatedly against the live dev DB.
- artifacts/teaboy-os/playwright.config.mjs
Minimal Playwright config: testDir=tests, *.spec.mjs match, headless,
baseURL defaults to http://localhost:80 (the workspace proxy), and
is overridable via TEST_WEB_BASE.
- artifacts/teaboy-os/package.json
Added @playwright/test and pg as devDependencies and a `test:e2e`
script: `playwright test --config playwright.config.mjs`.
- .gitignore
Ignored Playwright's test-results/ and playwright-report/ output dirs.
How to run:
pnpm --filter @workspace/teaboy-os exec playwright install chromium
DATABASE_URL=... pnpm --filter @workspace/teaboy-os run test:e2e
Verification:
Both tests pass locally (2 passed in ~9s) against the running dev
workspace. Required system libraries for headless Chromium were
installed via the workspace's system-deps mechanism (glib, nss, nspr,
atk, cups, dbus, libdrm, libxkbcommon, libgbm, alsa-lib, pango, cairo,
and the relevant xorg libs), so `playwright test` works out of the
box on this environment.
No application source files were modified.
Replit-Task-Id: d2f21eab-498e-4cc0-a913-6035b714b3da
|
||
|
|
fbfe2c7ef5 | Git commit prior to merge | ||
|
|
1055866105 | Git commit prior to merge | ||
|
|
f311871ec8 |
Add automated tests for the leave-and-handoff flow (Task #50)
Adds artifacts/api-server/tests/conversations-leave.test.mjs, modeled on the existing apps-open.test.mjs, covering POST /conversations/:id/leave: - Solo member leaving deletes the conversation entirely. - Sole admin leaving with no successor auto-promotes the earliest-joined remaining member. - Sole admin leaving with a chosen successorId promotes that user. - Sole admin leaving with a non-member successorId returns 400 and leaves the group untouched (leaver still admin, no promotion). - Non-admin leaving a group removes them with no admin promotion. Tests create their own users (with the standard user role) and groups directly in Postgres so joined_at ordering is deterministic for the auto-promotion case, then exercise the route through HTTP using a real session cookie obtained from POST /api/auth/login. An after() hook cleans up all created conversations, participants, messages, role assignments, and users. The optional e2e for the chooser dialog is intentionally deferred and proposed as follow-up #51. Verified by running `pnpm --filter @workspace/api-server test` three times consecutively; all 15 tests pass on every run. |
||
|
|
8fb6d54d78 |
Add automated tests for the leave-and-handoff flow (Task #50)
Adds artifacts/api-server/tests/conversations-leave.test.mjs, modeled on the existing apps-open.test.mjs, covering POST /conversations/:id/leave: - Solo member leaving deletes the conversation entirely. - Sole admin leaving with no successor auto-promotes the earliest-joined remaining member. - Sole admin leaving with a chosen successorId promotes that user. - Sole admin leaving with a non-member successorId returns 400 and leaves the group untouched (leaver still admin, no promotion). - Non-admin leaving a group removes them with no admin promotion. Tests create their own users (with the standard user role) and groups directly in Postgres so joined_at ordering is deterministic for the auto-promotion case, then exercise the route through HTTP using a real session cookie obtained from POST /api/auth/login. An after() hook cleans up all created conversations, participants, messages, role assignments, and users. The optional e2e for the chooser dialog is intentionally deferred and proposed as follow-up #51. Verified by running `pnpm --filter @workspace/api-server test` three times consecutively; all 15 tests pass on every run. Replit-Task-Id: e31c169d-a4f5-4387-a642-b39a422c1408 |
||
|
|
84b34019e7 |
Show new admin clearly after sole admin leaves group chat
Task #49: When the sole admin leaves a group and a successor is auto- or manually-promoted, surface the change prominently in addition to the existing system messages. Changes: - artifacts/teaboy-os/src/pages/chat.tsx - New effect on conversations list: tracks the set of group conversations where the current user is currently an admin (from participant.isAdmin). On first load it silently records a baseline in localStorage (key teaboy:admin-known:<userId>); thereafter, any newly-admin group triggers a toast ("You are now the admin of <group>"). The set is pruned when the user is no longer admin so a future re-promotion toasts again. Using participant.isAdmin (rather than only lastMessage) ensures the cue fires even if newer messages have arrived in the conversation since the promotion. - Conversation list rows now render a small amber "New admin" / "You are now the admin" Crown badge whenever the most recent message is an admin_promoted system message. Variant differs for the promoted user vs other members. data-testid="badge-new-admin-<convId>" for tests. - Imported Crown from lucide-react. - artifacts/teaboy-os/src/locales/en.json + ar.json - Added bilingual strings under chat.actions: youAreAdminTitle, youAreAdminDescription, newAdminBadge, newAdminLabel. Implementation notes: - lastMessage.meta is already returned by GET /conversations and includes the promoted user (id, displayNameAr/En, username), so no API changes were needed. - Regenerated api-client-react via `pnpm --filter @workspace/api-spec run codegen` (pre-existing stale codegen was failing typecheck unrelated to this task, now clean for chat.tsx). - Did not add automated tests; the existing follow-up task "Make sure the leave-and-handoff flow stays working with automated tests" already covers it. |
||
|
|
42c2910d4b |
Show new admin clearly after sole admin leaves group chat
Task #49: When the sole admin leaves a group and a successor is auto- or manually-promoted, surface the change prominently in addition to the existing system messages. Changes: - artifacts/teaboy-os/src/pages/chat.tsx - New effect on conversations list: tracks the set of group conversations where the current user is currently an admin (from participant.isAdmin). On first load it silently records a baseline in localStorage (key teaboy:admin-known:<userId>); thereafter, any newly-admin group triggers a toast ("You are now the admin of <group>"). The set is pruned when the user is no longer admin so a future re-promotion toasts again. Using participant.isAdmin (rather than only lastMessage) ensures the cue fires even if newer messages have arrived in the conversation since the promotion. - Conversation list rows now render a small amber "New admin" / "You are now the admin" Crown badge whenever the most recent message is an admin_promoted system message. Variant differs for the promoted user vs other members. data-testid="badge-new-admin-<convId>" for tests. - Imported Crown from lucide-react. - artifacts/teaboy-os/src/locales/en.json + ar.json - Added bilingual strings under chat.actions: youAreAdminTitle, youAreAdminDescription, newAdminBadge, newAdminLabel. Implementation notes: - lastMessage.meta is already returned by GET /conversations and includes the promoted user (id, displayNameAr/En, username), so no API changes were needed. - Regenerated api-client-react via `pnpm --filter @workspace/api-spec run codegen` (pre-existing stale codegen was failing typecheck unrelated to this task, now clean for chat.tsx). - Did not add automated tests; the existing follow-up task "Make sure the leave-and-handoff flow stays working with automated tests" already covers it. Replit-Task-Id: 71495f44-8c6c-4f7f-8f48-6400630d1203 |
||
|
|
18c0518d3b |
Task #48: Let admins page through more than the last 100 opens
Added offset/limit pagination to the two admin app-opens drill-in endpoints so admins can investigate spikes that span more than the default 100 most-recent opens. Backend (artifacts/api-server/src/routes/stats.ts): - New parsePaging() helper validates `limit` (1..200, default 100) and `offset` (>=0, default 0); invalid values return 400. - Both `/stats/admin/app-opens/by-app/:appId` and `/stats/admin/app-opens/by-user/:userId` accept the new params, apply `.limit(limit).offset(offset)`, and return `limit`, `offset`, and a `nextOffset` (number | null) computed from `totalCount`. - Added a stable secondary sort (`id desc`) so paged results don't shuffle when timestamps tie. Spec & client (lib/api-spec/openapi.yaml + regenerated clients): - Added `limit`/`offset` query params and `limit`/`offset`/`nextOffset` response fields to AdminAppOpensByApp/AdminAppOpensByUser. - Re-ran `pnpm --filter @workspace/api-spec run codegen`. Frontend (artifacts/teaboy-os/src/pages/admin.tsx + locales): - AppOpensDrillIn / UserOpensDrillIn now accumulate extra pages in local state and expose a "Load more" button via a shared LoadMoreSection footer that also shows "Showing X of Y". - Extra pages are fetched via the generated `getAdminAppOpensByApp` / `getAdminAppOpensByUser` functions; accumulated state resets when the appId/userId or stats query params change. - Added en/ar translations for `loadMore`, `loadMoreError`, `shownOf`. Tests: - New artifacts/api-server/tests/admin-app-opens-pagination.test.mjs covers happy-path paging for both endpoints, the default page size, and 400 responses for invalid limit/offset. - All 10 api-server tests pass; full workspace typecheck passes. |
||
|
|
216ff65e04 |
Task #48: Let admins page through more than the last 100 opens
Added offset/limit pagination to the two admin app-opens drill-in endpoints so admins can investigate spikes that span more than the default 100 most-recent opens. Backend (artifacts/api-server/src/routes/stats.ts): - New parsePaging() helper validates `limit` (1..200, default 100) and `offset` (>=0, default 0); invalid values return 400. - Both `/stats/admin/app-opens/by-app/:appId` and `/stats/admin/app-opens/by-user/:userId` accept the new params, apply `.limit(limit).offset(offset)`, and return `limit`, `offset`, and a `nextOffset` (number | null) computed from `totalCount`. - Added a stable secondary sort (`id desc`) so paged results don't shuffle when timestamps tie. Spec & client (lib/api-spec/openapi.yaml + regenerated clients): - Added `limit`/`offset` query params and `limit`/`offset`/`nextOffset` response fields to AdminAppOpensByApp/AdminAppOpensByUser. - Re-ran `pnpm --filter @workspace/api-spec run codegen`. Frontend (artifacts/teaboy-os/src/pages/admin.tsx + locales): - AppOpensDrillIn / UserOpensDrillIn now accumulate extra pages in local state and expose a "Load more" button via a shared LoadMoreSection footer that also shows "Showing X of Y". - Extra pages are fetched via the generated `getAdminAppOpensByApp` / `getAdminAppOpensByUser` functions; accumulated state resets when the appId/userId or stats query params change. - Added en/ar translations for `loadMore`, `loadMoreError`, `shownOf`. Tests: - New artifacts/api-server/tests/admin-app-opens-pagination.test.mjs covers happy-path paging for both endpoints, the default page size, and 400 responses for invalid limit/offset. - All 10 api-server tests pass; full workspace typecheck passes. Replit-Task-Id: b6382efe-765f-4689-8c93-196fee253f63 |
||
|
|
2fcaa27fbd |
Make admin recent-opens drill-in rows clickable
Task: #47 — Let admins jump from a recent open straight to that user. Changes (artifacts/teaboy-os/src/pages/admin.tsx): - AppOpensDrillIn: each user row in the per-app recent-opens popup is now a focusable button. Clicking jumps to that user's row in the Users list (closes the popup, then calls the existing handleSelectUserFromDashboard via a new onJumpUser prop), reusing the highlight behavior that already powers the leaderboard. - UserOpensDrillIn: each app row in the per-user recent-opens popup is now a focusable button. Clicking opens that app's edit modal (closes the popup, then calls the existing handleSelectAppFromDashboard via a new onJumpApp prop), mirroring the leaderboard click behavior. - Added type="button", hover/focus styles, and aria-labels reusing the existing admin.dashboard.viewUserDetails / admin.dashboard.viewAppDetails translation keys (already localized for both en and ar). The footer "Edit app" / "View user" buttons remain unchanged and keep working alongside the per-row clicks. No new translation keys, schema changes, or API changes were needed — AppOpenByAppEntry already exposes userId and AppOpenByUserEntry already exposes appId. Verification: tsc --noEmit on teaboy-os shows no new errors from these edits (only the same pre-existing errors that were present before this task). E2E was not run because the change is a thin wiring of existing handlers and admin login requires custom session setup beyond this task's scope. |
||
|
|
ce0819cfaa |
Make admin recent-opens drill-in rows clickable
Task: #47 — Let admins jump from a recent open straight to that user. Changes (artifacts/teaboy-os/src/pages/admin.tsx): - AppOpensDrillIn: each user row in the per-app recent-opens popup is now a focusable button. Clicking jumps to that user's row in the Users list (closes the popup, then calls the existing handleSelectUserFromDashboard via a new onJumpUser prop), reusing the highlight behavior that already powers the leaderboard. - UserOpensDrillIn: each app row in the per-user recent-opens popup is now a focusable button. Clicking opens that app's edit modal (closes the popup, then calls the existing handleSelectAppFromDashboard via a new onJumpApp prop), mirroring the leaderboard click behavior. - Added type="button", hover/focus styles, and aria-labels reusing the existing admin.dashboard.viewUserDetails / admin.dashboard.viewAppDetails translation keys (already localized for both en and ar). The footer "Edit app" / "View user" buttons remain unchanged and keep working alongside the per-row clicks. No new translation keys, schema changes, or API changes were needed — AppOpenByAppEntry already exposes userId and AppOpenByUserEntry already exposes appId. Verification: tsc --noEmit on teaboy-os shows no new errors from these edits (only the same pre-existing errors that were present before this task). E2E was not run because the change is a thin wiring of existing handlers and admin login requires custom session setup beyond this task's scope. Replit-Task-Id: 5db0964e-95fa-4199-9337-631cd1a790ec |
||
|
|
39f99a80a7 |
Let leaving admins choose who takes over the group (task #46)
Original ask: when the only admin leaves a group, let them pick a
specific successor instead of always auto-promoting the longest-tenured
member. Keep "auto" available, with bilingual labels.
Changes:
- lib/api-spec/openapi.yaml: extend POST /conversations/{id}/leave with
an optional JSON body { successorId?: number | null }.
- Regenerated lib/api-client-react and lib/api-zod via api-spec codegen.
- artifacts/api-server/src/routes/conversations.ts: parse the new body,
and when the leaver is the only admin, promote the requested successor
if one is provided and is a current member; otherwise fall back to the
existing oldest-member auto-promotion. Returns 400 if successorId is
not a remaining member.
- artifacts/teaboy-os/src/pages/chat.tsx:
- Track a successorChoice state ("auto" | userId).
- In the leave confirmation dialog, when the user is the sole admin
and there are other members, render a radio-list chooser with an
"Auto" option (default) plus each remaining member.
- Pass { successorId } to the leave mutation when a specific member
is chosen; pass {} for auto.
- Reset choice on success.
- artifacts/teaboy-os/src/locales/{en,ar}.json: added successorTitle,
successorHelp, successorAuto strings.
Verification:
- pnpm -w run typecheck passes for libs and all artifacts.
- Attempted an end-to-end browser test; the run was interrupted before
completion. Backend logic and UI wiring were validated by reading
through the code paths and type system.
|
||
|
|
0b7593bbc2 |
Let leaving admins choose who takes over the group (task #46)
Original ask: when the only admin leaves a group, let them pick a
specific successor instead of always auto-promoting the longest-tenured
member. Keep "auto" available, with bilingual labels.
Changes:
- lib/api-spec/openapi.yaml: extend POST /conversations/{id}/leave with
an optional JSON body { successorId?: number | null }.
- Regenerated lib/api-client-react and lib/api-zod via api-spec codegen.
- artifacts/api-server/src/routes/conversations.ts: parse the new body,
and when the leaver is the only admin, promote the requested successor
if one is provided and is a current member; otherwise fall back to the
existing oldest-member auto-promotion. Returns 400 if successorId is
not a remaining member.
- artifacts/teaboy-os/src/pages/chat.tsx:
- Track a successorChoice state ("auto" | userId).
- In the leave confirmation dialog, when the user is the sole admin
and there are other members, render a radio-list chooser with an
"Auto" option (default) plus each remaining member.
- Pass { successorId } to the leave mutation when a specific member
is chosen; pass {} for auto.
- Reset choice on success.
- artifacts/teaboy-os/src/locales/{en,ar}.json: added successorTitle,
successorHelp, successorAuto strings.
Verification:
- pnpm -w run typecheck passes for libs and all artifacts.
- Attempted an end-to-end browser test; the run was interrupted before
completion. Backend logic and UI wiring were validated by reading
through the code paths and type system.
Replit-Task-Id: c9065bc1-ab4e-4a3b-a865-81754f5c2e5a
|
||
|
|
5a0a573609 |
Add notes functionality to the application with CRUD operations and labeling
Integrates a new Notes feature, including backend API routes for notes and labels, database schema updates, frontend UI components for creating, viewing, editing, and deleting notes, and internationalization support for notes in both English and Arabic. |
||
|
|
a864b84567 |
Add notes functionality to the application with CRUD operations and labeling
Integrates a new Notes feature, including backend API routes for notes and labels, database schema updates, frontend UI components for creating, viewing, editing, and deleting notes, and internationalization support for notes in both English and Arabic. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 4ab7f101-06a9-4dd7-94c8-617f1751327c Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/fYGOSe0 Replit-Helium-Checkpoint-Created: true |
||
|
|
75147c8f24 |
Task #45: Tapping a chat notification opens the matching conversation
- notifications.tsx: When a notification is clicked, if it has relatedType === "conversation" and a relatedId, navigate to /chat?c=<conversationId> in addition to marking it read. Other notification types continue to behave as before (just mark read). - chat.tsx: Read the optional `c` query parameter via wouter's useSearch hook. When present and valid, set it as the selectedConvId so the conversation opens automatically, then replace the URL back to /chat so refreshing or navigating away doesn't keep re-opening it. No API or schema changes required; notification records already carry relatedType/relatedId for chat notifications. |
||
|
|
8729cae01a |
Task #45: Tapping a chat notification opens the matching conversation
- notifications.tsx: When a notification is clicked, if it has relatedType === "conversation" and a relatedId, navigate to /chat?c=<conversationId> in addition to marking it read. Other notification types continue to behave as before (just mark read). - chat.tsx: Read the optional `c` query parameter via wouter's useSearch hook. When present and valid, set it as the selectedConvId so the conversation opens automatically, then replace the URL back to /chat so refreshing or navigating away doesn't keep re-opening it. No API or schema changes required; notification records already carry relatedType/relatedId for chat notifications. Replit-Task-Id: 2fda1864-99d6-4f07-a3d9-aa3021d5493f |
||
|
|
999d1a3e50 |
Push notification_created socket event for instant bell badge updates
Original task: Make the bell badge update instantly when a chat
notification arrives.
Changes:
- artifacts/api-server/src/routes/conversations.ts: After
createMessageNotifications inserts the rows, emit a
`notification_created` event to each recipient's `user:{id}` room
(carrying type/relatedId/relatedType for future routing).
- artifacts/teaboy-os/src/hooks/use-notifications-socket.ts: New hook
that opens a global socket connection (when the user is logged in)
and invalidates getListNotificationsQueryKey() and
getGetHomeStatsQueryKey() whenever `notification_created` fires.
- artifacts/teaboy-os/src/App.tsx: Mounts the hook via a small
NotificationsSocketBridge component inside AuthProvider so the
listener is active on every page (home, notifications, services,
etc.), not just /chat.
Notes:
- Socket join already happens server-side on connect
(`socket.join('user:{userId}')`), so no API server topology change
was needed.
- Pre-existing TS errors in api-server and teaboy-os are unrelated to
this change.
|
||
|
|
1411486602 |
Push notification_created socket event for instant bell badge updates
Original task: Make the bell badge update instantly when a chat
notification arrives.
Changes:
- artifacts/api-server/src/routes/conversations.ts: After
createMessageNotifications inserts the rows, emit a
`notification_created` event to each recipient's `user:{id}` room
(carrying type/relatedId/relatedType for future routing).
- artifacts/teaboy-os/src/hooks/use-notifications-socket.ts: New hook
that opens a global socket connection (when the user is logged in)
and invalidates getListNotificationsQueryKey() and
getGetHomeStatsQueryKey() whenever `notification_created` fires.
- artifacts/teaboy-os/src/App.tsx: Mounts the hook via a small
NotificationsSocketBridge component inside AuthProvider so the
listener is active on every page (home, notifications, services,
etc.), not just /chat.
Notes:
- Socket join already happens server-side on connect
(`socket.join('user:{userId}')`), so no API server topology change
was needed.
- Pre-existing TS errors in api-server and teaboy-os are unrelated to
this change.
Replit-Task-Id: ff3973f9-1c9d-4283-8091-bfeb3eb0d6a4
|
||
|
|
6316893c0e |
Task #43: Stop counting system messages as unread
Problem: Group rename, member-add, and member-remove events insert rows into the messages table with the actor as senderId, which made them increment the unread badge for everyone else just like a normal chat message. That created notification noise for routine admin tweaks. Fix: In `artifacts/api-server/src/routes/conversations.ts`, the `buildConversationDetails` unread count query now restricts to `messages.kind = 'user'`, so only real user chat messages contribute to the unread count returned for the conversation list / bell badge. Notes / non-changes: - The conversation-list "last message" preview is intentionally left unfiltered, so the most recent activity (including system messages) still surfaces in the list — matches the task's "Done looks like". - Push-style chat notifications (`createMessageNotifications`) are only invoked from the user send-message route, never from `insertAndEmitSystemMessage`, so no additional guard is required for system events today. - Frontend chat.tsx already renders system messages distinctly and shows them in the list preview; no UI change needed. |
||
|
|
ce1fb84365 |
Task #43: Stop counting system messages as unread
Problem: Group rename, member-add, and member-remove events insert rows into the messages table with the actor as senderId, which made them increment the unread badge for everyone else just like a normal chat message. That created notification noise for routine admin tweaks. Fix: In `artifacts/api-server/src/routes/conversations.ts`, the `buildConversationDetails` unread count query now restricts to `messages.kind = 'user'`, so only real user chat messages contribute to the unread count returned for the conversation list / bell badge. Notes / non-changes: - The conversation-list "last message" preview is intentionally left unfiltered, so the most recent activity (including system messages) still surfaces in the list — matches the task's "Done looks like". - Push-style chat notifications (`createMessageNotifications`) are only invoked from the user send-message route, never from `insertAndEmitSystemMessage`, so no additional guard is required for system events today. - Frontend chat.tsx already renders system messages distinctly and shows them in the list preview; no UI change needed. Replit-Task-Id: 3734d73b-2df7-4f32-9655-6c7a9e23536c |
||
|
|
e37f926581 |
Task #42: Tell members when someone leaves a group on their own
Original task: Post a bilingual system message into the group chat when a member leaves via POST /api/conversations/:id/leave, with real-time delivery via Socket.IO and rendering in the chat thread. Findings: - The leave handler in artifacts/api-server/src/routes/conversations.ts already inserts a `member_left` system message (and `admin_promoted` when a successor is auto-promoted) and emits via Socket.IO using insertAndEmitSystemMessage. Direct conversations and last-leaver cleanup paths are correctly skipped. - artifacts/teaboy-os/src/pages/chat.tsx renderSystemMessage already handles `member_left`, `admin_promoted`, and `adminPromotedAfterLeave`. - Bilingual locale keys exist in src/locales/en.json and ar.json under chat.system.memberLeft / adminPromoted / adminPromotedAfterLeave. Change made: - Extended the MessageWithSender.kind enum in lib/api-spec/openapi.yaml to include `member_left` and `admin_promoted` (previously only user/group_renamed/members_added/member_removed were declared). - Re-ran `pnpm --filter @workspace/api-spec run codegen` to regenerate api-zod and api-client-react schemas so the spec, runtime validation, and client types stay in sync. - Verified `pnpm -w run typecheck` passes across all packages. No behavioural code changes were necessary; the feature was already implemented end-to-end and only the API spec enum needed to catch up. |
||
|
|
62b79c7e7d |
Task #42: Tell members when someone leaves a group on their own
Original task: Post a bilingual system message into the group chat when a member leaves via POST /api/conversations/:id/leave, with real-time delivery via Socket.IO and rendering in the chat thread. Findings: - The leave handler in artifacts/api-server/src/routes/conversations.ts already inserts a `member_left` system message (and `admin_promoted` when a successor is auto-promoted) and emits via Socket.IO using insertAndEmitSystemMessage. Direct conversations and last-leaver cleanup paths are correctly skipped. - artifacts/teaboy-os/src/pages/chat.tsx renderSystemMessage already handles `member_left`, `admin_promoted`, and `adminPromotedAfterLeave`. - Bilingual locale keys exist in src/locales/en.json and ar.json under chat.system.memberLeft / adminPromoted / adminPromotedAfterLeave. Change made: - Extended the MessageWithSender.kind enum in lib/api-spec/openapi.yaml to include `member_left` and `admin_promoted` (previously only user/group_renamed/members_added/member_removed were declared). - Re-ran `pnpm --filter @workspace/api-spec run codegen` to regenerate api-zod and api-client-react schemas so the spec, runtime validation, and client types stay in sync. - Verified `pnpm -w run typecheck` passes across all packages. No behavioural code changes were necessary; the feature was already implemented end-to-end and only the API spec enum needed to catch up. Replit-Task-Id: 40fccb3a-4fc0-4ad7-a6e9-d1ac67ef7769 |
||
|
|
1457e99a49 |
Add admin recent-opens drill-in popup for top apps and users
Task #41: Show a usage history popup when admins click a top apps row or a most-active users row on the admin dashboard. Changes: - API: extracted the existing range/from/to parser in artifacts/api-server/src/routes/stats.ts into a shared parseRangeWindow() helper so the same window logic powers the existing /stats/admin endpoint and two new ones. - API: added GET /stats/admin/app-opens/by-app/:appId returning the last 100 opens for an app inside the selected window, including the user (id, username, displayName, avatarUrl) and a totalCount. requireAuth + requireAdmin guarded. - API: added GET /stats/admin/app-opens/by-user/:userId with the same shape but per-app metadata for each open. - Spec: added matching paths and AdminAppOpensByApp / AdminAppOpensByUser schemas in lib/api-spec/openapi.yaml, reran orval codegen for api-client-react and api-zod. - UI: in artifacts/teaboy-os/src/pages/admin.tsx the Top apps and Most active users leaderboard rows now open a drill-in modal instead of immediately navigating away. The modal shows a scrollable timeline of recent opens (timestamp + user/app), respects the dashboard's current range selector (7d/30d/90d/custom), and exposes an "Edit app" / "View user" footer button that preserves the previous jump-to behaviour. Loading, error, and empty states are handled. - i18n: added admin.dashboard.drillIn keys in en.json and ar.json (titles, subtitle, empty/error, footer buttons). Verification: pnpm run typecheck passes. Follow-ups proposed: #47 (clickable rows inside the popup), #48 (paginate beyond 100 opens). |
||
|
|
b6a0dc6ab9 |
Add admin recent-opens drill-in popup for top apps and users
Task #41: Show a usage history popup when admins click a top apps row or a most-active users row on the admin dashboard. Changes: - API: extracted the existing range/from/to parser in artifacts/api-server/src/routes/stats.ts into a shared parseRangeWindow() helper so the same window logic powers the existing /stats/admin endpoint and two new ones. - API: added GET /stats/admin/app-opens/by-app/:appId returning the last 100 opens for an app inside the selected window, including the user (id, username, displayName, avatarUrl) and a totalCount. requireAuth + requireAdmin guarded. - API: added GET /stats/admin/app-opens/by-user/:userId with the same shape but per-app metadata for each open. - Spec: added matching paths and AdminAppOpensByApp / AdminAppOpensByUser schemas in lib/api-spec/openapi.yaml, reran orval codegen for api-client-react and api-zod. - UI: in artifacts/teaboy-os/src/pages/admin.tsx the Top apps and Most active users leaderboard rows now open a drill-in modal instead of immediately navigating away. The modal shows a scrollable timeline of recent opens (timestamp + user/app), respects the dashboard's current range selector (7d/30d/90d/custom), and exposes an "Edit app" / "View user" footer button that preserves the previous jump-to behaviour. Loading, error, and empty states are handled. - i18n: added admin.dashboard.drillIn keys in en.json and ar.json (titles, subtitle, empty/error, footer buttons). Verification: pnpm run typecheck passes. Follow-ups proposed: #47 (clickable rows inside the popup), Replit-Task-Id: f2fbe652-a788-4f25-9fb2-9ef2c535c8da #48 (paginate beyond 100 opens). |
||
|
|
732cb379ee |
Prevent database synchronization issues by ignoring specific tables
Configure Drizzle to exclude the `user_sessions` table from schema introspection. |
||
|
|
b910733adc |
Prevent database synchronization issues by ignoring specific tables
Configure Drizzle to exclude the `user_sessions` table from schema introspection. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 4e1b5887-b92a-4851-b4ff-a7278a110e95 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/YPEna1J Replit-Helium-Checkpoint-Created: true |
||
|
|
e9fbddffe3 |
Stop a group from being orphaned when its only admin leaves (Task #40)
The /conversations/:id/leave handler used to delete the leaver's participant row unconditionally. If the leaver was the only admin, the group survived but no one could rename it, change the picture, or add/remove members. If they were also the only participant, the empty conversation lingered forever. Server (artifacts/api-server/src/routes/conversations.ts): - Load all participants ordered by joinedAt before mutating anything. - If the leaver is the only participant, delete the conversation row (cascades clean up participants, messages, and reads) and skip the emit. - If the leaver is the only admin, promote the longest-tenured remaining participant (oldest joinedAt) to admin in the same flow. - Emit a `member_left` system message and, when applicable, an `admin_promoted` system message (with reason `previous_admin_left`) before removing the leaver, so members see both events live. Client (artifacts/teaboy-os/src/pages/chat.tsx + locales): - Render the new `member_left` and `admin_promoted` system message kinds with bilingual copy in en.json and ar.json. - Extended SystemMessageMeta with `promoted` and `reason` fields. Approach notes: - Chose auto-promotion over a chooser dialog to keep the leave flow one-tap; proposed a follow-up (#46) for an optional successor picker. - API contract for /leave is unchanged (still POST with no body), so no openapi.yaml or codegen changes were needed. - Pre-existing TypeScript errors in auth.ts, admin.tsx, etc. are unrelated codegen drift and were left alone. |
||
|
|
a52c1659fc |
Stop a group from being orphaned when its only admin leaves (Task #40)
The /conversations/:id/leave handler used to delete the leaver's participant row unconditionally. If the leaver was the only admin, the group survived but no one could rename it, change the picture, or add/remove members. If they were also the only participant, the empty conversation lingered forever. Server (artifacts/api-server/src/routes/conversations.ts): - Load all participants ordered by joinedAt before mutating anything. - If the leaver is the only participant, delete the conversation row (cascades clean up participants, messages, and reads) and skip the emit. - If the leaver is the only admin, promote the longest-tenured remaining participant (oldest joinedAt) to admin in the same flow. - Emit a `member_left` system message and, when applicable, an `admin_promoted` system message (with reason `previous_admin_left`) before removing the leaver, so members see both events live. Client (artifacts/teaboy-os/src/pages/chat.tsx + locales): - Render the new `member_left` and `admin_promoted` system message kinds with bilingual copy in en.json and ar.json. - Extended SystemMessageMeta with `promoted` and `reason` fields. Approach notes: - Chose auto-promotion over a chooser dialog to keep the leave flow one-tap; proposed a follow-up (#46) for an optional successor picker. - API contract for /leave is unchanged (still POST with no body), so no openapi.yaml or codegen changes were needed. - Pre-existing TypeScript errors in auth.ts, admin.tsx, etc. are unrelated codegen drift and were left alone. Replit-Task-Id: 026e59a5-90c0-4faa-9080-aee0aee0a631 |
||
|
|
16020a9e37 |
Task #39: Send a real chat notification when someone messages a non-muted chat
Wired the chat message-send handler in artifacts/api-server/src/routes/conversations.ts to
create rows in the `notifications` table for every conversation participant who:
- is not the sender
- has `is_muted = false` on `conversation_participants`
Implementation details:
- Added a `createMessageNotifications` helper invoked after the new_message socket emit.
- Imported `notificationsTable` from `@workspace/db`.
- Notification content:
* Direct chat: title = sender display name, body = message preview (≤140 chars)
* Group chat: title = group name (fallback chain), body = "{sender}: {preview}"
Both Arabic and English titles/bodies are populated using the sender's
displayNameAr/displayNameEn (with username fallback) so the existing
bilingual notifications page renders correctly.
- type = "chat", relatedType = "conversation", relatedId = conversation id, so
notifications can later be deep-linked to the chat.
Muted conversations are filtered at the SQL level, so no notification rows are
created for muted recipients — the existing `conversation_participants.is_muted`
flag is the single source of truth, satisfying the task acceptance criteria.
No schema changes were needed; existing `notifications` table fields cover this.
The notifications page and bell badge already read from `useListNotifications`,
so no frontend changes were required — entries appear on next refetch/navigation.
Pre-existing TypeScript errors in the api-server (stale codegen for
@workspace/api-zod and unrelated schema fields) are not introduced by this change;
the esbuild build succeeds and the server starts cleanly.
|
||
|
|
5a0f6803b0 |
Task #39: Send a real chat notification when someone messages a non-muted chat
Wired the chat message-send handler in artifacts/api-server/src/routes/conversations.ts to
create rows in the `notifications` table for every conversation participant who:
- is not the sender
- has `is_muted = false` on `conversation_participants`
Implementation details:
- Added a `createMessageNotifications` helper invoked after the new_message socket emit.
- Imported `notificationsTable` from `@workspace/db`.
- Notification content:
* Direct chat: title = sender display name, body = message preview (≤140 chars)
* Group chat: title = group name (fallback chain), body = "{sender}: {preview}"
Both Arabic and English titles/bodies are populated using the sender's
displayNameAr/displayNameEn (with username fallback) so the existing
bilingual notifications page renders correctly.
- type = "chat", relatedType = "conversation", relatedId = conversation id, so
notifications can later be deep-linked to the chat.
Muted conversations are filtered at the SQL level, so no notification rows are
created for muted recipients — the existing `conversation_participants.is_muted`
flag is the single source of truth, satisfying the task acceptance criteria.
No schema changes were needed; existing `notifications` table fields cover this.
The notifications page and bell badge already read from `useListNotifications`,
so no frontend changes were required — entries appear on next refetch/navigation.
Pre-existing TypeScript errors in the api-server (stale codegen for
@workspace/api-zod and unrelated schema fields) are not introduced by this change;
the esbuild build succeeds and the server starts cleanly.
Replit-Task-Id: 6b146a53-a575-4921-bd4f-3332247779df
|
||
|
|
ebc2e977b0 |
Send system messages for group rename / add / remove
Original task (#38): When admins rename a group or add/remove members, post a system message into the chat thread so other members see who changed what and when, with bilingual (AR/EN) text and real-time delivery. Changes - lib/db/src/schema/conversations.ts: added `kind` (varchar default "user") and `meta` (jsonb) columns on the `messages` table. Pushed the new columns directly via ALTER TABLE since drizzle-kit push prompted on unrelated rename ambiguities. Also healed pre-existing schema drift on `users.clock_hour12`, `conversations.avatar_url`, and `conversation_participants.is_muted/is_archived` so the API could start. - lib/api-spec/openapi.yaml: extended MessageWithSender with `kind` (enum: user | group_renamed | members_added | member_removed) and optional `meta`. Re-ran codegen. - artifacts/api-server/src/routes/conversations.ts: added insertAndEmitSystemMessage + small user-display helpers; PATCH conversation now emits a `group_renamed` system message when a name actually changes; add-participants emits `members_added` with the actor + added users; remove-participant emits `member_removed` with actor + removed user. Each system message is broadcast over Socket.IO via the existing `new_message` channel so all current members receive it immediately. - artifacts/teaboy-os/src/pages/chat.tsx: render messages with `kind != "user"` as centered, muted pill bubbles (no avatar / sender label) using a new renderSystemMessage helper that picks the language-appropriate name out of meta. Conversation list preview also uses it so the last activity reads sensibly when the most recent message is a system message. - artifacts/teaboy-os/src/locales/{en,ar}.json: added chat.system.* strings (groupRenamed, membersAdded with plural variants, memberRemoved, someone, listSeparator). Verification - Typecheck (libs + artifacts) passes. - e2e via testing skill: registered fresh users, created a group, renamed it, added a member, removed a member; all three centered system messages appeared in the thread in order with the expected copy. Notes / deviations - Used the actor's userId as senderId for system messages (kept existing NOT NULL FK) instead of introducing a nullable sender, which keeps the migration lightweight. This means system messages count toward unread for non-actor members; flagged as a follow-up. |
||
|
|
db9cf7b315 |
Send system messages for group rename / add / remove
Original task (#38): When admins rename a group or add/remove members, post a system message into the chat thread so other members see who changed what and when, with bilingual (AR/EN) text and real-time delivery. Changes - lib/db/src/schema/conversations.ts: added `kind` (varchar default "user") and `meta` (jsonb) columns on the `messages` table. Pushed the new columns directly via ALTER TABLE since drizzle-kit push prompted on unrelated rename ambiguities. Also healed pre-existing schema drift on `users.clock_hour12`, `conversations.avatar_url`, and `conversation_participants.is_muted/is_archived` so the API could start. - lib/api-spec/openapi.yaml: extended MessageWithSender with `kind` (enum: user | group_renamed | members_added | member_removed) and optional `meta`. Re-ran codegen. - artifacts/api-server/src/routes/conversations.ts: added insertAndEmitSystemMessage + small user-display helpers; PATCH conversation now emits a `group_renamed` system message when a name actually changes; add-participants emits `members_added` with the actor + added users; remove-participant emits `member_removed` with actor + removed user. Each system message is broadcast over Socket.IO via the existing `new_message` channel so all current members receive it immediately. - artifacts/teaboy-os/src/pages/chat.tsx: render messages with `kind != "user"` as centered, muted pill bubbles (no avatar / sender label) using a new renderSystemMessage helper that picks the language-appropriate name out of meta. Conversation list preview also uses it so the last activity reads sensibly when the most recent message is a system message. - artifacts/teaboy-os/src/locales/{en,ar}.json: added chat.system.* strings (groupRenamed, membersAdded with plural variants, memberRemoved, someone, listSeparator). Verification - Typecheck (libs + artifacts) passes. - e2e via testing skill: registered fresh users, created a group, renamed it, added a member, removed a member; all three centered system messages appeared in the thread in order with the expected copy. Notes / deviations - Used the actor's userId as senderId for system messages (kept existing NOT NULL FK) instead of introducing a nullable sender, which keeps the migration lightweight. This means system messages count toward unread for non-actor members; flagged as a follow-up. Replit-Task-Id: 6dfa2b99-fbac-4146-b59b-8c04a14c9e96 |
||
|
|
00d07e02a8 |
Let group admins delete the group's picture
Task #37: Add a "Remove picture" action next to the camera icon in the group chat header so admins can clear a group's avatar back to the default Users icon, not just replace it. Implementation: - artifacts/teaboy-os/src/pages/chat.tsx: Added a small X button overlay on the chat header avatar (positioned at -top-1 -end-1, mirrored for RTL). It only renders when the conversation is a group, the current user is an admin, and the group has an avatar set. Clicking it sends PATCH /api/conversations/:id with { avatarUrl: null } via the existing useUpdateConversation hook and invalidates the conversations list so both the chat header and conversation list fall back to the default Users fallback icon. - Reused existing locale keys chat.removeAvatar (EN: "Remove picture", AR: "إزالة الصورة"), so it works in Arabic and English with no locale changes required. - Backend (artifacts/api-server/src/routes/conversations.ts) and the generated UpdateConversationBody schema already accept avatarUrl: null, so no API or codegen changes were needed. Notes / deviations: - Pre-existing TypeScript errors in chat.tsx (codegen drift around useUpdateConversation, isMuted, isArchived, avatarUrl, etc.) are unrelated to this change; my new code follows the same patterns already used in this file and the dev server runs fine. |
||
|
|
c1b53dea8d |
Let group admins delete the group's picture
Task #37: Add a "Remove picture" action next to the camera icon in the group chat header so admins can clear a group's avatar back to the default Users icon, not just replace it. Implementation: - artifacts/teaboy-os/src/pages/chat.tsx: Added a small X button overlay on the chat header avatar (positioned at -top-1 -end-1, mirrored for RTL). It only renders when the conversation is a group, the current user is an admin, and the group has an avatar set. Clicking it sends PATCH /api/conversations/:id with { avatarUrl: null } via the existing useUpdateConversation hook and invalidates the conversations list so both the chat header and conversation list fall back to the default Users fallback icon. - Reused existing locale keys chat.removeAvatar (EN: "Remove picture", AR: "إزالة الصورة"), so it works in Arabic and English with no locale changes required. - Backend (artifacts/api-server/src/routes/conversations.ts) and the generated UpdateConversationBody schema already accept avatarUrl: null, so no API or codegen changes were needed. Notes / deviations: - Pre-existing TypeScript errors in chat.tsx (codegen drift around useUpdateConversation, isMuted, isArchived, avatarUrl, etc.) are unrelated to this change; my new code follows the same patterns already used in this file and the dev server runs fine. Replit-Task-Id: 03db94ee-51ff-4695-8347-07fe7d962c5d |
||
|
|
4008bd4e17 |
Honor user's 12/24-hour clock preference for chat & notification timestamps
Original task: Chat message timestamps and notification list timestamps were always rendered in 24-hour format, ignoring the per-user clockHour12 preference that already controls the home-screen clock. Changes: - artifacts/teaboy-os/src/lib/i18n-format.ts: formatDateTime() now accepts an optional `hour12` boolean (defaults to false to preserve existing callers). formatTime() already passed hour12 through options. - artifacts/teaboy-os/src/pages/chat.tsx: Message bubble timestamp now passes `hour12: user?.clockHour12 ?? false` to formatTime(). The user is already pulled from useAuth() in this file. - artifacts/teaboy-os/src/pages/notifications.tsx: Imported useAuth, read user, and passed user?.clockHour12 ?? false to formatDateTime(). Locale handling: i18n-format already forces Latin digits via the `-u-nu-latn` locale extension and numberingSystem: "latn". With hour12 enabled, Intl.DateTimeFormat in the `ar` locale emits the localized ص/م markers automatically, satisfying the Arabic requirement. Verified: tsc --noEmit on the teaboy-os artifact reports no new errors introduced by these changes (pre-existing unrelated errors remain). No follow-up tasks proposed — task is self-contained and the project task list already covers adjacent chat/notification work. |
||
|
|
8e14846772 |
Honor user's 12/24-hour clock preference for chat & notification timestamps
Original task: Chat message timestamps and notification list timestamps were always rendered in 24-hour format, ignoring the per-user clockHour12 preference that already controls the home-screen clock. Changes: - artifacts/teaboy-os/src/lib/i18n-format.ts: formatDateTime() now accepts an optional `hour12` boolean (defaults to false to preserve existing callers). formatTime() already passed hour12 through options. - artifacts/teaboy-os/src/pages/chat.tsx: Message bubble timestamp now passes `hour12: user?.clockHour12 ?? false` to formatTime(). The user is already pulled from useAuth() in this file. - artifacts/teaboy-os/src/pages/notifications.tsx: Imported useAuth, read user, and passed user?.clockHour12 ?? false to formatDateTime(). Locale handling: i18n-format already forces Latin digits via the `-u-nu-latn` locale extension and numberingSystem: "latn". With hour12 enabled, Intl.DateTimeFormat in the `ar` locale emits the localized ص/م markers automatically, satisfying the Arabic requirement. Verified: tsc --noEmit on the teaboy-os artifact reports no new errors introduced by these changes (pre-existing unrelated errors remain). No follow-up tasks proposed — task is self-contained and the project task list already covers adjacent chat/notification work. Replit-Task-Id: 583b65bd-a229-46fb-92a6-bb0b095f4c93 |
||
|
|
e8cb2b836d |
Reject invalid custom date ranges on /api/stats/admin with HTTP 400
Original task (Task #35): When the admin dashboard's custom range receives a malformed or missing date (e.g. ?range=custom&from=foo), the API silently fell back to the 7-day window instead of returning an error. This masked client bugs and confused admins. Changes: - artifacts/api-server/src/routes/stats.ts: - Refactored the custom-range branch so range=custom now always validates from/to. Returns 400 with a helpful, specific message when: * from or to is missing * from or to is not a valid YYYY-MM-DD UTC date * from is after to (existing behavior, message clarified) - Removed the silent `if (range === "custom") range = "7d"` fallback. - lib/api-spec/openapi.yaml: - Documented the 400 ErrorResponse on getAdminStats so the generated clients know about this failure mode. - Regenerated @workspace/api-client-react and @workspace/api-zod via `pnpm --filter @workspace/api-spec run codegen`. - artifacts/teaboy-os/src/pages/admin.tsx: - Captured `error` from useGetAdminStats (with retry: false) and surface a translated, role="alert" panel beneath the range controls when the API returns an error, including the server's error message. The frontend already guards against client-side invalid input via isCustomValid, so this primarily covers any remaining edge cases (stale querystring, race conditions). - Added admin.dashboard.customRange.loadError translations in en.json and ar.json. Verified with `pnpm -w run typecheck` (passes for libs and all artifacts). Manual curl confirmed the route is wired (auth gate returns 401 first, as expected). |
||
|
|
36f2872dcd |
Reject invalid custom date ranges on /api/stats/admin with HTTP 400
Original task (Task #35): When the admin dashboard's custom range receives a malformed or missing date (e.g. ?range=custom&from=foo), the API silently fell back to the 7-day window instead of returning an error. This masked client bugs and confused admins. Changes: - artifacts/api-server/src/routes/stats.ts: - Refactored the custom-range branch so range=custom now always validates from/to. Returns 400 with a helpful, specific message when: * from or to is missing * from or to is not a valid YYYY-MM-DD UTC date * from is after to (existing behavior, message clarified) - Removed the silent `if (range === "custom") range = "7d"` fallback. - lib/api-spec/openapi.yaml: - Documented the 400 ErrorResponse on getAdminStats so the generated clients know about this failure mode. - Regenerated @workspace/api-client-react and @workspace/api-zod via `pnpm --filter @workspace/api-spec run codegen`. - artifacts/teaboy-os/src/pages/admin.tsx: - Captured `error` from useGetAdminStats (with retry: false) and surface a translated, role="alert" panel beneath the range controls when the API returns an error, including the server's error message. The frontend already guards against client-side invalid input via isCustomValid, so this primarily covers any remaining edge cases (stale querystring, race conditions). - Added admin.dashboard.customRange.loadError translations in en.json and ar.json. Verified with `pnpm -w run typecheck` (passes for libs and all artifacts). Manual curl confirmed the route is wired (auth gate returns 401 first, as expected). Replit-Task-Id: 965134ad-0d07-4cd2-a6ff-f60a50289d90 |
||
|
|
77843e3540 |
Show user avatars in the most-active-users leaderboard
Original task #33: The admin "Most active users" leaderboard rendered only a colored circle with the first letter of each user's name even though the API already returns each user's avatarUrl. Changes: - artifacts/teaboy-os/src/pages/admin.tsx - Added a small LeaderboardAvatar component that renders the avatar image when available and falls back to the initial when there is no avatarUrl or when the image fails to load (onError). - The avatar URL is resolved through the existing resolveServiceImageUrl helper (consistent with chat.tsx). - Kept the existing emerald circle styling as the fallback background; added overflow-hidden so the rounded image is clipped. - useEffect resets the error state when the src changes so a later valid URL still attempts to load. No API or schema changes were required (avatarUrl is already returned by GET /admin/stats and present in the generated client types). Pre-existing TypeScript errors in admin.tsx / chat.tsx / clock files are unrelated to this task and were not touched. |
||
|
|
1e6713f531 |
Show user avatars in the most-active-users leaderboard
Original task #33: The admin "Most active users" leaderboard rendered only a colored circle with the first letter of each user's name even though the API already returns each user's avatarUrl. Changes: - artifacts/teaboy-os/src/pages/admin.tsx - Added a small LeaderboardAvatar component that renders the avatar image when available and falls back to the initial when there is no avatarUrl or when the image fails to load (onError). - The avatar URL is resolved through the existing resolveServiceImageUrl helper (consistent with chat.tsx). - Kept the existing emerald circle styling as the fallback background; added overflow-hidden so the rounded image is clipped. - useEffect resets the error state when the src changes so a later valid URL still attempts to load. No API or schema changes were required (avatarUrl is already returned by GET /admin/stats and present in the generated client types). Pre-existing TypeScript errors in admin.tsx / chat.tsx / clock files are unrelated to this task and were not touched. Replit-Task-Id: a0fe21b3-7422-48ba-9731-ed8315eb9d68 |
||
|
|
a60ea914f4 |
Task #32: Let admins click a top app or active user to see details
Made the leaderboard rows on the admin dashboard interactive so admins can
drill in directly to investigate.
Changes:
- artifacts/teaboy-os/src/pages/admin.tsx
- DashboardSection: each "Top apps" and "Most active users" row is now a
real <button type="button"> with a descriptive aria-label
("View details for ..."), focus-visible ring, and hover styles.
- New onSelectApp / onSelectUser props passed from AdminPage:
* Top apps row -> switches to the Apps section AND opens the existing
Edit App modal prefilled with that app's data (uses the apps list
already loaded via useListApps to look up the full record).
* Most active users row -> switches to the Users section, scrolls the
matching user row into view, and applies a temporary primary-colored
ring highlight that fades after ~2.5s.
- Added userRowRefs (Map of id -> div) and a highlightedUserId state +
effect to drive the scroll/highlight behavior.
- artifacts/teaboy-os/src/locales/{en,ar}.json
- Added admin.dashboard.viewAppDetails / viewUserDetails strings used as
aria-labels.
Verification: e2e tested via the testing skill — login as admin, click a
top app row (modal opens), Cancel, click a most-active-users row (users
section opens with highlighted row), and Tab+Enter on a top apps row also
opens the modal (keyboard accessibility confirmed).
Notes / deviations: pre-existing TypeScript errors in the project's API
client types (topApps/mostActiveUsers/rangeFrom not yet on AdminStats,
and unrelated chat.tsx/home.tsx errors) are not introduced by this task
and were not addressed.
|
||
|
|
13040c8a93 |
Task #32: Let admins click a top app or active user to see details
Made the leaderboard rows on the admin dashboard interactive so admins can
drill in directly to investigate.
Changes:
- artifacts/teaboy-os/src/pages/admin.tsx
- DashboardSection: each "Top apps" and "Most active users" row is now a
real <button type="button"> with a descriptive aria-label
("View details for ..."), focus-visible ring, and hover styles.
- New onSelectApp / onSelectUser props passed from AdminPage:
* Top apps row -> switches to the Apps section AND opens the existing
Edit App modal prefilled with that app's data (uses the apps list
already loaded via useListApps to look up the full record).
* Most active users row -> switches to the Users section, scrolls the
matching user row into view, and applies a temporary primary-colored
ring highlight that fades after ~2.5s.
- Added userRowRefs (Map of id -> div) and a highlightedUserId state +
effect to drive the scroll/highlight behavior.
- artifacts/teaboy-os/src/locales/{en,ar}.json
- Added admin.dashboard.viewAppDetails / viewUserDetails strings used as
aria-labels.
Verification: e2e tested via the testing skill — login as admin, click a
top app row (modal opens), Cancel, click a most-active-users row (users
section opens with highlighted row), and Tab+Enter on a top apps row also
opens the modal (keyboard accessibility confirmed).
Notes / deviations: pre-existing TypeScript errors in the project's API
client types (topApps/mostActiveUsers/rangeFrom not yet on AdminStats,
and unrelated chat.tsx/home.tsx errors) are not introduced by this task
and were not addressed.
Replit-Task-Id: 95c90dfe-6761-4d04-8e71-f2aa14e590bb
|
||
|
|
90a7a807e9 |
Task #31: Let people leave, mute, or archive a group chat
Adds per-user mute / archive / leave actions for chats. Schema: - `lib/db/src/schema/conversations.ts`: added `is_muted` and `is_archived` boolean columns on `conversation_participants`. - Columns applied directly via SQL (drizzle push wanted to make unrelated app_opens decisions; force-applied is_muted/is_archived with `ALTER TABLE ... ADD COLUMN IF NOT EXISTS`). API (`artifacts/api-server/src/routes/conversations.ts`): - New endpoint `PATCH /conversations/:id/state` — current user toggles their own `isMuted` / `isArchived`. - New endpoint `POST /conversations/:id/leave` — removes the caller from a group conversation; rejects DMs. - `buildConversationDetails` now returns `isMuted` and `isArchived` for the requesting user. - `sendMessage` auto-clears `isArchived` for all participants so archived chats reappear when a new message arrives. OpenAPI (`lib/api-spec/openapi.yaml`): - Added the two new operations and `UpdateConversationStateBody`. - Added `isMuted` / `isArchived` to `ConversationWithDetails`. - Re-ran codegen for `@workspace/api-zod` and `@workspace/api-client-react`. UI (`artifacts/teaboy-os/src/pages/chat.tsx`): - Header gets a kebab "chat actions" button visible for both DMs and groups when a conversation is open. - Action sheet offers Mute/Unmute, Archive/Unarchive, and (groups only) Leave with a confirmation dialog. - Conversation list now has Active / Archived tabs and a bell-off indicator + dimmed unread badge for muted chats. - Bilingual strings added to en.json and ar.json. Side fixes (unrelated pre-existing schema drift discovered while testing): added missing `users.clock_hour12` and `conversations.avatar_url` columns directly so login and the conversations list work; the schema files already declared them. Verified end-to-end with the testing tool: mute, archive, unarchive, and leave-group flows all pass. |
||
|
|
7b77de107f |
Task #31: Let people leave, mute, or archive a group chat
Adds per-user mute / archive / leave actions for chats. Schema: - `lib/db/src/schema/conversations.ts`: added `is_muted` and `is_archived` boolean columns on `conversation_participants`. - Columns applied directly via SQL (drizzle push wanted to make unrelated app_opens decisions; force-applied is_muted/is_archived with `ALTER TABLE ... ADD COLUMN IF NOT EXISTS`). API (`artifacts/api-server/src/routes/conversations.ts`): - New endpoint `PATCH /conversations/:id/state` — current user toggles their own `isMuted` / `isArchived`. - New endpoint `POST /conversations/:id/leave` — removes the caller from a group conversation; rejects DMs. - `buildConversationDetails` now returns `isMuted` and `isArchived` for the requesting user. - `sendMessage` auto-clears `isArchived` for all participants so archived chats reappear when a new message arrives. OpenAPI (`lib/api-spec/openapi.yaml`): - Added the two new operations and `UpdateConversationStateBody`. - Added `isMuted` / `isArchived` to `ConversationWithDetails`. - Re-ran codegen for `@workspace/api-zod` and `@workspace/api-client-react`. UI (`artifacts/teaboy-os/src/pages/chat.tsx`): - Header gets a kebab "chat actions" button visible for both DMs and groups when a conversation is open. - Action sheet offers Mute/Unmute, Archive/Unarchive, and (groups only) Leave with a confirmation dialog. - Conversation list now has Active / Archived tabs and a bell-off indicator + dimmed unread badge for muted chats. - Bilingual strings added to en.json and ar.json. Side fixes (unrelated pre-existing schema drift discovered while testing): added missing `users.clock_hour12` and `conversations.avatar_url` columns directly so login and the conversations list work; the schema files already declared them. Verified end-to-end with the testing tool: mute, archive, unarchive, and leave-group flows all pass. Replit-Task-Id: faec58bb-12c6-4f6f-9ddb-f3f9f6c033f4 |
||
|
|
78b51b9112 |
Task #30: Group settings (rename, add/remove members)
Lets group admins manage their groups after creation.
API changes (lib/api-spec/openapi.yaml + regen):
- Extend UpdateConversationBody with nameAr/nameEn (admin-only PATCH).
- Add POST /conversations/{id}/participants (add members).
- Add DELETE /conversations/{id}/participants/{userId} (remove member).
Backend (artifacts/api-server/src/routes/conversations.ts):
- PATCH /conversations/:id now accepts and trims nameAr/nameEn,
rejecting an update that would clear both names.
- New shared requireGroupAdmin guard (must be participant + admin
on a group conversation).
- Add-participants validates user IDs exist and skips duplicates.
- Remove-participants forbids the admin from removing themselves.
- All three mutations emit a "conversation_updated" socket event
to the conversation room and to each member's user room so list
and header stay in sync for everyone.
Frontend (artifacts/teaboy-os/src/pages/chat.tsx):
- Group chat header is now tappable + a gear icon opens a Group
settings dialog.
- Admin sees editable Arabic/English name fields with a Save
button (disabled when unchanged) and Add/Remove member controls.
- Non-admins see a read-only members list.
- Add Members reuses /users/directory and excludes existing members.
- Removes own row's trash button so admin can't remove themselves.
- Subscribes to "conversation_updated" socket event to refresh list.
- Bilingual strings added (chat.settings.*) in en.json and ar.json
with full Arabic plural forms.
Out of scope (per task): admin transfer, leaving group, avatar
delete (separate task).
Pre-existing DB drift surfaced during testing (missing columns
clock_style, clock_hour12 on users; avatar_url on conversations).
Added with non-destructive ALTER TABLE ... ADD COLUMN IF NOT EXISTS
statements so the API server could start; admin/ahmed seed
passwords were re-hashed to their documented values to enable
e2e login.
Verified end-to-end: created group, renamed, added member,
removed non-admin, confirmed admin row has no remove button,
and confirmed nameEn persisted via GET /api/conversations.
|