⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(mobile): address review findings
Tine2b39f85bf2a
diff --git a/apps/mobile/src/app/(app)/notification-settings.tsx b/apps/mobile/src/app/(app)/notification-settings.tsxindex 2562adba0..9af110459 100644--- a/apps/mobile/src/app/(app)/notification-settings.tsx+++ b/apps/mobile/src/app/(app)/notification-settings.tsx@@ -333,24 +333,25 @@ function ChannelForm({? "App token": "Signing secret";+ // An empty address clears it: the API keeps the stored value for null or a missing field.const save = () => {const s = secret.trim() || undefined;if (channel === "ntfy")return onSave({ntfyEnabled: enabled,- ntfyServerUrl: url.trim() || undefined,- ntfyTopic: topic.trim() || undefined,+ ntfyServerUrl: url.trim(),+ ntfyTopic: topic.trim(),ntfyToken: s,});if (channel === "gotify")return onSave({gotifyEnabled: enabled,- gotifyServerUrl: url.trim() || undefined,+ gotifyServerUrl: url.trim(),gotifyToken: s,});return onSave({webhookEnabled: enabled,- webhookUrl: url.trim() || undefined,+ webhookUrl: url.trim(),webhookSecret: s,});};diff --git a/apps/mobile/src/app/(app)/task/[taskId].tsx b/apps/mobile/src/app/(app)/task/[taskId].tsxindex 96f057177..232bc9c50 100644--- a/apps/mobile/src/app/(app)/task/[taskId].tsx+++ b/apps/mobile/src/app/(app)/task/[taskId].tsx@@ -307,7 +307,12 @@ export default function TaskScreen() {onClose={() => setEditingDescription(false)}taskId={task.id}initial={d.description}- onSave={(text) => run(() => api.updateDescription(task.id, text))}+ onSave={async (text) =>+ !!(await run(async () => {+ await api.updateDescription(task.id, text);+ return true;+ }))+ }/><OptionSheetvisible={menu}diff --git a/apps/mobile/src/app/(app)/workspace/[workspaceId]/members.tsx b/apps/mobile/src/app/(app)/workspace/[workspaceId]/members.tsxindex 19e3914fa..988abc1a2 100644--- a/apps/mobile/src/app/(app)/workspace/[workspaceId]/members.tsx+++ b/apps/mobile/src/app/(app)/workspace/[workspaceId]/members.tsx@@ -35,6 +35,7 @@ import { qk, useAction } from "@/lib/query";import { useRequiredSession } from "@/lib/session";import {canManageWorkspace,+ hasRole,ROLE_HINTS,roleLabel,WORKSPACE_ROLES,@@ -75,9 +76,9 @@ export default function MembersScreen() {);const members = [...(org.data?.members ?? [])].sort((a, b) =>- a.role === "owner"+ hasRole(a.role, "owner")? -1- : b.role === "owner"+ : hasRole(b.role, "owner")? 1: (a.user?.name ?? "").localeCompare(b.user?.name ?? ""),);@@ -167,7 +168,8 @@ export default function MembersScreen() {<Group>{members.map((m, i) => {const isSelf = m.userId === session.userId;- const editable = canManage && m.role !== "owner" && !isSelf;+ const editable =+ canManage && !hasRole(m.role, "owner") && !isSelf;return (<GroupRowkey={m.id}@@ -204,7 +206,7 @@ export default function MembersScreen() {<Txtvariant="meta"weight="medium"- tone={m.role === "owner" ? "ink" : "muted"}+ tone={hasRole(m.role, "owner") ? "ink" : "muted"}>{roleLabel(m.role)}</Txt>diff --git a/apps/mobile/src/app/(app)/workspace/[workspaceId]/settings.tsx b/apps/mobile/src/app/(app)/workspace/[workspaceId]/settings.tsxindex 9ba61d479..1308a31c1 100644--- a/apps/mobile/src/app/(app)/workspace/[workspaceId]/settings.tsx+++ b/apps/mobile/src/app/(app)/workspace/[workspaceId]/settings.tsx@@ -20,7 +20,7 @@ import { workspaceDescription } from "@/lib/describe";import { useWorkspaceLabels, useWorkspaces } from "@/lib/hooks";import { qk, useAction } from "@/lib/query";import { sessionStore, useRequiredSession } from "@/lib/session";-import { canManageWorkspace } from "@/lib/style";+import { canManageWorkspace, hasRole } from "@/lib/style";import { useColors } from "@/theme";export default function WorkspaceSettingsScreen() {@@ -39,7 +39,7 @@ export default function WorkspaceSettingsScreen() {workspace?.role ??org.data?.members?.find((m) => m.userId === session.userId)?.role;const canEdit = canManageWorkspace(role);- const isOwner = role === "owner";+ const isOwner = hasRole(role, "owner");const [confirm, setConfirm] = useState<"leave" | "delete" | null>(null);const leaveOrDelete = async (kind: "leave" | "delete") => {diff --git a/apps/mobile/src/app/sign-in.tsx b/apps/mobile/src/app/sign-in.tsxindex d55d6c51a..0933aaf60 100644--- a/apps/mobile/src/app/sign-in.tsx+++ b/apps/mobile/src/app/sign-in.tsx@@ -77,16 +77,19 @@ export default function SignInScreen() {}};+ // A slow probe must not land after switching mode or server.+ const modeRef = useRef(mode);+ const probeRef = useRef(0);const connect = (raw: string) =>run(async () => {+ const probe = ++probeRef.current;const url = normalizeServerUrl(raw);const cfg = await auth.probe(url);+ if (probeRef.current !== probe || modeRef.current !== "self") return;setServerUrl(url);setConfig(cfg);});- // A slow cloud probe must not land after switching to self-hosted.- const modeRef = useRef(mode);const probeCloud = () => {const apply = (cfg: InstanceConfig) =>modeRef.current === "cloud" && setConfig(cfg);@@ -94,6 +97,7 @@ export default function SignInScreen() {};const changeMode = (next: "cloud" | "self") => {modeRef.current = next;+ probeRef.current++;setMode(next);setError(null);setConfig(null);@@ -182,12 +186,17 @@ export default function SignInScreen() {<OtpStepserverUrl={serverUrl}email={otpEmail}- setEmail={setOtpEmail}loading={loading}error={error}onVerify={(code) =>run(() => auth.signInWithOtp(serverUrl, otpEmail, code))}+ onSend={(email) =>+ run(async () => {+ await auth.sendOtp(serverUrl, email);+ setOtpEmail(email);+ })+ }onResend={() => run(() => auth.sendOtp(serverUrl, otpEmail))}/>) : null}@@ -529,18 +538,18 @@ function StepTitle({ title, message }: { title: string; message?: string }) {function OtpStep({email,- setEmail,loading,error,onVerify,+ onSend,onResend,}: {serverUrl: string;email: string;- setEmail: (v: string) => void;loading: boolean;error: string | null;onVerify: (code: string) => void;+ onSend: (email: string) => void;onResend: () => void;}) {const c = useColors();@@ -570,10 +579,7 @@ function OtpStep({label="Send code"disabled={!draftEmail.trim()}loading={loading}- onPress={() => {- setEmail(draftEmail.trim());- onResend();- }}+ onPress={() => onSend(draftEmail.trim())}/></View>);@@ -678,6 +684,7 @@ function DeviceStep({if (/device sign-in failed|invalid/i.test(userMessage(e))) throw e;result = { kind: "pending" };}+ if (cancelled) return;if (result.kind === "approved") {if (Platform.OS === "ios") WebBrowser.dismissAuthSession();await auth.completeWithToken(serverUrl, result.token);diff --git a/apps/mobile/src/features/task/description-editor.tsx b/apps/mobile/src/features/task/description-editor.tsxindex e74267a61..a15832157 100644--- a/apps/mobile/src/features/task/description-editor.tsx+++ b/apps/mobile/src/features/task/description-editor.tsx@@ -35,7 +35,8 @@ export function DescriptionEditor(props: {onClose: () => void;taskId: string;initial: string;- onSave: (text: string) => void;+ /** Resolves true once saved; otherwise the editor stays open with the draft. */+ onSave: (text: string) => Promise<boolean>;}) {return (<Modal@@ -75,11 +76,12 @@ function EditorBody({onClose: () => void;taskId: string;initial: string;- onSave: (text: string) => void;+ onSave: (text: string) => Promise<boolean>;}) {const c = useColors();const toast = useToast();const [text, setText] = useState(initial);+ const [saving, setSaving] = useState(false);const [mode, setMode] = useState<"write" | "preview">("write");const [selection, setSelection] = useState({start: initial.length,@@ -173,9 +175,12 @@ function EditorBody({Description</Txt><Touch- onPress={() => {- onSave(text);- onClose();+ disabled={saving}+ onPress={async () => {+ setSaving(true);+ const saved = await onSave(text);+ setSaving(false);+ if (saved) onClose();}}style={{height: 32,diff --git a/apps/mobile/src/lib/api/client.ts b/apps/mobile/src/lib/api/client.tsindex a15f01291..e2f626ba5 100644--- a/apps/mobile/src/lib/api/client.ts+++ b/apps/mobile/src/lib/api/client.ts@@ -160,9 +160,11 @@ export async function request<T>(const parsed = await readBody(response);if (!response.ok) {+ // Only expire the session the request was made with, not one signed in since.if (response.status === 401 &&session &&+ sessionStore.get().session?.token === session.token &&!path.startsWith("api/auth/") &&!options.credentials) {diff --git a/apps/mobile/src/lib/api/endpoints.ts b/apps/mobile/src/lib/api/endpoints.tsindex f6e6d39f3..dd147ed85 100644--- a/apps/mobile/src/lib/api/endpoints.ts+++ b/apps/mobile/src/lib/api/endpoints.ts@@ -248,8 +248,7 @@ export const api = {) => put<unknown>(`api/column/reorder/${projectId}`, { columns }),// --- Activity & comments ---- activities: (taskId: string) =>- get<Activity[]>(`api/activity/${taskId}`, { limit: 100 }),+ activities: (taskId: string) => get<Activity[]>(`api/activity/${taskId}`),workspaceActivity: (workspaceId: string) =>get<WorkspaceActivity[]>(`api/activity/workspace/${workspaceId}`),createComment: (taskId: string, comment: string) =>diff --git a/apps/mobile/src/lib/background.ts b/apps/mobile/src/lib/background.tsindex 28a37fd37..6c3071ffc 100644--- a/apps/mobile/src/lib/background.ts+++ b/apps/mobile/src/lib/background.ts@@ -20,9 +20,12 @@ const MAX_POSTED = 5;export async function checkNotifications(): Promise<void> {if (!sessionStore.get().ready) await sessionStore.hydrate();- if (!sessionStore.get().session) return;+ const session = sessionStore.get().session;+ if (!session) return;const since = Number((await AsyncStorage.getItem(SINCE_KEY)) ?? 0);const notifications = await api.notifications();+ // Signing out or switching accounts mid-check must not surface the old account's alerts.+ if (sessionStore.get().session?.token !== session.token) return;const unread = notifications.filter((n) =>@@ -32,7 +35,19 @@ export async function checkNotifications(): Promise<void> {.sort((a, b) => a.createdAt.localeCompare(b.createdAt));// On the first run only remember where we are, so the existing backlog isn't replayed.if (since !== 0 && AppState.currentState !== "active") {- for (const n of unread.slice(-MAX_POSTED)) {+ // Past the cap, the oldest are folded into one summary instead of being dropped silently.+ const hidden = Math.max(0, unread.length - (MAX_POSTED - 1));+ const shown = hidden > 1 ? unread.slice(-(MAX_POSTED - 1)) : unread;+ if (hidden > 1)+ await Notifications.scheduleNotificationAsync({+ content: {+ title: "Kaneo",+ body: `${hidden} more new notifications`,+ data: {},+ },+ trigger: Platform.OS === "android" ? { channelId: CHANNEL_ID } : null,+ });+ for (const n of shown) {const text = describeNotification(n);await Notifications.scheduleNotificationAsync({content: {diff --git a/apps/mobile/src/lib/format.ts b/apps/mobile/src/lib/format.tsindex 7a23d5e2b..629078318 100644--- a/apps/mobile/src/lib/format.ts+++ b/apps/mobile/src/lib/format.ts@@ -3,10 +3,12 @@ export type Day = { y: number; m: number; d: number };export function parseInstant(value?: string | null): Date | null {if (!value) return null;+ // `new Date("2026-03-09")` is UTC midnight, which is the previous day west of UTC.+ const bare = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);+ if (bare)+ return new Date(Number(bare[1]), Number(bare[2]) - 1, Number(bare[3]));const date = new Date(value);- if (!Number.isNaN(date.getTime())) return date;- const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(value);- return m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : null;+ return Number.isNaN(date.getTime()) ? null : date;}export function toDay(date: Date): Day {diff --git a/apps/mobile/src/lib/style.test.ts b/apps/mobile/src/lib/style.test.tsnew file mode 100644index 000000000..23b9f43fa--- /dev/null+++ b/apps/mobile/src/lib/style.test.ts@@ -0,0 +1,18 @@+import { describe, expect, it } from "vite-plus/test";+import { canManageWorkspace, hasRole } from "./style";++describe("hasRole", () => {+ it("finds a role among comma-separated roles", () => {+ expect(hasRole("admin,viewer", "admin")).toBe(true);+ expect(hasRole("member", "owner")).toBe(false);+ expect(hasRole(null, "owner")).toBe(false);+ });+});++describe("canManageWorkspace", () => {+ it("allows owners and admins, even alongside other roles", () => {+ expect(canManageWorkspace("viewer,admin")).toBe(true);+ expect(canManageWorkspace("owner")).toBe(true);+ expect(canManageWorkspace("member,viewer")).toBe(false);+ });+});diff --git a/apps/mobile/src/lib/style.ts b/apps/mobile/src/lib/style.tsindex d2a30153e..d7166f483 100644--- a/apps/mobile/src/lib/style.ts+++ b/apps/mobile/src/lib/style.ts@@ -44,8 +44,13 @@ export function roleLabel(role: string) {return role.charAt(0).toUpperCase() + role.slice(1);}+/** A member can hold several roles, stored comma-separated like `admin,viewer`. */+export function hasRole(role: string | null | undefined, name: string) {+ return !!role && role.split(",").includes(name);+}+export function canManageWorkspace(role?: string | null) {- return role === "owner" || role === "admin";+ return hasRole(role, "owner") || hasRole(role, "admin");}export const STATUS_PLANNED = "planned";