Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ src/auth/ session store, auth context, deep-link capture
src/team/ team context, switcher, creation, invitations
src/board/ board and list views, filters, drag-to-move
src/issues/ priority and status metadata
src/offline/ connectivity, cache persistence, the mutation queue
src/ui/ design tokens, theme, primitives, navigation chrome
openapi/ the vendored API contract codegen reads
```
Expand Down Expand Up @@ -97,11 +98,12 @@ The mockups reuse the web app's design tokens (brand `#6342db`, tinted neutrals,

## Status

Onboarding works end to end: sign in to any instance, register, accept an
invitation, create and switch teams, and work a team's board -- columns from the
team's own statuses, six server-side filters held in the URL, board and list
views, and drag or tap to move a card. Search and Inbox are placeholders
pointing at their issues.
Every tracked issue is implemented except push notifications, which have no
backend to talk to. Sign in to any instance, register, accept invitations,
manage teams, work a board, create and edit issues with sub-issues and links,
comment in GitHub-flavored markdown, attach photos and files, search, run cycles,
read the four reports, save views, administer a team or the whole instance, and
keep working with no connection.

Known gaps, tracked rather than hidden:

Expand All @@ -125,6 +127,9 @@ Known gaps, tracked rather than hidden:
- **Member counts cost one request per team.** `TeamRead` carries no count, so
the teams list asks each team for its members. A `member_count` field upstream
would remove the fan-out and help the web too.
- **Offline is verified as logic, not as behaviour.** The queue, the conflict
rule and the cache are covered by tests, but nobody has watched a phone lose
signal, move a card and come back. That needs a device.
- **No aurora or glass blur yet.** The web's translucent panels are approximated
with opaque surfaces; `backdrop-filter` has no React Native equivalent and
per-surface blur is expensive on Android.
57 changes: 57 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
},
"dependencies": {
"@react-native-async-storage/async-storage": "2.2.0",
"@react-native-community/netinfo": "12.0.1",
"@tanstack/query-async-storage-persister": "^5.102.8",
"@tanstack/react-query": "^5.102.8",
"@tanstack/react-query-persist-client": "^5.102.8",
"axios": "^1.20.0",
"expo": "~57.0.22",
"expo-blur": "~57.0.3",
Expand Down
6 changes: 4 additions & 2 deletions src/api/__tests__/live-notifications.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import {
unreadCountNotificationsUnreadCountGet,
updateNotificationNotificationsNotificationIdPatch,
} from '@/api/generated/endpoints/notifications/notifications';
import { createInviteTeamsTeamIdInvitesPost } from '@/api/generated/endpoints/invites/invites';
import { acceptInviteInvitesTokenAcceptPost } from '@/api/generated/endpoints/invites/invites';
import {
acceptInviteInvitesTokenAcceptPost,
createInviteTeamsTeamIdInvitesPost,
} from '@/api/generated/endpoints/invites/invites';
import { listMyTeamsTeamsGet } from '@/api/generated/endpoints/teams/teams';
import type { TeamRead } from '@/api/generated/models';
import { setInstanceUrl } from '@/api/instance';
Expand Down
4 changes: 4 additions & 0 deletions src/api/query-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export const queryClient = new QueryClient({
queries: {
retry: 1,
refetchOnWindowFocus: false,
// Long enough that a persisted cache is still served after a restart --
// without it everything would be discarded as stale on the way in, which
// is exactly the case offline reading exists for.
gcTime: 7 * 24 * 60 * 60 * 1000,
},
},
});
22 changes: 19 additions & 3 deletions src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import { Stack } from 'expo-router';
import * as SplashScreen from 'expo-splash-screen';
import * as SystemUI from 'expo-system-ui';
import { StatusBar } from 'expo-status-bar';
import { QueryClientProvider } from '@tanstack/react-query';
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client';

