Skip to content

Commit 7205f3d

Browse files
authored
Merge branch 'main' into feat/usage-opencode-provider
2 parents 2306cac + 5b8445b commit 7205f3d

70 files changed

Lines changed: 3690 additions & 761 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/src/ipc/DesktopIpcHandlers.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
fetchSshEnvironmentDescriptor,
2222
fetchSshSessionState,
2323
issueSshWebSocketTicket,
24+
resolveSshHost,
2425
resolveSshPasswordPrompt,
2526
} from "./methods/sshEnvironment.ts";
2627
import {
@@ -68,6 +69,7 @@ export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers"
6869
yield* ipc.handle(clearConnectionCatalog);
6970

7071
yield* ipc.handle(discoverSshHosts);
72+
yield* ipc.handle(resolveSshHost);
7173
yield* ipc.handle(ensureSshEnvironment);
7274
yield* ipc.handle(disconnectSshEnvironment);
7375
yield* ipc.handle(fetchSshEnvironmentDescriptor);

‎apps/desktop/src/ipc/channels.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const GET_CONNECTION_CATALOG_CHANNEL = "desktop:get-connection-catalog";
2929
export const SET_CONNECTION_CATALOG_CHANNEL = "desktop:set-connection-catalog";
3030
export const CLEAR_CONNECTION_CATALOG_CHANNEL = "desktop:clear-connection-catalog";
3131
export const DISCOVER_SSH_HOSTS_CHANNEL = "desktop:discover-ssh-hosts";
32+
export const RESOLVE_SSH_HOST_CHANNEL = "desktop:resolve-ssh-host";
3233
export const ENSURE_SSH_ENVIRONMENT_CHANNEL = "desktop:ensure-ssh-environment";
3334
export const DISCONNECT_SSH_ENVIRONMENT_CHANNEL = "desktop:disconnect-ssh-environment";
3435
export const FETCH_SSH_ENVIRONMENT_DESCRIPTOR_CHANNEL = "desktop:fetch-ssh-environment-descriptor";

‎apps/desktop/src/ipc/methods/sshEnvironment.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ export const discoverSshHosts = DesktopIpc.makeIpcMethod({
117117
}),
118118
});
119119

