Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(mobile): render workspace logos and use English copy in workspace switcher (#3839)

Matt Voska96dbe8877431
diff --git a/apps/mobile/app/(app)/[workspace]/switch-workspace.tsx b/apps/mobile/app/(app)/[workspace]/switch-workspace.tsx
index f9781313bc..26a01fcde6 100644
--- a/apps/mobile/app/(app)/[workspace]/switch-workspace.tsx
+++ b/apps/mobile/app/(app)/[workspace]/switch-workspace.tsx
@@ -30,6 +30,7 @@ import { router } from "expo-router";
import { useQuery } from "@tanstack/react-query";
import type { Workspace } from "@multica/core/types";
import { Text } from "@/components/ui/text";
+import { WorkspaceAvatar } from "@/components/workspace/workspace-avatar";
import { workspaceListOptions } from "@/data/queries/workspaces";
import { useWorkspaceStore } from "@/data/workspace-store";
import { useColorScheme } from "@/lib/use-color-scheme";
@@ -45,12 +46,12 @@ export default function SwitchWorkspaceRoute() {
const onSelect = (ws: Workspace) => {
if (ws.slug === activeSlug) return;
Alert.alert(
- "切换工作区",
- `确定切换到 "${ws.name}"?`,
+ "Switch workspace",
+ `Switch to "${ws.name}"?`,
[
- { text: "取消", style: "cancel" },
+ { text: "Cancel", style: "cancel" },
{
- text: "切换",
+ text: "Switch",
onPress: () => {
router.dismiss();
router.replace(`/${ws.slug}/inbox`);
@@ -64,7 +65,7 @@ export default function SwitchWorkspaceRoute() {
<View className="flex-1">
<View className="px-4 pt-4 pb-3">
<Text className="text-base font-semibold text-foreground">
- 切换工作区
+ Switch workspace
</Text>
</View>
{isLoading ? (
@@ -80,7 +81,6 @@ export default function SwitchWorkspaceRoute() {
active={ws.slug === activeSlug}
onPress={() => onSelect(ws)}
iconTint={t.foreground}
- mutedIconTint={t.mutedForeground}
/>
))}
</ScrollView>
@@ -94,13 +94,11 @@ function WorkspaceRow({
active,
onPress,
iconTint,
- mutedIconTint,
}: {
workspace: Workspace;
active: boolean;
onPress: () => void;
iconTint: string;
- mutedIconTint: string;
}) {
return (
<Pressable
@@ -108,18 +106,18 @@ function WorkspaceRow({
disabled={active}
accessibilityLabel={
active
- ? `${workspace.name}, 当前工作区`
- : `切换到 ${workspace.name}`
+ ? `${workspace.name}, current workspace`
+ : `Switch to ${workspace.name}`
}
className={cn(
"flex-row items-center gap-3 px-4 py-3 active:bg-secondary",
active && "opacity-100",
)}
>
- <ExpoImage
- source="sf:building.2"
- tintColor={active ? iconTint : mutedIconTint}
- style={{ width: 18, height: 18 }}
+ <WorkspaceAvatar
+ name={workspace.name}
+ avatarUrl={workspace.avatar_url}
+ size={24}
/>
<Text
className={cn(
diff --git a/apps/mobile/components/nav/more-tab-dropdown.tsx b/apps/mobile/components/nav/more-tab-dropdown.tsx
index 916673971a..9aac93b8e1 100644
--- a/apps/mobile/components/nav/more-tab-dropdown.tsx
+++ b/apps/mobile/components/nav/more-tab-dropdown.tsx
@@ -50,6 +50,7 @@ import {
DropdownMenuSeparator,
} from "@/components/ui/dropdown-menu";
import { Text } from "@/components/ui/text";
+import { WorkspaceAvatar } from "@/components/workspace/workspace-avatar";
import { workspaceListOptions } from "@/data/queries/workspaces";
import { useAuthStore } from "@/data/auth-store";
import { useWorkspaceStore } from "@/data/workspace-store";
@@ -138,10 +139,10 @@ export function MoreTabDropdownAnchor({
<WorkspaceCard
currentWorkspaceName={currentWorkspace?.name}
+ currentWorkspaceAvatarUrl={currentWorkspace?.avatar_url}
onPress={() =>
slug && router.push(`/${slug}/switch-workspace`)
}
- iconTint={t.foreground}
chevronTint={t.mutedForeground}
/>
@@ -247,13 +248,13 @@ function UserCard({
*/
function WorkspaceCard({
currentWorkspaceName,
+ currentWorkspaceAvatarUrl,
onPress,
- iconTint,
chevronTint,
}: {
currentWorkspaceName: string | undefined;
+ currentWorkspaceAvatarUrl: string | null | undefined;
onPress: () => void;
- iconTint: string;
chevronTint: string;
}) {
const { data } = useQuery(workspaceListOptions());
@@ -265,16 +266,14 @@ function WorkspaceCard({
disabled={!canSwitch}
className="h-12 gap-3"
accessibilityLabel={
- canSwitch ? "切换工作区" : currentWorkspaceName ?? "Workspace"
+ canSwitch ? "Switch workspace" : currentWorkspaceName ?? "Workspace"
}
>
- <View className="size-8 rounded-md bg-muted items-center justify-center">
- <ExpoImage
- source="sf:building.2"
- tintColor={iconTint}
- style={{ width: 16, height: 16 }}
- />
- </View>
+ <WorkspaceAvatar
+ name={currentWorkspaceName ?? "Workspace"}
+ avatarUrl={currentWorkspaceAvatarUrl}
+ size={32}
+ />
<View className="flex-1 min-w-0">
<Text
className="text-sm font-medium text-foreground"
diff --git a/apps/mobile/components/workspace/workspace-avatar.tsx b/apps/mobile/components/workspace/workspace-avatar.tsx
new file mode 100644
index 0000000000..9b135b4f64
--- /dev/null
+++ b/apps/mobile/components/workspace/workspace-avatar.tsx
@@ -0,0 +1,57 @@
+/**
+ * Mobile WorkspaceAvatar. Mirrors packages/views/workspace/workspace-avatar.tsx:
+ * a resolved avatar_url renders as a rounded-square logo image; otherwise the
+ * workspace's initial letter sits in a muted tile. Same fallback semantics as
+ * web/desktop so a workspace looks identical across clients (apps/mobile/CLAUDE.md
+ * behavioral-parity rule).
+ *
+ * URL resolution goes through resolveAttachmentUrl — the mobile mirror of
+ * core's resolvePublicFileUrl — because avatar_url comes back as a server-
+ * relative path on self-hosted backends without a CDN signer, which RN's
+ * <Image> can't load without an absolute origin.
+ */
+import { View } from "react-native";
+import { Image as ExpoImage } from "expo-image";
+import { Text } from "@/components/ui/text";
+import { resolveAttachmentUrl } from "@/lib/attachment-url";
+import { cn } from "@/lib/utils";
+
+export function WorkspaceAvatar({
+ name,
+ avatarUrl,
+ size = 24,
+ className,
+}: {
+ name: string;
+ avatarUrl: string | null | undefined;
+ size?: number;
+ className?: string;
+}) {
+ const resolved = resolveAttachmentUrl(avatarUrl);
+ const borderRadius = Math.round(size / 4);
+
+ if (resolved) {
+ return (
+ <ExpoImage
+ source={{ uri: resolved }}
+ contentFit="cover"
+ accessibilityLabel={name}
+ style={{ width: size, height: size, borderRadius }}
+ />
+ );
+ }
+
+ return (
+ <View
+ className={cn("items-center justify-center bg-muted border border-border", className)}
+ style={{ width: size, height: size, borderRadius }}
+ >
+ <Text
+ className="font-semibold text-muted-foreground"
+ style={{ fontSize: Math.round(size * 0.48) }}
+ >
+ {name.charAt(0).toUpperCase()}
+ </Text>
+ </View>
+ );
+}