Skip to content

feat: Task sharing via link (#4727) - #4737

Merged
beastoin merged 39 commits into
mainfrom
feat/task-sharing
Feb 12, 2026
Merged

beastoin merged 39 commits into
mainfrom
feat/task-sharing

Conversation

@beastoin

@beastoin beastoin commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Backend: 3 new endpoints (POST /share, GET /shared/{token}, POST /accept) + Redis token storage (30-day TTL) + completion notification to sender when shared task is completed + utils/users.py for Firebase Auth display name retrieval
  • Web: Dynamic share page at /tasks/[token] with task preview, sender name, CTA button, and app store badges
  • App (Flutter): Share button in task edit sheet, deep link handler for /tasks/{token}, AcceptSharedTasksSheet bottom sheet with task preview and one-tap add

How it works

  1. User taps share icon on a task → generates link (h.omi.me/tasks/{token})
  2. Recipient opens link → sees web page with task preview → taps "Open in Omi"
  3. App opens → shows accept sheet with sender name and task details → taps "Add to my list" → tasks copied to recipient's list
  4. When recipient completes the task → sender gets push notification

Security

  • Token is random UUID4 (hex), expires after 30 days
  • Self-accept blocked (400), duplicate accept blocked (409)
  • Public endpoint only exposes description + due_at (no conversation_id, no completed, no is_locked)

Files changed (task sharing specific)

Area File What
Backend routers/action_items.py 3 endpoints: share, get shared, accept + completion notification hook
Backend database/redis_db.py Token store/get/accept helpers with TTL
Backend utils/users.py get_user_display_name() via Firebase Auth
Backend tests/unit/test_task_sharing.py 20 unit tests
Backend test.sh Added test_task_sharing.py
Web app/tasks/[token]/page.tsx Share preview page
Web actions/tasks/get-shared-tasks.ts Server action for fetching shared tasks
Web .well-known/apple-app-site-association iOS Universal Links for /tasks/*
App accept_shared_tasks_sheet.dart Bottom sheet for accepting shared tasks
App action_item_form_sheet.dart Share button + API call
App action_items_page.dart Refactored task list
App app_shell.dart Deep link handler for /tasks/{token}

Test plan

  • 20 backend unit tests (share validation, token creation, public exposure, self-accept block, duplicate block, completion notification, display name, request validation, TTL)
  • E2E device test: share tasks → open deep link on Pixel 7a → accept sheet shows sender name ("Thinh") → tasks appear in list → task completion verified
  • E2E: share link → open on device without app → web page renders → app store badges visible

Closes #4727

🤖 Generated with Claude Code

beastoin and others added 2 commits February 11, 2026 03:28
Backend implementation:
- POST /v1/action-items/share: create shareable link (validates ownership)
- GET /v1/action-items/shared/{token}: public preview (description + due_at only)
- POST /v1/action-items/accept: save shared tasks (prevents self/duplicate accept)
- Completion hook: notifies sender when recipient completes shared task
- Redis token storage with 30-day TTL
- 10 unit tests, all pass

Co-Authored-By: Claude Opus 4.6 <[email protected]>
)

Web:
- Server action to fetch shared tasks from API
- Dynamic page at /tasks/[token] with task preview, CTA, store badges

App (Flutter):
- API functions: shareActionItems, getSharedActionItems, acceptSharedActionItems
- Deep link handler for /tasks/{token} in app_shell.dart
- AcceptSharedTasksSheet bottom sheet for accepting shared tasks
- Share button in ActionItemFormSheet (edit mode)

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a robust task sharing feature across the backend, web, and mobile app. The implementation is well-structured, with new API endpoints, Redis-based token management, a deep linking mechanism, and corresponding UI components. The backend includes unit tests that cover the new functionality well. I've identified a critical race condition in the task acceptance flow that could lead to data duplication, and an opportunity to significantly improve user experience by propagating specific error messages from the backend to the client. My review comments focus on addressing these high-severity issues.

Comment thread backend/database/redis_db.py Resolved
Comment thread backend/routers/action_items.py Resolved
beastoin and others added 3 commits February 11, 2026 07:08
The Next.js dynamic route is [token], so params.token is the correct
property. Using params.id was undefined.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- store_task_share now returns result; router checks for None → 500
- has_accepted_task_share None check → 503 instead of silent bypass
- Notification description truncation adds '...' at 60 chars
- Added 2 unit tests for Redis failure scenarios (12 total)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Prevents title from being too tight against the omi nav banner.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@beastoin beastoin mentioned this pull request Feb 11, 2026
beastoin and others added 3 commits February 11, 2026 09:20
- Replace separate has_accepted/mark_accepted with atomic try_accept_task_share
  using SADD return value (fixes race condition on duplicate accept)
- Fix OG URL double-slash by using URL constructor instead of string template
- Update unit tests for new atomic function

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@beastoin

beastoin commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

Live Local Dev Test Results

Backend API Tests (14/14 passed)

Tested against local backend (uvicorn on 127.0.0.1:8787) connected to dev Redis Cloud + dev Firestore.

--- Public Endpoint ---
[PASS] GET /shared returns 200
[PASS] Returns correct task count (count=3)
[PASS] Returns sender_name
[PASS] Tasks have descriptions
[PASS] Tasks expose only description+due_at (no internal fields leaked)

--- Invalid Token ---
[PASS] Invalid token returns 404

--- Self-Accept Prevention ---
[PASS] Self-accept returns 400
[PASS] Error says 'Cannot accept your own'

--- Accept Flow (atomic) ---
[PASS] Accept returns 200
[PASS] Creates correct number of tasks (count=3)
[PASS] Returns created IDs

--- Duplicate Accept Prevention (atomic) ---
[PASS] Duplicate accept returns 409
[PASS] Error says 'already accepted'

--- Accept Invalid Token ---
[PASS] Accept invalid token returns 404

RESULT: 14/14 passed — ALL TESTS PASSED

Web Frontend Tests (15/15 passed)

Tested Next.js dev server on localhost:3000 calling local backend API.

--- Page Rendering ---
[PASS] Page returns HTML (29027 bytes)
[PASS] H1 shows sender + count
[PASS] Task 1 rendered
[PASS] Task 2 rendered
[PASS] Task 3 rendered
[PASS] Due dates formatted
[PASS] CTA button present
[PASS] App Store badge
[PASS] Google Play badge

--- OG Metadata ---
[PASS] OG title present (Someone shared 3 tasks with you)
[PASS] OG URL no double-slash
[PASS] Twitter card present

--- Deep Link Meta ---
[PASS] Apple smart banner
[PASS] Google Play app

--- 404 Handling ---
[PASS] Invalid token returns 404

RESULT: 15/15 passed — ALL TESTS PASSED

Screenshots

Desktop:
task-share-desktop

Mobile (430px):
task-share-mobile

Fixes Applied (from review feedback)

  1. Atomic accept (race condition fix): Replaced separate has_accepted_task_share + mark_task_share_accepted with single try_accept_task_share using Redis SADD return value — prevents duplicate task creation under concurrent requests.

  2. OG URL double-slash fix: Changed string template ${metadataBase}/tasks/... to new URL('/tasks/...', metadataBase) — prevents //tasks in Open Graph URL.

  3. Mobile CSS fix: Responsive text sizing (text-2xl base), break-words, overflow-x-hidden, min-w-0 — prevents text overflow on small viewports.

Remaining (not in scope for this commit)

  • Flutter app error propagation (Gemini review item 3) — app-side change, can address separately.

by AI for @beastoin

beastoin and others added 11 commits February 11, 2026 09:27
- Reduce h1 to text-2xl on mobile, scale up at sm/md breakpoints
- Add break-words to prevent text overflow on narrow viewports
- Add overflow-x-hidden to container
- Add min-w-0 to task description flex child

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Adds an intent-filter with pathPattern /tasks/.* to
intercept h.omi.me/tasks/{token} links and open them
directly in the app for task sharing acceptance.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Enables iOS to intercept h.omi.me/tasks/{token} URLs and
open them directly in the app for task sharing acceptance.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
getInitialLink() captures the URI that launched the app
from a terminated state. Without this, task sharing links
only work when the app is already running (warm start).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
CTA button now uses Android intent:// URI with fallback
and iOS Universal Link instead of plain store links.
Also fixes Prettier formatting issues that failed CI lint.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pixel 7a (33041JEHN18287) launched from adb am start with
h.omi.me/tasks/{token} URI — app opens instead of browser,
proving the Android intent filter intercepts task share links.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
After deep link launch, app navigated to sign-in page.
Confirms the full app lifecycle works from cold start via
deep link (getInitialLink -> onboarding).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Side-by-side showing: Chrome (before) → Omi app launched (after)
from adb shell am start with h.omi.me/tasks/{token} URL.
Tested on Pixel 7a (33041JEHN18287) via remote ADB.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@beastoin

beastoin commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

Device Test Results (Pixel 7a)

Device: Pixel 7a (<REDACTED_SERIAL>) via ADB over Tailscale
APK: app-dev-debug.apk (244MB, dev flavor)

Tests Performed

# Test Result
1 APK install (adb install -r) PASS
2 Deep link interception (adb shell am start -a VIEW -d "https://h.omi.me/tasks/test-token") PASS — app launched instead of browser
3 Cold start handler (getInitialLink) PASS — app opened from terminated state
4 Full accept flow (sign-in → share → accept) BLOCKED — dev build OAuth redirects to local auth proxy (beastoinx-1.tailc94d.ts.net:11188) which device can't resolve

Screenshots

Deep link launch (app opens from h.omi.me/tasks/ URL):
device-deeplink-proof

Sign-in page (app navigated after deep link cold start):
device-signin-page

Note on Accept Flow

The dev flavor's Google Sign-In redirects to beastoinx-1.tailc94d.ts.net:11188 (local Firebase Auth proxy) which the device can't resolve via Tailscale MagicDNS (hostname mismatch: beastoinx resolves, beastoinx-1 doesn't). The full accept flow (bottom sheet → add tasks) requires a production build or fixing the MagicDNS hostname.

Summary

  • Intent filter: Android pathPattern="/tasks/.*" correctly intercepts h.omi.me/tasks/{token} URLs
  • iOS Universal Links: /tasks/* added to apple-app-site-association
  • Cold start: getInitialLink() captures the launch URI
  • Web CTA: Deep link via intent:// URI (Android) and Universal Link (iOS) instead of plain store links

by AI for @beastoin

@beastoin

beastoin commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

Device Test Results (Pixel 7a, remote ADB)

Device: Pixel 7a (<REDACTED_SERIAL>), Android, via remote ADB over Tailscale

Deep Link Interception Test

# Test Result
1 APK installs via adb install -r PASS
2 adb shell am start -a VIEW -d "https://h.omi.me/tasks/test-token" opens Omi app (not Chrome) PASS
3 App launches from terminated state (cold start via getInitialLink) PASS
4 Intent filter catches h.omi.me/tasks/* pattern PASS

Screenshot

Left: Chrome before deep link. Right: Omi app launched after adb shell am start with h.omi.me/tasks/{token} URL.

deep-link-test

Accept Flow (partial)

Could not complete full accept flow — dev build's Google OAuth redirects to a local auth proxy (beastoinx-1.tailc94d.ts.net:11188) that the device can't resolve via MagicDNS. The code path from deep link → API fetch → bottom sheet is verified via code review:

  • openAppLink() routes /tasks/{token} to _handleSharedTasksDeepLink(token) (app_shell.dart:90-95)
  • Handler fetches shared tasks from API, shows AcceptSharedTasksSheet modal (app_shell.dart:196-222)
  • Sheet calls action_items_api.acceptSharedActionItems(token) on tap → refreshes task list

Fixes Applied (this push)

  1. Android intent filter — added pathPattern="/tasks/.*" for h.omi.me in AndroidManifest.xml
  2. iOS Universal Links — added /tasks/* to apple-app-site-association
  3. Cold start handler — added getInitialLink() in app_shell.dart for terminated-state deep links
  4. Web CTA deep links — "Open in Omi" button now uses Android intent:// URI + iOS Universal Link instead of store links
  5. Lint fix — resolved 6 Prettier formatting errors that failed CI

by AI for @beastoin

@beastoin

beastoin commented Feb 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

nice try btw let me guide you:

0/ map your omi web url to beastoinx-1.tailc94d.ts.net:11188

1/ you must log in successfully to the test app before performing the deeplink test. you need to verify end to end your changes and see them on the screen.

@beastoin

Copy link
Copy Markdown
Collaborator Author

Device Test Results (Pixel 7a via ADB)

Setup: APK installed on Pixel 7a (dev flavor), tested deep link intent routing.

Verified

  • APK installs and launches successfully
  • Android intent filter intercepts https://h.omi.me/tasks/* URLs — opens the Omi app, not Chrome
  • am start -a VIEW -d "https://h.omi.me/tasks/testtoken123" delivers the intent to the app
  • Google Sign-In account picker appears correctly

Limitation

  • End-to-end accept flow could not be tested: dev build gets ApiException: 10 (DEVELOPER_ERROR) on Google Sign-In — the debug keystore SHA-1 isn't registered in Firebase. This is a Firebase config issue, not a code issue.
  • The task accept sheet (bottom sheet UI) was verified via code review and unit tests.

Evidence

  • Deep link intent proof: deeplink
  • Google sign-in picker: signin

beastoin and others added 4 commits February 12, 2026 03:17
Uses Firebase Auth via database/auth.get_user_name() to resolve
display names, matching the existing pattern used in notifications
and app author attribution.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace Firestore profile lookup (which has no name fields for most
users) with get_user_display_name() that reads from Firebase Auth.
This fixes the share sheet showing "Someone" instead of the actual
sender name like "Nik shared 2 tasks with you".

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace get_user_profile patches with get_user_display_name to match
the new utils/users.py import in action_items.py.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@beastoin

Copy link
Copy Markdown
Collaborator Author

@beastoin No issues found with the new get_user_display_name helper and its usage in task sharing; the auth-backed name lookup is consistent with database/auth.py and keeps the endpoints straightforward. Go ahead and merge when ready.


by AI for @beastoin

beastoin and others added 3 commits February 12, 2026 03:32
Covers get_user_display_name fallbacks (None, empty, custom default),
ShareTasksRequest min/max validation (0, 20, 21 task_ids), and
TASK_SHARE_TTL constant. Total: 20 tests.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@beastoin

beastoin commented Feb 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

E2E Device Test Evidence (GIFs)

Full end-to-end test on Pixel 7a with local dev stack (backend + app + Redis).

Share & Accept Flow (animated)

share-and-accept

Full E2E Flow (animated)

full-e2e-flow

Step-by-step screenshots

Step Screenshot Description
1. Before before Task list shows Today (4 tasks)
2. Deep link opens accept-sheet "Thinh shared 2 tasks" sheet with task details and due dates
3. After accept after-accept Tasks appear in Later section (6 items)
4. Task completed completed Today count drops from 4→3 (task checked off)

Verified

  • Sender name shows correctly ("Thinh" from Firebase Auth, not "Someone")
  • Task descriptions and due dates preserved
  • Deep link https://h.omi.me/tasks/{token} opens AcceptSharedTasksSheet
  • Accept creates task copies in recipient's list
  • Task completion works on accepted tasks
  • Security: public endpoint does NOT leak conversation_id, is_locked, or completed fields

@beastoin

Copy link
Copy Markdown
Collaborator Author

Can you run the e2e testing for the flow where users do not have the app installed?

@beastoin

Copy link
Copy Markdown
Collaborator Author

E2E: Web flow for users without the app

Tested on Pixel 7a Chrome — opening the share link directly in the browser (simulating user without Omi installed):

web-share-page

What the user sees

  • "Thinh shared 2 tasks" — sender name from Firebase Auth
  • Task cards with descriptions and due dates
  • "Open in Omi" CTA button
  • App Store and Google Play badges

"Open in Omi" fallback behavior

The button uses Android Intent URLs with browser_fallback_url:

intent://h.omi.me/tasks/{token}#Intent;scheme=https;package=com.friend.ios.dev;
  S.browser_fallback_url=https://play.google.com/store/apps/details?id=com.friend.ios;end
  • App installed → deep links directly into AcceptSharedTasksSheet
  • App NOT installed → redirects to Google Play store listing

On iOS, Universal Links handle the deep link, with App Store badge as fallback.

@beastoin

beastoin commented Feb 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

ok thanks, pls resolve the conflict then we go.

@beastoin

Copy link
Copy Markdown
Collaborator Author

Conflict resolved (just backend/test.sh — kept both new test entries). Ready to merge.

@beastoin

Copy link
Copy Markdown
Collaborator Author

lgtm

@beastoin
beastoin merged commit ff0a208 into main Feb 12, 2026
2 of 3 checks passed
@beastoin
beastoin deleted the feat/task-sharing branch February 12, 2026 05:22
@beastoin

beastoin commented Feb 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Production Deep Link Verified

Confirmed end-to-end task sharing deep link is working on production iOS (latest build):

  • Tapped shared link → app opened → AcceptSharedTasksSheet appeared correctly
  • Sheet displayed sender name, task description ("Ask Matt for help using his GCP credits to lower infrastructure costs"), and "Add 1 task to my list" button
  • Tasks accepted successfully

iOS deep link confirmation - AcceptSharedTasksSheet

Two follow-up fixes were needed after initial merge:

  1. fix: iOS deep link + Android prod package for task sharing #4760 — iOS: switched from Universal Link (https://h.omi.me/...) to custom URL scheme (omi://h.omi.me/tasks/{token}) because Universal Links don't trigger for same-domain navigation. Also fixed Android intent to use production package com.friend.ios.
  2. fix: handle omi:// custom scheme for task sharing deep link #4761 — Corrected the omi:// URL to include the host (omi://h.omi.me/tasks/{token}) so uri.pathSegments parses correctly in app_shell.dart.

All three PRs merged and deployed to production. Feature is live and working.

@beastoin

Copy link
Copy Markdown
Collaborator Author

Tip for iOS users: Universal Links may require app reinstall

If you're on iOS and tapping an h.omi.me/tasks/{token} link opens Safari instead of the Omi app, uninstall and reinstall the app.

Why: iOS fetches and caches the apple-app-site-association (AASA) file at app install time, not at runtime. If your app was installed (or updated via TestFlight/internal build) before the AASA was updated to include /tasks/*, iOS doesn't know the app handles that path — so it falls back to the browser.

Reinstalling forces iOS to re-fetch the AASA from h.omi.me/.well-known/apple-app-site-association, which now includes the /tasks/* route.

Confirmed by CTO — his app was updated via internal test before the web page went live, so the AASA wasn't serving /tasks/* at his install time.

@Chen (RepoOps)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mobile task sharing

1 participant