120+
export const resolveSshHost = DesktopIpc.makeIpcMethod({
121+
channel: IpcChannels.RESOLVE_SSH_HOST_CHANNEL,
122+
payload: Schema.String,
123+
result: DesktopSshEnvironmentTargetSchema,
124+
handler: Effect.fn("desktop.ipc.sshEnvironment.resolveHost")(function* (alias) {
125+
const sshEnvironment = yield* DesktopSshEnvironment.DesktopSshEnvironment;
126+
return yield* sshEnvironment.resolveHost(alias);
127+
}),
128+
});
129+
120130
export const ensureSshEnvironment = DesktopIpc.makeIpcMethod({
121131
channel: IpcChannels.ENSURE_SSH_ENVIRONMENT_CHANNEL,
122132
payload: DesktopSshEnvironmentEnsureInputSchema,

‎apps/desktop/src/preload.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ contextBridge.exposeInMainWorld("desktopBridge", {
6060
ipcRenderer.invoke(IpcChannels.SET_CONNECTION_CATALOG_CHANNEL, catalog),
6161
clearConnectionCatalog: () => ipcRenderer.invoke(IpcChannels.CLEAR_CONNECTION_CATALOG_CHANNEL),
6262
discoverSshHosts: () => ipcRenderer.invoke(IpcChannels.DISCOVER_SSH_HOSTS_CHANNEL),
63+
resolveSshHost: (alias) => ipcRenderer.invoke(IpcChannels.RESOLVE_SSH_HOST_CHANNEL, alias),
6364
ensureSshEnvironment: async (target, options) =>
6465
unwrapEnsureSshEnvironmentResult(
6566
await ipcRenderer.invoke(IpcChannels.ENSURE_SSH_ENVIRONMENT_CHANNEL, {

‎apps/desktop/src/ssh/DesktopSshEnvironment.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from "@t3tools/contracts";
66
import * as NetService from "@t3tools/shared/Net";
77
import * as SshAuth from "@t3tools/ssh/auth";
8+
import { resolveSshTarget } from "@t3tools/ssh/command";
89
import { discoverSshHosts } from "@t3tools/ssh/config";
910
import {
1011
SshCommandError,
@@ -54,6 +55,9 @@ export class DesktopSshEnvironment extends Context.Service<
5455
readonly discoverHosts: (input?: {
5556
readonly homeDir?: string;
5657
}) => Effect.Effect<readonly DesktopDiscoveredSshHost[], DesktopSshEnvironmentDiscoverError>;
58+
readonly resolveHost: (
59+
alias: string,
60+
) => Effect.Effect<DesktopSshEnvironmentTarget, SshCommandError | SshInvalidTargetError>;
5761
readonly ensureEnvironment: (
5862
target: DesktopSshEnvironmentTarget,
5963
options?: { readonly issuePairingToken?: boolean },
@@ -136,6 +140,11 @@ export const make = Effect.gen(function* () {
136140
Effect.provide(runtimeContext),
137141
Effect.withSpan("desktop.ssh.discoverHosts"),
138142
),
143+
resolveHost: (alias) =>
144+
resolveSshTarget(alias.trim()).pipe(
145+
Effect.provide(runtimeContext),
146+
Effect.withSpan("desktop.ssh.resolveHost"),
147+
),
139148
ensureEnvironment: (target, ensureOptions) =>
140149
manager
141150
.ensureEnvironment(target, ensureOptions)

‎apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import type {
33
EnvironmentThreadShell,
44
} from "@t3tools/client-runtime/state/shell";
55
import { LegendList } from "@legendapp/list/react-native";
6-
import type { EnvironmentId } from "@t3tools/contracts";
6+
import {
7+
type EnvironmentId,
8+
type EnvironmentMachineKind,
9+
resolveEnvironmentMachineKind,
10+
} from "@t3tools/contracts";
711
import type { MenuAction } from "@react-native-menu/menu";
812
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
913
import { SymbolView } from "../../components/AppSymbol";
@@ -24,10 +28,12 @@ import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSw
2428
import { AppText as Text } from "../../components/AppText";
2529
import { ControlPillMenu } from "../../components/ControlPill";
2630
import { EmptyState } from "../../components/EmptyState";
31+
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
2732
import { ProjectFavicon } from "../../components/ProjectFavicon";
2833
import { useSafeAreaInsets } from "react-native-safe-area-context";
2934
import { relativeTime } from "../../lib/time";
3035
import { useUniwindTheme } from "../../lib/useUniwindTheme";
36+
import { useServerConfigs } from "../../state/entities";
3137
import { ThreadSwipeable } from "../home/thread-swipe-actions";
3238
import {
3339
createNativeMailSearchToolbarItem,
@@ -45,6 +51,7 @@ type ArchivedThreadListItem =
4551
readonly kind: "project";
4652
readonly key: string;
4753
readonly environmentLabel: string | null;
54+
readonly environmentMachine: EnvironmentMachineKind;
4855
readonly project: EnvironmentProject;
4956
}
5057
| {
@@ -360,6 +367,7 @@ function ArchivedThreadsHeader(props: {
360367

361368
function ProjectGroupLabel(props: {
362369
readonly environmentLabel: string | null;
370+
readonly environmentMachine: EnvironmentMachineKind;
363371
readonly project: EnvironmentProject;
364372
}) {
365373
return (
@@ -378,9 +386,16 @@ function ProjectGroupLabel(props: {
378386
{props.project.title}
379387
</Text>
380388
{props.environmentLabel ? (
381-
<Text className="max-w-[42%] text-2xs text-foreground-tertiary" numberOfLines={1}>
382-
{props.environmentLabel}
383-
</Text>
389+
<View className="max-w-[42%] flex-row items-center gap-1">
390+
<EnvironmentMachineSymbol
391+
kind={props.environmentMachine}
392+
size={10}
393+
tintColorClassName="accent-foreground-tertiary"
394+
/>
395+
<Text className="shrink text-2xs text-foreground-tertiary" numberOfLines={1}>
396+
{props.environmentLabel}
397+
</Text>
398+
</View>
384399
) : null}
385400
</View>
386401
);
@@ -517,6 +532,7 @@ export function ArchivedThreadsScreen(props: {
517532
),
518533
[props.environments],
519534
);
535+
const serverConfigs = useServerConfigs();
520536
const listItems = useMemo<ReadonlyArray<ArchivedThreadListItem>>(() => {
521537
const items: ArchivedThreadListItem[] = [];
522538
for (const group of props.groups) {
@@ -525,6 +541,9 @@ export function ArchivedThreadsScreen(props: {
525541
kind: "project",
526542
key: `${group.key}:project`,
527543
environmentLabel,
544+
environmentMachine: resolveEnvironmentMachineKind(
545+
serverConfigs.get(group.project.environmentId) ?? null,
546+
),
528547
project: group.project,
529548
});
530549

@@ -540,7 +559,7 @@ export function ArchivedThreadsScreen(props: {
540559
});
541560
}
542561
return items;
543-
}, [environmentLabelsById, props.groups]);
562+
}, [environmentLabelsById, props.groups, serverConfigs]);
544563
const handleSwipeableWillOpen = useCallback((methods: SwipeableMethods) => {
545564
if (openSwipeableRef.current && openSwipeableRef.current !== methods) {
546565
openSwipeableRef.current.close();
@@ -559,7 +578,11 @@ export function ArchivedThreadsScreen(props: {
559578
if (item.kind === "project") {
560579
return (
561580
<View className="pt-4">
562-
<ProjectGroupLabel environmentLabel={item.environmentLabel} project={item.project} />
581+
<ProjectGroupLabel
582+
environmentLabel={item.environmentLabel}
583+
environmentMachine={item.environmentMachine}
584+
project={item.project}
585+
/>
563586
</View>
564587
);
565588
}

‎apps/mobile/src/features/projects/AddProjectScreen.tsx‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ import {
3131
inferProjectTitleFromPath,
3232
isWindowsPlatform,
3333
} from "@t3tools/client-runtime/state/projects";
34-
import { CommandId, type EnvironmentId, ProjectId } from "@t3tools/contracts";
34+
import {
35+
CommandId,
36+
type EnvironmentId,
37+
type EnvironmentMachineKind,
38+
ProjectId,
39+
resolveEnvironmentMachineKind,
40+
} from "@t3tools/contracts";
3541
import { CommonActions, StackActions, useNavigation } from "@react-navigation/native";
3642
import { SymbolView } from "../../components/AppSymbol";
3743
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
@@ -49,6 +55,7 @@ import { projectEnvironment } from "../../state/projects";
4955
import { useEnvironmentQuery } from "../../state/query";
5056
import { sourceControlEnvironment } from "../../state/sourceControl";
5157
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
58+
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
5259
import { ErrorBanner } from "../../components/ErrorBanner";
5360
import { SourceControlIcon } from "../../components/SourceControlIcon";
5461
import { uuidv4 } from "../../lib/uuid";
@@ -65,6 +72,7 @@ interface EnvironmentOption {
6572
readonly environmentId: EnvironmentId;
6673
readonly label: string;
6774
readonly platform: string;
75+
readonly machine: EnvironmentMachineKind;
6876
readonly baseDirectory: string | null;
6977
readonly connectionState: EnvironmentConnectionPhase;
7078
readonly connectionError: string | null;
@@ -352,6 +360,7 @@ function useEnvironmentOptions(): ReadonlyArray<EnvironmentOption> {
352360
environmentId: connection.environmentId,
353361
label: connection.environmentLabel,
354362
platform: platformFromOs(config?.environment.platform.os ?? null),
363+
machine: resolveEnvironmentMachineKind(config ?? null),
355364
baseDirectory: config?.settings.addProjectBaseDirectory ?? null,
356365
connectionState: runtime?.connectionState ?? "available",
357366
connectionError: runtime?.connectionError ?? null,
@@ -490,11 +499,10 @@ export function AddProjectSourceScreen() {
490499
})
491500
}
492501
icon={
493-
<SymbolView
494-
name="server.rack"
502+
<EnvironmentMachineSymbol
503+
kind={environment.machine}
495504
size={17}
496-
tintColorClassName={"accent-icon"}
497-
type="monochrome"
505+
tintColorClassName="accent-icon"
498506
/>
499507
}
500508
selected={environment.environmentId === selectedEnvironment?.environmentId}

‎apps/mobile/src/features/settings/SettingsClientStorageRouteScreen.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { useAtomSet, useAtomValue } from "@effect/atom-react";
2+
import { type EnvironmentMachineKind, resolveEnvironmentMachineKind } from "@t3tools/contracts";
23
import { AsyncResult } from "effect/unstable/reactivity";
34
import { useMemo } from "react";
45
import { ActivityIndicator, Alert, Pressable, ScrollView, View } from "react-native";
56
import { useSafeAreaInsets } from "react-native-safe-area-context";
67

78
import { AppText as Text } from "../../components/AppText";
89
import { SymbolView } from "../../components/AppSymbol";
10+
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
911
import {
1012
clearClientCacheAtom,
1113
clientCacheSummaryAtom,
1214
type EnvironmentClientCacheSummary,
1315
} from "../../state/client-cache-state";
16+
import { useServerConfigs } from "../../state/entities";
1417
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
1518
import { SettingsSection } from "./components/SettingsSection";
1619

@@ -20,6 +23,7 @@ export function SettingsClientStorageRouteScreen() {
2023
const clearResult = useAtomValue(clearClientCacheAtom);
2124
const clearCache = useAtomSet(clearClientCacheAtom);
2225
const { savedConnectionsById } = useSavedRemoteConnections();
26+
const serverConfigs = useServerConfigs();
2327
const isClearing = clearResult.waiting;
2428
const summary = AsyncResult.isSuccess(summaryResult) ? summaryResult.value : null;
2529
const environmentSummaries = useMemo(
@@ -106,6 +110,9 @@ export function SettingsClientStorageRouteScreen() {
106110
savedConnectionsById[environment.environmentId]?.environmentLabel ??
107111
environment.environmentId
108112
}
113+
machine={resolveEnvironmentMachineKind(
114+
serverConfigs.get(environment.environmentId) ?? null,
115+
)}
109116
disabled={isClearing}
110117
first={index === 0}
111118
onClear={() => confirmClearEnvironment(environment)}
@@ -169,6 +176,7 @@ export function SettingsClientStorageRouteScreen() {
169176
function CacheEnvironmentRow(props: {
170177
readonly environment: EnvironmentClientCacheSummary;
171178
readonly environmentLabel: string;
179+
readonly machine: EnvironmentMachineKind;
172180
readonly disabled: boolean;
173181
readonly first: boolean;
174182
readonly onClear: () => void;
@@ -181,13 +189,7 @@ function CacheEnvironmentRow(props: {
181189
: "border-t border-border flex-row items-center gap-3 p-4"
182190
}
183191
>
184-
<SymbolView
185-
name="desktopcomputer"
186-
size={22}
187-
tintColorClassName={"accent-icon"}
188-
type="monochrome"
189-
weight="regular"
190-
/>
192+
<EnvironmentMachineSymbol kind={props.machine} size={22} tintColorClassName="accent-icon" />
191193
<Text className="min-w-0 flex-1 text-base text-foreground" numberOfLines={1}>
192194
{props.environmentLabel}
193195
</Text>

‎apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { VcsRef } from "@t3tools/client-runtime/state/vcs";
2+
import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
23
import { LegendList } from "@legendapp/list/react-native";
34
import {
45
isAtomCommandInterrupted,
@@ -21,9 +22,11 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
2122
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
2223
import { SymbolView } from "../../components/AppSymbol";
2324
import { AppText as Text } from "../../components/AppText";
25+
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
2426
import { ThemedSwitch } from "../../components/ThemedSwitch";
2527
import { cn } from "../../lib/cn";
2628
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
29+
import { useServerConfigs } from "../../state/entities";
2730
import { useAtomCommand } from "../../state/use-atom-command";
2831
import { vcsEnvironment } from "../../state/vcs";
2932
import {
@@ -35,7 +38,7 @@ import { branchBadgeLabel, useNewTaskFlow } from "./new-task-flow-provider";
3538
import { shouldCheckoutNewTaskBranch } from "./new-task-context-presentation";
3639

3740
function SelectionRow(props: {
38-
readonly icon?: "arrow.triangle.branch" | "desktopcomputer";
41+
readonly icon?: "arrow.triangle.branch" | ReactNode;
3942
readonly onPress: () => void;
4043
readonly disabled?: boolean;
4144
readonly selected: boolean;
@@ -56,14 +59,16 @@ function SelectionRow(props: {
5659
onPress={props.onPress}
5760
style={{ opacity: props.disabled ? 0.45 : 1 }}
5861
>
59-
{props.icon ? (
62+
{props.icon === "arrow.triangle.branch" ? (
6063
<SymbolView
61-
name={props.icon}
64+
name="arrow.triangle.branch"
6265
size={17}
6366
tintColorClassName={"accent-icon-muted"}
6467
type="monochrome"
6568
/>
66-
) : null}
69+
) : (
70+
(props.icon ?? null)
71+
)}
6772
<View className="min-w-0 flex-1 gap-0.5">
6873
<Text className="text-base font-t3-medium text-foreground" numberOfLines={1}>
6974
{props.title}
@@ -145,6 +150,7 @@ export function NewTaskEnvironmentPickerRouteScreen() {
145150
const flow = useNewTaskFlow();
146151
const navigation = useNavigation();
147152
const insets = useSafeAreaInsets();
153+
const serverConfigs = useServerConfigs();
148154

149155
return (
150156
<View className="flex-1 bg-sheet" collapsable={false}>
@@ -170,7 +176,15 @@ export function NewTaskEnvironmentPickerRouteScreen() {
170176
{flow.environments.map((environment, index) => (
171177
<SelectionRow
172178
key={String(environment.environmentId)}
173-
icon="desktopcomputer"
179+
icon={
180+
<EnvironmentMachineSymbol
181+
kind={resolveEnvironmentMachineKind(
182+
serverConfigs.get(environment.environmentId) ?? null,
183+
)}
184+
size={17}
185+
tintColorClassName="accent-icon-muted"
186+
/>
187+
}
174188
isLast={index === flow.environments.length - 1}
175189
onPress={() => {
176190
void Haptics.selectionAsync();

0 commit comments

Comments
 (0)