import { hydrateInstanceUrl } from '@/api/instance';
import { queryClient } from '@/api/query-client';
import { startConnectivityWatch } from '@/offline/connectivity';
import { MAX_AGE_MS, persister } from '@/offline/persistence';
import { registerQueuedMutations } from '@/offline/queue';
import { AuthProvider, useAuth } from '@/auth/auth-context';
import { hydrateSession } from '@/auth/session';
import { useDeepLinkCapture } from '@/auth/use-deep-link-capture';
Expand Down Expand Up @@ -149,6 +152,13 @@ function Gate() {
export default function RootLayout() {
const [hydrated, setHydrated] = useState<Hydrated | null>(null);

useEffect(() => {
// Mutation functions have to be registered by key before a persisted queue
// is restored, or a paused mutation comes back as data with nothing to run.
registerQueuedMutations(queryClient);
return startConnectivityWatch();
}, []);

useEffect(() => {
// One pass over persisted state before anything renders: the stored theme,
// the instance URL, and the token -- each into its module-level mirror so
Expand All @@ -173,13 +183,19 @@ export default function RootLayout() {
<GestureHandlerRootView style={{ flex: 1 }}>
<SafeAreaProvider>
<Themed>
<QueryClientProvider client={queryClient}>
<PersistQueryClientProvider
client={queryClient}
persistOptions={{ persister, maxAge: MAX_AGE_MS }}
// Anything queued while offline is replayed here, once the
// restored cache is back in place.
onSuccess={() => void queryClient.resumePausedMutations()}
>
<AuthProvider>
<TeamProvider initialTeamKey={hydrated.teamKey}>
<Gate />
</TeamProvider>
</AuthProvider>
</QueryClientProvider>
</PersistQueryClientProvider>
</Themed>
</SafeAreaProvider>
</GestureHandlerRootView>
Expand Down
6 changes: 6 additions & 0 deletions src/board/board-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { KanbanBoard } from '@/board/kanban-board';
import { useStatusChange } from '@/board/use-status-change';
import { CycleBanner, CyclesSheet } from '@/cycles/cycles-screen';
import { ReportsSheet } from '@/reports/reports-sheet';
import { OfflineBanner, SyncQueueSheet } from '@/offline/sync-status';
import { useListViewsTeamsTeamIdViewsGet } from '@/api/generated/endpoints/views/views';
import { useAuth } from '@/auth/auth-context';
import { fromViewFilters } from '@/views/saved-views';
Expand Down Expand Up @@ -58,6 +59,7 @@ export function BoardScreen() {
const [viewsOpen, setViewsOpen] = useState(false);
const [cyclesOpen, setCyclesOpen] = useState(false);
const [reportsOpen, setReportsOpen] = useState(false);
const [syncOpen, setSyncOpen] = useState(false);
const [switching, setSwitching] = useState(false);
const [creating, setCreating] = useState(false);
const [moving, setMoving] = useState<IssueRead | null>(null);
Expand Down Expand Up @@ -213,6 +215,8 @@ export function BoardScreen() {
</Pressable>
</View>

<OfflineBanner onOpenQueue={() => setSyncOpen(true)} />

<CycleBanner team={team} onOpen={() => setCyclesOpen(true)} />

<FilterChips chips={chips} onAdd={() => setFilterOpen(true)} />
Expand All @@ -235,6 +239,8 @@ export function BoardScreen() {
/>
)}

<SyncQueueSheet visible={syncOpen} onClose={() => setSyncOpen(false)} />

<ReportsSheet
visible={reportsOpen}
onClose={() => setReportsOpen(false)}
Expand Down
31 changes: 24 additions & 7 deletions src/board/use-status-change.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useCallback } from 'react';
import { useQueryClient } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';

import {
getListIssuesTeamsTeamIdIssuesGetQueryKey,
updateIssueIssuesIssueIdPatch,
} from '@/api/generated/endpoints/issues/issues';
import { getListIssuesTeamsTeamIdIssuesGetQueryKey } from '@/api/generated/endpoints/issues/issues';
import { QUEUED, type MoveIssueVariables } from '@/offline/queue';
import type {
ListIssuesTeamsTeamIdIssuesGetParams,
PageIssueRead,
Expand All @@ -22,12 +20,20 @@ import type {
*
* `params` has to match what the board is showing, because it is part of the
* query key being patched.
*
* The write itself goes through a keyed mutation rather than a bare call, so
* React Query pauses it when there is no network and replays it on reconnect --
* a card moved on a train stays moved, and reaches the server when the train
* comes out of the tunnel.
*/
export function useStatusChange(
team: TeamRead | undefined,
params: ListIssuesTeamsTeamIdIssuesGetParams,
) {
const queryClient = useQueryClient();
const move = useMutation<unknown, Error, MoveIssueVariables>({
mutationKey: QUEUED.moveIssue,
});

return useCallback(
async (issueId: number, status: StatusRead): Promise<boolean> => {
Expand All @@ -47,19 +53,30 @@ export function useStatusChange(
: old,
);

const before = previous?.items.find((item) => item.id === issueId);

try {
await updateIssueIssuesIssueIdPatch(issueId, { status_id: status.id });
await move.mutateAsync({
issueId,
status,
// Captured now so a replay can tell "nothing moved" from "somebody
// else moved it while we were away".
seenAt: before?.updated_at ?? '',
identifier: before?.identifier ?? `#${issueId}`,
});
// Moving a card moves its points between columns, and may close out a
// cycle's remaining work.
void queryClient.invalidateQueries({ queryKey: [`/teams/${team.id}/estimates`] });
void queryClient.invalidateQueries({ queryKey: [`/teams/${team.id}/cycles`] });
void queryClient.invalidateQueries({ queryKey: [`/issues/${issueId}`] });
return true;
} catch {
// A paused mutation does not reject, so reaching here means it was
// genuinely refused -- put the card back where it was.
queryClient.setQueryData(queryKey, previous);
return false;
}
},
[queryClient, team, params],
[queryClient, team, params, move],
);
}
Loading
Loading