Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7387347
feat(kin): canvas contract
Surajsm60720 Nov 18, 2026
01a6cc9
feat(kin): shared canvas model, layout, lens and live stream
Surajsm60720 Nov 18, 2026
ce993ab
feat(kin): canvas on web and desktop
Surajsm60720 Nov 18, 2026
511f311
feat(kin): canvas in the feature map
Surajsm60720 Nov 18, 2026
e0f657f
feat(kin): canvas server: places, widgets, since and agent activity
Surajsm60720 Nov 18, 2026
2f21335
feat(mobile): Kin canvas on iOS and Android
Surajsm60720 Nov 18, 2026
bc8ace5
fix(kin): the pushed canvas page in the feature map
Surajsm60720 Nov 18, 2026
a56317c
fix(kin): canvas fixes from the first web pass
Surajsm60720 Nov 18, 2026
ba47e0c
fix(kin): canvas fixes from review and the phone pass
Surajsm60720 Nov 18, 2026
88f4e82
fix(kin): a first drag pins every card, and countdowns open their source
Surajsm60720 Nov 18, 2026
1396a5e
Merge origin/kin into t3/kin-canvas
Surajsm60720 Nov 23, 2026
89e9d00
refactor(kin): the canvas reads only what Work and Docs already send
Surajsm60720 Nov 23, 2026
70f14fd
feat(kin): Docs has a Map view of what is being worked on, on web and…
Surajsm60720 Nov 23, 2026
2d76917
fix(kin): map copy in one place, camera helpers kept private
Surajsm60720 Nov 23, 2026
8af4529
fix(kin): the Docs map keeps its cards while it reloads and says what…
Surajsm60720 Nov 23, 2026
0d81c3b
fix(kin): the Docs map stays smooth and legible with hundreds of cards
Surajsm60720 Nov 23, 2026
f2e1a71
Merge origin/kin into t3/kin-canvas
Surajsm60720 Nov 25, 2026
339f3a2
fix(kin): the Docs map reads tasks through runKinCommand
Surajsm60720 Nov 25, 2026
04f1ce0
fix(kin): a double tap on a map card no longer zooms past its peek
Surajsm60720 Nov 25, 2026
20bd58a
Merge origin/kin into t3/kin-canvas
Surajsm60720 Nov 26, 2026
f45abe1
fix(kin): web Back returns the Docs map to the same spot and zoom
Surajsm60720 Nov 27, 2026
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
3 changes: 2 additions & 1 deletion apps/mobile/src/components/ui/AppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ export function AppBar(props: AppBarProps) {
onCancelButtonPress: () => reportSearchText(""),
},
}
: undefined),
: // Options merge: a bar without search on a screen that had one must clear it.
{ headerSearchBarOptions: undefined }),
}}
/>
{props.onClose ? (
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/components/ui/AppSymbol.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import IconMicrophone from "@tabler/icons-react-native/IconMicrophone";
import IconLink from "@tabler/icons-react-native/IconLink";
import IconMail from "@tabler/icons-react-native/IconMail";
import IconList from "@tabler/icons-react-native/IconList";
import IconMap from "@tabler/icons-react-native/IconMap";
import IconListNumbers from "@tabler/icons-react-native/IconListNumbers";
import IconMenu2 from "@tabler/icons-react-native/IconMenu2";
import IconMessageCircleQuestion from "@tabler/icons-react-native/IconMessageCircleQuestion";
Expand Down Expand Up @@ -248,6 +249,7 @@ const ANDROID_ICON_BY_SF_SYMBOL = {
envelope: IconMail,
phone: IconPhone,
"list.bullet": IconList,
map: IconMap,
"list.number": IconListNumbers,
"line.3.horizontal": IconMenu2,
"line.3.horizontal.decrease": IconFilter,
Expand Down
20 changes: 12 additions & 8 deletions apps/mobile/src/features/chats/KinDocsList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { KinViewerScope } from "@t3tools/client-runtime/kin/kinViewerScope";
import { kinNothingShown } from "@t3tools/client-runtime/kin/kinViewerScope";
import { kinDocsViewAction } from "./KinDocsMap";
import { useKinViewerScope } from "./state/kinChatOnly";
import { KIN_MORE_FAILED, KIN_RETRY, kinFailureText } from "@t3tools/client-runtime/kin/kinAnswers";
import { LegendList } from "@legendapp/list/react-native";
Expand Down Expand Up @@ -506,6 +507,8 @@ export function KinDocsList(
readonly live: KinWorkLive;
readonly directory: KinWorkDirectory;
readonly stale: boolean;
/** Shows Docs as the map instead; absent where the list stands alone. */
readonly onMap?: () => void;
},
) {
const navigation = useNavigation();
Expand Down Expand Up @@ -662,22 +665,23 @@ export function KinDocsList(
<AppBar
title={KIN_WORK_HOME.places.docs}
refresh={{ accessibilityLabel: "Refresh", onPress: refresh }}
{...(agent === null
? {}
: {
actions: [
actions={[
...(props.onMap === undefined ? [] : [kinDocsViewAction("list", props.onMap)]),
...(agent === null
? []
: [
{
accessibilityLabel: `Ask ${agent.name}`,
icon: "bubble.left",
icon: "bubble.left" as const,
onPress: () => agent.ask(kinWorkAskDraft("docs")),
},
{
accessibilityLabel: KIN_LISTS.ask,
icon: "plus",
icon: "plus" as const,
onPress: () => agent.ask(KIN_LISTS.askMessage),
},
],
})}
]),
]}
{...(refused
? {}
: {
Expand Down
238 changes: 238 additions & 0 deletions apps/mobile/src/features/chats/KinDocsMap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
import { kinCanvasFit, type KinCanvasCamera } from "@t3tools/client-runtime/kin/kinCanvasCamera";
import { kinCanvasLayout } from "@t3tools/client-runtime/kin/kinCanvasLayout";
import {
KIN_CANVAS,
kinCanvasHeadline,
type KinCanvasCardView,
} from "@t3tools/client-runtime/kin/kinCanvasView";
import { KIN_RETRY } from "@t3tools/client-runtime/kin/kinAnswers";
import { KIN_WORK_HOME } from "@t3tools/client-runtime/kin/kinWorkHome";
import { useEffect, useState } from "react";
import { View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";

import { AppBar } from "../../components/ui/AppBar";
import { AppText as Text } from "../../components/ui/AppText";
import { Button } from "../../components/ui/Button";
import { EmptyState } from "../../components/ui/EmptyState";
import { useBarOverlap } from "../../components/ui/useBarInset";
import { useReduceMotionEnabled } from "../../lib/appState";
import { KinCanvasBoard } from "./canvas/KinCanvasBoard";
import {
KinCanvasPartial,
KinCanvasShowSwitch,
KinCanvasZoomControls,
} from "./canvas/KinCanvasOverlays";
import { KinCanvasPeek } from "./canvas/KinCanvasPeek";
import { useCanvasCamera } from "./canvas/useCanvasCamera";
import { KinWorkLoading } from "./components/KinWorkPieces";
import { useKinTab } from "./components/KinTab";
import { useKinWorkLink } from "./state/kinWorkLink";
import { useKinCanvas } from "./state/useKinCanvas";
import type { KinWorkTarget } from "./state/useKinWork";

/** The bar's switch between Docs' two views. */
export function kinDocsViewAction(view: "list" | "map", onPress: () => void) {
return view === "list"
? { accessibilityLabel: `Show ${KIN_CANVAS.title}`, icon: "map" as const, onPress }
: { accessibilityLabel: `Show ${KIN_CANVAS.list}`, icon: "list.bullet" as const, onPress };
}

/**
* Docs as a map: every project an area with its tasks in progress and its docs, zoomed like a
* map. Close in, a doc shows its text on the card; a tap reads it over the map.
*/
export function KinDocsMap(props: KinWorkTarget & { readonly onList: () => void }) {
const target = { environmentId: props.environmentId, orgId: props.orgId };
const data = useKinCanvas(target);
const tab = useKinTab();
const bar = (
<AppBar title={KIN_WORK_HOME.places.docs} actions={[kinDocsViewAction("map", props.onList)]} />
);
const message = (body: React.ReactNode) => (
<View collapsable={false} className="flex-1 bg-screen">
{bar}
<View
className="flex-1 justify-center p-4"
style={{ paddingBottom: tab?.bottomClearance ?? 0 }}
>
{body}
</View>
</View>
);
if (data.status === "offline")
return message(
<EmptyState
variant="plain"
title={KIN_CANVAS.offlineTitle}
detail={KIN_CANVAS.offlineDetail}
/>,
);
if (data.status === "refused")
return message(
<EmptyState
variant="plain"
title={KIN_CANVAS.refusedTitle}
detail={KIN_CANVAS.refusedDetail}
/>,
);
if (data.status === "failed")
return message(
<EmptyState
variant="plain"
title={KIN_CANVAS.loadFailed}
detail={KIN_CANVAS.loadFailedDetail}
action={<Button tone="secondary" label={KIN_RETRY} onPress={data.retry} />}
/>,
);
if (data.status === "loading") return message(<KinWorkLoading label={KIN_CANVAS.loading} />);
return <KinDocsMapReady {...target} data={data} bar={bar} />;
}

function KinDocsMapReady(
props: KinWorkTarget & {
readonly data: ReturnType<typeof useKinCanvas>;
readonly bar: React.ReactNode;
},
) {
const { data, environmentId, orgId } = props;
const target = { environmentId, orgId };
const tab = useKinTab();
const insets = useSafeAreaInsets();
const barOverlap = useBarOverlap();
const reduceMotion = useReduceMotionEnabled();
const openLink = useKinWorkLink();
const [peek, setPeek] = useState<KinCanvasCardView | null>(null);
const [heading, setHeading] = useState<KinCanvasCamera | null>(null);
const camera = useCanvasCamera(`${environmentId}:${orgId}:docs`, reduceMotion, () =>
setHeading(null),
);
const layout = kinCanvasLayout({
groups: data.model.groups,
items: data.model.items,
aspect: 0.7,
});

// The map starts below the bar, not under it: a moving map behind the title can't be read.
const top = 8;
const bottom = (tab?.bottomClearance ?? insets.bottom) + 12;
// The switch above and the controls below cover the board's edges; fits keep cards clear of them.
const free = { top: top + 48, right: 0, bottom: bottom + 64, left: 0 };

const fly = (to: KinCanvasCamera) => {
setHeading(to);
camera.flyTo(to);
};
const fitAll = (instant = false, measured?: { readonly w: number; readonly h: number }) => {
const to = kinCanvasFit(
layout.bounds,
measured?.w ?? camera.width.get(),
measured?.h ?? camera.height.get(),
free,
16,
);
if (instant) camera.set(to);
else fly(to);
};

const { x: bx, y: by, w: bw, h: bh } = layout.bounds;
/* oxlint-disable react/exhaustive-effect-dependencies, react/set-state-in-effect -- only a change of
extent refits; the camera, which lives outside React, and the insets are read as they are then */
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- refits the camera to the map as its extent changes, until the person moves it
useEffect(() => {
if (camera.moved() || camera.width.get() === 0) return;
fitAll(true);
}, [bx, by, bw, bh]);
/* oxlint-enable react/exhaustive-effect-dependencies, react/set-state-in-effect */

/** Bring a card to the strip of map the peek sheet leaves showing, at a size to read its title. */
const reveal = (card: KinCanvasCardView) => {
const box = layout.cards.get(card.key);
if (box === undefined) return;
const scale = Math.min(Math.max(camera.scale.get(), 0.9), 1.2);
const height = camera.height.get();
const visibleMiddle = height * 0.25;
fly({
x: box.x + box.w / 2,
y: box.y + box.h / 2 + (height / 2 - visibleMiddle) / scale,
scale,
});
};
const open = (card: KinCanvasCardView) => {
setPeek(null);
const base = { environmentId: String(environmentId), orgId: String(orgId) };
if (card.kind === "doc") openLink("KinDoc", { ...base, doc: card.key });
else openLink("KinWorkItem", { ...base, task: card.key });
};

const empty = data.model.cards.size === 0;
const headline = kinCanvasHeadline(data.model);
return (
<View collapsable={false} className="flex-1 bg-screen">
{props.bar}
<View className="flex-1" style={{ marginTop: barOverlap }}>
<KinCanvasBoard
target={target}
camera={camera}
layout={layout}
model={data.model}
heading={heading}
peek={peek?.key ?? null}
onCard={(key) => {
const card = data.model.cards.get(key);
if (card === undefined) return;
setPeek(card);
reveal(card);
}}
onSized={(size) => {
if (camera.held) camera.settled();
else fitAll(true, size);
}}
>
<View
pointerEvents="box-none"
className="absolute inset-x-0 items-center gap-2 px-3"
style={{ top }}
>
{data.tasks ? <KinCanvasShowSwitch show={data.view} onShow={data.setView} /> : null}
{headline === "" ? null : (
<View className="rounded-full bg-card/90 px-3 py-1">
<Text textRole="caption" className="text-foreground-muted">
{headline}
</Text>
</View>
)}
</View>
{empty ? (
<View pointerEvents="none" className="absolute inset-0 justify-center px-8">
<EmptyState
variant="plain"
title={data.view === "doing" ? KIN_CANVAS.empty : KIN_CANVAS.emptyOpen}
detail={KIN_CANVAS.emptyDetail}
/>
</View>
) : null}
<View
pointerEvents="box-none"
className="absolute inset-x-0 flex-row items-end justify-between gap-2 px-3"
style={{ bottom }}
>
<View className="min-w-0 shrink">
<KinCanvasPartial lines={data.partial} onRetry={data.failed ? data.retry : null} />
</View>
{empty ? null : (
<KinCanvasZoomControls
onZoomOut={() => camera.zoomBy(0.7)}
onZoomIn={() => camera.zoomBy(1.4)}
onShowAll={() => fitAll()}
/>
)}
</View>
</KinCanvasBoard>
</View>
{peek !== null ? (
<KinCanvasPeek target={target} card={peek} onClose={() => setPeek(null)} onOpen={open} />
) : null}
</View>
);
}
30 changes: 29 additions & 1 deletion apps/mobile/src/features/chats/KinWorkScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import type { KinWorkLive } from "@t3tools/client-runtime/kin/kinWorkStream";
import { EnvironmentId, KinOrgId, KinPersonId } from "@t3tools/contracts";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import { Atom } from "effect/reactivity";
import { useState } from "react";
import { View } from "react-native";

import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
Expand All @@ -32,6 +34,7 @@ import { ScreenContent } from "../../components/ui/ScreenContent";
import { ScreenScrollView } from "../../components/ui/ScreenScrollView";
import { appAtomRegistry } from "../../state/atom-registry";
import { KinDocsList } from "./KinDocsList";
import { KinDocsMap } from "./KinDocsMap";
import { KinTasksList } from "./KinTasksList";
import { KinClientsList } from "./KinWorkLists";
import { KinMoneyArea } from "./KinWorkMoney";
Expand Down Expand Up @@ -256,7 +259,8 @@ export function KinPlace(
</KinWorkMessage>
);
}
if (place.place === "docs") return <KinDocsList {...shared} />;
if (place.place === "docs")
return <KinDocsPlace key={`${target.environmentId}:${target.orgId}`} {...shared} />;
if (place.place === "clients") return <KinClientsList {...shared} projects={place.projects} />;
if (place.place === "money") return <KinMoneyArea {...shared} />;
return (
Expand Down Expand Up @@ -302,3 +306,27 @@ export function KinPlace(
</KinWorkMessage>
);
}

/** Which of Docs' two views each company's Docs shows, kept while the app runs. */
const kinDocsViewAtom = Atom.family((_company: string) =>
Atom.make<"list" | "map">("list").pipe(Atom.keepAlive),
);

/** Docs, as the list or as the map of what's being worked on; the bar switches between them. */
function KinDocsPlace(props: React.ComponentProps<typeof KinDocsList>) {
const held = kinDocsViewAtom(`${props.environmentId}:${props.orgId}`);
const [view, setView] = useState(() => appAtomRegistry.get(held));
Comment thread
Surajsm60720 marked this conversation as resolved.
Resolved
const choose = (next: "list" | "map") => {
appAtomRegistry.set(held, next);
setView(next);
};
return view === "map" ? (
<KinDocsMap
environmentId={props.environmentId}
orgId={props.orgId}
onList={() => choose("list")}
/>
) : (
<KinDocsList {...props} onMap={() => choose("map")} />
);
}
Loading
Loading