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
4 changes: 4 additions & 0 deletions FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ migrations after upstream migrations.

101. Mobile has a J5 Inbox screen ([#830](https://github.com/Jacksondr5/j5code/issues/830)), landing the reserved Route registration seam for it. `apps/mobile/src/Stack.tsx` imports J5-owned `j5InboxRoutes` (`apps/mobile/src/j5/inbox/routes.ts`) and spreads it before `SETTINGS_SCREENS`, adding a root `Inbox` screen at `inbox` (`apps/mobile/src/j5/inbox/InboxScreen.tsx`). It reads every connected server's open and answered asks through J5-owned source atoms (`apps/mobile/src/j5/inbox/inboxSources.ts`, built as web's are, with `writesNowhere` for a person who can answer nothing), merges and orders them with `client-runtime/src/j5/inbox.ts`, and shows an older server's source notice. It rereads when it comes into view and on the server's inbox revision, with no timer. On a pin advance: if upstream reshapes `Stack.tsx`'s root screens, spread `j5InboxRoutes` among them again.

102. Mobile's thread list has an Inbox bell with the open count ([#830](https://github.com/Jacksondr5/j5code/issues/830)), as web's rail does. J5-owned `apps/mobile/src/j5/inbox/InboxBell.tsx` reads every connected server's open count (`inboxCountSourcesAtom`, case 101), says it through `inboxBellPresentation` (`packages/client-runtime/src/j5/inbox.ts`, shared with web's bell), and opens the `Inbox` screen. It counts open asks only; web's also counts Crew requests and seat approvals, which come to mobile with Crews. Two headers mount it, each with one import and one or two lines: `apps/mobile/src/features/home/ThreadListToolbar.tsx` (Android) adds it beside `filterButton` in the toolbar row's `filter` slot when a server is saved, and `apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx` adds it as a `Toolbar.Custom` in the right toolbar of the thread list on iPhone and iPad alike (iOS draws its sidebar's header natively, through this toolbar). Android's split view draws its sidebar header with the same `ThreadListToolbar`, so it gets the bell there; no other header holds the thread list's filter. Upstream's symbol set has no plain bell on Android, so J5's `BellGlyph` draws Tabler's there and the SF Symbol on iOS. On a pin advance: if upstream moves the thread list's filter, move the bell with it.

## Pin and upstream advance runbook

Current pin: `d2c440312e5f39d59827ed466838a623516454d6`, upstream's stable release tag `v0.1.3` on `main` (frozen 2026-10-27). The previous pin was `70d60e03a7a35c6fa131825bbfa05ec893e69912`, upstream's nightly tag `v0.1.1-nightly.20261017.3238`.
Expand Down Expand Up @@ -737,6 +739,8 @@ explicitly marked.
| `apps/mobile/src/features/settings/components/SettingsScreen.tsx` | N | 72 |
| `apps/mobile/src/features/settings/settings-environment-filter.tsx` | N | 72 |
| `apps/mobile/src/Stack.tsx` | A | 72, 98, 101, Role library |
| `apps/mobile/src/features/home/ThreadListToolbar.tsx` | N | 102 |
| `apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx` | N | 102 |
| `apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx` | N | 72 |
| `apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx` | N | 90 |
| `apps/mobile/src/features/threads/ThreadFeed.tsx` | N | 90 |
Expand Down
9 changes: 8 additions & 1 deletion apps/mobile/src/features/home/ThreadListToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands
import { WorkspaceListToolbarRow } from "../workspace/WorkspaceListToolbarRow";
import { useWorkspaceConnectionState } from "../../state/workspace";
import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
import { InboxBell } from "../../j5/inbox/InboxBell";

export function ThreadListToolbar(props: {
readonly searchQuery: string;
Expand Down Expand Up @@ -113,7 +114,13 @@ export function ThreadListToolbar(props: {
searchAccessibilityLabel="Search threads"
titleAccessibilityLabel="J5 Code, Threads"
onOpenEnvironments={props.onOpenEnvironments}
filter={filterButton}
// J5: the Inbox bell beside the filter (FORK.md case 102).
filter={
<>
{filterButton}
{connectionState.hasConnections ? <InboxBell /> : null}
</>
}
/>
</View>
);
Expand Down
7 changes: 7 additions & 0 deletions apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { SearchBarCommands } from "react-native-screens";

import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
import { NativeStackScreenOptions } from "../../native/StackHeader";
import { InboxBell } from "../../j5/inbox/InboxBell";
import {
NativePrimaryColumnContext,
NativeWorkspaceTabActivityContext,
Expand Down Expand Up @@ -189,6 +190,12 @@ export function WorkspaceToolbar(props: {
{workspace.settingsOpen && !foldedSearch ? null : (
<Toolbar placement="right">
{searchButton}
{/* J5: the Inbox bell on the thread list, iPhone and iPad alike (case 102). */}
{selectedTab === "threads" ? (
<Toolbar.Custom>
<InboxBell />
</Toolbar.Custom>
) : null}
{nativeToolbarCompose && foldedSearch ? <Toolbar.Spacer width={8} /> : null}
{composeButton}
{selectedTab !== "threads" ||
Expand Down
9 changes: 9 additions & 0 deletions apps/mobile/src/j5/inbox/BellGlyph.ios.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { SymbolView } from "expo-symbols";
import type { ColorValue } from "react-native";
import { withUniwind } from "uniwind";

function Bell(props: { readonly size: number; readonly tintColor?: ColorValue }) {
return <SymbolView name="bell" size={props.size} tintColor={props.tintColor} type="monochrome" />;
}

export const BellGlyph = withUniwind(Bell);
10 changes: 10 additions & 0 deletions apps/mobile/src/j5/inbox/BellGlyph.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import IconBell from "@tabler/icons-react-native/IconBell";
import type { ColorValue } from "react-native";
import { withUniwind } from "uniwind";

// Upstream's symbol set has no plain bell on Android, so the Inbox draws its own.
function Bell(props: { readonly size: number; readonly tintColor?: ColorValue }) {
return <IconBell size={props.size} color={props.tintColor} strokeWidth={2} />;
}

export const BellGlyph = withUniwind(Bell);
39 changes: 39 additions & 0 deletions apps/mobile/src/j5/inbox/InboxBell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useAtomValue } from "@effect/atom-react";
import { inboxBellPresentation, mergeOpenInboxCounts } from "@t3tools/client-runtime/j5/inbox";
import { useNavigation } from "@react-navigation/native";
import { Pressable, View } from "react-native";

import { AppText as Text } from "../../components/ui/AppText";
import { BellGlyph } from "./BellGlyph";
import { inboxCountSourcesAtom } from "./inboxSources";

/**
* The Inbox bell in the thread list's header, with the open count across every connected server.
* It counts open asks only: Crew requests and seat approvals join it with Crews on mobile.
*/
export function InboxBell() {
const navigation = useNavigation();
const sources = useAtomValue(inboxCountSourcesAtom);
const { badge, label } = inboxBellPresentation(mergeOpenInboxCounts(sources));
return (
<Pressable
accessibilityRole="button"
accessibilityLabel={label}
hitSlop={4}
onPress={() => navigation.navigate("Inbox")}
className="size-12 items-center justify-center active:opacity-70"
>
<BellGlyph size={22} tintColorClassName="accent-header-foreground" />
{badge === null ? null : (
<View
pointerEvents="none"
className="absolute right-1 top-1 min-w-4 items-center justify-center rounded-full bg-primary px-1"
>
<Text className="text-[10px] font-t3-semibold leading-4 text-primary-foreground">
{badge}
</Text>
</View>
)}
</Pressable>
);
}
5 changes: 5 additions & 0 deletions apps/mobile/src/j5/inbox/inboxSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export const answeredInboxSourcesAtom = createJ5ReadSourcesAtom({
label: "mobile-j5:inbox-answered-sources",
queryAtom: answeredInboxQueryAtom,
});
export const inboxCountSourcesAtom = createJ5ReadSourcesAtom({
...sourcesInput,
label: "mobile-j5:inbox-count-sources",
queryAtom: inboxCountQueryAtom,
});

/**
* Reads each connected server's source again, as the Inbox screen does when it comes into view.
Expand Down
12 changes: 12 additions & 0 deletions apps/mobile/src/j5/upstreamSeams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ const SEAMS: ReadonlyArray<Seam> = [
from: "./j5/inbox/routes",
reaches: ["...j5InboxRoutes(GLASS_HEADER_OPTIONS)"],
},
{
file: "features/home/ThreadListToolbar.tsx",
record: "case 102: the Inbox bell",
from: "../../j5/inbox/InboxBell",
reaches: ["<InboxBell />"],
},
{
file: "features/workspace/WorkspaceToolbar.ios.tsx",
record: "case 102: the Inbox bell",
from: "../../j5/inbox/InboxBell",
reaches: ["<InboxBell />"],
},
{
file: "App.tsx",
record: "case 21: archive preflight",
Expand Down
9 changes: 0 additions & 9 deletions apps/web/src/j5/a2a/HumanInboxBell.test.ts

This file was deleted.

10 changes: 4 additions & 6 deletions apps/web/src/j5/a2a/HumanInboxBell.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link } from "@tanstack/react-router";
import { InboxIcon } from "lucide-react";
import { useAtomValue } from "@effect/atom-react";
import { mergeOpenInboxCounts } from "@t3tools/client-runtime/j5/inbox";
import { inboxBellPresentation, mergeOpenInboxCounts } from "@t3tools/client-runtime/j5/inbox";

import { useSidebar } from "../../components/ui/sidebar";
import { cn } from "../../lib/utils";
Expand All @@ -22,8 +22,6 @@ const useCountRefresh = createVisibleRefreshHook(() => {
void refreshJ5Sources(inboxCountSourcesAtom, inboxCountQueryAtom);
});

export const shouldShowOpenInboxCount = (count: number | null) => count !== null && count > 0;

export function HumanInboxBell({ onBackdrop }: { readonly onBackdrop: boolean }) {
const { isMobile, setOpenMobile } = useSidebar();
const sources = useAtomValue(inboxCountSourcesAtom);
Expand All @@ -49,7 +47,7 @@ export function HumanInboxBell({ onBackdrop }: { readonly onBackdrop: boolean })
if (isMobile) setOpenMobile(false);
};

const label = `${count === null ? "Open inbox" : `Open inbox, ${incomplete ? "last known " : ""}${count} open`}${incomplete ? "; some environments could not be refreshed" : ""}`;
const { badge, label } = inboxBellPresentation({ count, incomplete });
return (
<Link
aria-label={label}
Expand All @@ -64,9 +62,9 @@ export function HumanInboxBell({ onBackdrop }: { readonly onBackdrop: boolean })
to="/inbox"
>
<InboxIcon aria-hidden className="size-4" />
{shouldShowOpenInboxCount(count) || incomplete ? (
{badge !== null ? (
<span className="absolute -end-1 -top-1 flex min-h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-3xs font-semibold leading-none text-primary-foreground tabular-nums ring-2 ring-sidebar">
{incomplete ? (count !== null && count > 0 ? `${count}*` : "?") : count}
{badge}
</span>
) : null}
</Link>
Expand Down
23 changes: 23 additions & 0 deletions packages/client-runtime/src/j5/inbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { J5ReadSource } from "./readSources.ts";
import {
answeredByLine,
closedLine,
inboxBellPresentation,
mergeHumanInboxSources,
mergeOpenInboxCounts,
nextKeptItems,
Expand Down Expand Up @@ -378,3 +379,25 @@ describe("who has an inbox", () => {
expect(writesNowhere(null)).toBe(false);
});
});

describe("what the inbox bell says", () => {
it("shows the open count, and nothing when none is open", () => {
expect(inboxBellPresentation({ count: 3, incomplete: false })).toEqual({
badge: "3",
label: "Open inbox, 3 open",
});
expect(inboxBellPresentation({ count: 0, incomplete: false }).badge).toBeNull();
expect(inboxBellPresentation({ count: null, incomplete: false })).toEqual({
badge: null,
label: "Open inbox",
});
});

it("marks a count some server could not refresh", () => {
expect(inboxBellPresentation({ count: 2, incomplete: true })).toEqual({
badge: "2*",
label: "Open inbox, last known 2 open; some environments could not be refreshed",
});
expect(inboxBellPresentation({ count: null, incomplete: true }).badge).toBe("?");
});
});
20 changes: 20 additions & 0 deletions packages/client-runtime/src/j5/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ export function mergeOpenInboxCounts(
};
}

/**
* What an inbox bell says: its badge, if any, and its spoken label. A count some server could not
* refresh is marked: `3*` when it is a last-known count, `?` when nothing is known.
*/
export function inboxBellPresentation(input: {
readonly count: number | null;
readonly incomplete: boolean;
}): { readonly badge: string | null; readonly label: string } {
const { count, incomplete } = input;
const badge = incomplete
? count !== null && count > 0
? `${count}*`
: "?"
: count !== null && count > 0
? String(count)
: null;
const label = `${count === null ? "Open inbox" : `Open inbox, ${incomplete ? "last known " : ""}${count} open`}${incomplete ? "; some environments could not be refreshed" : ""}`;
return { badge, label };
}

export function j5SourceNotice(source: J5ReadSource<unknown>): string | null {
switch (source.status) {
case "ready":
Expand Down
Loading