T3 Code Mobile [WIP] #2013
Mergedjuliusmarmingemerged 77 commits into
main fromrefs/pull/2013/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
- apps/desktop/src/updateState.ts line 41OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -34,4 +34,8 @@3434 platform: NodeJS.Platform;3535 appImage?: string | undefined;3636 disabledByEnv: boolean;37+ hasUpdateFeedConfig: boolean;3738 }): string | null {39+ if (!args.hasUpdateFeedConfig) {40+ return "Automatic updates are not available because no update feed is configured.";41+ }apps/mobile/src/features/connection/NewConnectionRouteScreen.tsx line 253OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +233,21 @@233+234+ {connectionError ? <ErrorBanner message={connectionError} /> : null}235+236+ <ConnectionSheetButton237+ icon="plus"238+ label={239+ isSubmitting || connectionState === "connecting" ? "Pairing..." : "Add backend"240+ }241+ disabled={connectDisabled}242+ tone="primary"243+ onPress={() => {244+ void handleSubmit();245+ }}246+ />247+ </View>248+ )}249+ </View>250+ </ScrollView>251+ </View>252+ );253+}
- apps/mobile/src/features/threads/ThreadComposer.tsx line 578Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +585,21 @@585+ if (event.startsWith("options:effort:")) {586+ const effort = event.slice("options:effort:".length);587+ const updated: ModelSelection =588+ currentModelSelection.provider === "claudeAgent"589+ ? {590+ ...currentModelSelection,591+ options: { ...currentModelSelection.options, effort: effort as typeof currentEffort },592+ }593+ : currentModelSelection;594+ void props.onUpdateModelSelection(updated);595+ return;596+ }597+ if (event.startsWith("options:fast-mode:")) {598+ const fastMode = event.endsWith(":on");599+ const updated: ModelSelection = {600+ ...currentModelSelection,601+ options: { ...currentModelSelection.options, fastMode: fastMode || undefined },602+ };603+ void props.onUpdateModelSelection(updated);604+ return;605+ }
- packages/client-runtime/src/environmentConnection.ts line 85OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +25,21 @@25+ event: OrchestrationShellStreamEvent,26+ environmentId: EnvironmentId,27+ ) => void;28+ readonly syncShellSnapshot: (29+ snapshot: OrchestrationShellSnapshot,30+ environmentId: EnvironmentId,31+ ) => void;32+ readonly applyTerminalEvent: (event: TerminalEvent, environmentId: EnvironmentId) => void;33+}34+35+interface EnvironmentConnectionInput extends OrchestrationHandlers {36+ readonly kind: "primary" | "saved";37+ readonly knownEnvironment: KnownEnvironment;38+ readonly client: WsRpcClient;39+ readonly refreshMetadata?: () => Promise<void>;40+ readonly onConfigSnapshot?: (config: ServerConfig) => void;41+ readonly onWelcome?: (payload: ServerLifecycleWelcomePayload) => void;42+ readonly onShellResubscribe?: (environmentId: EnvironmentId) => void;43+}44+45+function createBootstrapGate() {
- @@ -0,0 +7,21 @@7+const loadedFaviconUrls = new Set<string>();8+9+/* ─── Component ──────────────────────────────────────────────────────── */10+export function ProjectFavicon(props: {11+ readonly size?: number;12+ readonly projectTitle: string;13+ readonly httpBaseUrl?: string | null;14+ readonly workspaceRoot?: string | null;15+ readonly bearerToken?: string | null;16+}) {17+ const size = props.size ?? 42;18+ const iconMuted = useThemeColor("--color-icon-subtle");19+20+ const faviconUrl =21+ props.httpBaseUrl && props.workspaceRoot22+ ? `${props.httpBaseUrl}/api/project-favicon?cwd=${encodeURIComponent(props.workspaceRoot)}`23+ : null;24+25+ const [status, setStatus] = useState<"loading" | "loaded" | "error">(() =>26+ faviconUrl && loadedFaviconUrls.has(faviconUrl) ? "loaded" : "loading",27+ );apps/mobile/src/features/threads/git/gitSheetComponents.tsx lines 156 to 158Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +138,21 @@138+139+ if (!gitStatus.isRepo) {140+ return "Not a git repository";141+ }142+143+ const parts: string[] = [];144+ if (gitStatus.hasWorkingTreeChanges) {145+ const fileCount = gitStatus.workingTree?.files.length ?? 0;146+ parts.push(`${fileCount} file${fileCount === 1 ? "" : "s"} changed`);147+ } else {148+ parts.push("Clean");149+ }150+ if ((gitStatus.aheadCount ?? 0) > 0) {151+ parts.push(`${gitStatus.aheadCount} ahead`);152+ }153+ if ((gitStatus.behindCount ?? 0) > 0) {154+ parts.push(`${gitStatus.behindCount} behind`);155+ }156+ if (gitStatus.pr?.state === "open") {157+ parts.push(`PR #${gitStatus.pr.number} open`);158+ }
- @@ -0,0 +8,21 @@8+const CARD_SHADOW = Platform.select({9+ ios: {10+ shadowColor: "rgba(23,23,23,0.08)",11+ shadowOffset: { width: 0, height: 4 },12+ shadowOpacity: 1,13+ shadowRadius: 16,14+ },15+ android: { elevation: 3 },16+});17+18+const CARD_SHADOW_DARK = Platform.select({19+ ios: {20+ shadowColor: "#000",21+ shadowOffset: { width: 0, height: 2 },22+ shadowOpacity: 0.18,23+ shadowRadius: 8,24+ },25+ android: { elevation: 4 },26+});27+28+export { CARD_SHADOW, CARD_SHADOW_DARK };@@ -0,0 +176,21 @@176+ const appendAttachments = useCallback(177+ (nextAttachments: ReadonlyArray<DraftComposerImageAttachment>) => {178+ setAttachments((current) => [...current, ...nextAttachments]);179+ },180+ [],181+ );182+183+ const removeAttachment = useCallback((imageId: string) => {184+ setAttachments((current) => current.filter((candidate) => candidate.id !== imageId));185+ }, []);186+187+ const clearAttachments = useCallback(() => {188+ setAttachments([]);189+ }, []);190+191+ const reset = useCallback(() => {192+ console.log("[new task flow] reset", {193+ defaultEnvironmentId: projects[0]?.environmentId ?? null,194+ projectCount: projects.length,195+ });196+ setSelectedEnvironmentId(projects[0]?.environmentId ?? "");
juliusmarminge changed the title
- apps/mobile/src/app/connections/new.tsx line 111Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +90,21 @@90+91+ try {92+ const pairingUrl = extractPairingUrlFromQrPayload(data);93+ const { host, code } = parsePairingUrl(pairingUrl);94+ setHostInput(host);95+ setCodeInput(code);96+ onChangeConnectionPairingUrl(pairingUrl);97+ setShowScanner(false);98+ } catch (error) {99+ Alert.alert(100+ "Invalid QR code",101+ error instanceof Error ? error.message : "Scanned QR code was not recognized.",102+ );103+ } finally {104+ setTimeout(() => {105+ setScannerLocked(false);106+ }, 600);107+ }108+ },109+ [onChangeConnectionPairingUrl, scannerLocked],110+ );
- apps/mobile/src/features/threads/NewTaskDraftScreen.tsx line 377Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +352,21 @@352+ try {353+ const modelWithOptions: ModelSelection =354+ flow.selectedModel.provider === "claudeAgent"355+ ? {356+ ...flow.selectedModel,357+ options: {358+ effort: flow.effort,359+ fastMode: flow.fastMode || undefined,360+ contextWindow: flow.contextWindow,361+ },362+ }363+ : flow.selectedModel.provider === "codex"364+ ? { ...flow.selectedModel, options: { fastMode: flow.fastMode || undefined } }365+ : flow.selectedModel;366+367+ const createdThread = await onCreateThreadWithOptions({368+ project: flow.selectedProject,369+ modelSelection: modelWithOptions,370+ envMode: flow.workspaceMode,371+ branch: flow.selectedBranchName,372+ worktreePath: flow.workspaceMode === "worktree" ? null : flow.selectedWorktreePath,
- @@ -0,0 +233,21 @@233+234+ {connectionError ? <ErrorBanner message={connectionError} /> : null}235+236+ <ConnectionSheetButton237+ icon="plus"238+ label={239+ isSubmitting || connectionState === "connecting" ? "Pairing..." : "Add backend"240+ }241+ disabled={connectDisabled}242+ tone="primary"243+ onPress={() => {244+ void handleSubmit();245+ }}246+ />247+ </View>248+ )}249+ </View>250+ </ScrollView>251+ </View>252+ );253+}
- apps/mobile/src/lib/repositoryGroups.ts lines 85 to 89Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +67,21 @@67+68+ for (const thread of input.threads) {69+ const key = scopedProjectKey(thread.environmentId, thread.projectId);70+ const existing = threadsByProjectKey.get(key);71+ if (existing) {72+ existing.push(thread);73+ } else {74+ threadsByProjectKey.set(key, [thread]);75+ }76+ }77+78+ const grouped = new Map<string, MobileRepositoryGroup>();79+80+ for (const project of input.projects) {81+ const key = deriveRepositoryGroupKey(project);82+ const projectKey = scopedProjectKey(project.environmentId, project.id);83+ const threads = Arr.sortWith(84+ threadsByProjectKey.get(projectKey) ?? [],85+ (s) => new Date(s.updatedAt ?? s.createdAt),86+ Order.Date,87+ );@@ -0,0 +58,21 @@58+ style={{59+ position: "absolute",60+ top: 4,61+ right: 4,62+ width: 22,63+ height: 22,64+ borderRadius: 11,65+ backgroundColor: "rgba(0,0,0,0.55)",66+ alignItems: "center",67+ justifyContent: "center",68+ }}69+ hitSlop={6}70+ onPress={() => props.onRemove(image.id)}71+ >72+ <SymbolView73+ name="xmark"74+ size={9}75+ tintColor="#ffffff"76+ type="monochrome"77+ weight="bold"78+ />packages/client-runtime/src/vcsStatusState.ts lines 47 to 62OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +41,21 @@41+ cause: null,42+ isPending: true,43+});44+45+/* ─── Atoms ─────────────────────────────────────────────────────────── */46+47+const knownGitStatusKeys = new Set<string>();48+49+export const gitStatusStateAtom = Atom.family((key: string) => {50+ knownGitStatusKeys.add(key);51+ return Atom.make(INITIAL_GIT_STATUS_STATE).pipe(52+ Atom.keepAlive,53+ Atom.withLabel(`git-status:${key}`),54+ );55+});56+57+export const EMPTY_GIT_STATUS_ATOM = Atom.make(EMPTY_GIT_STATUS_STATE).pipe(58+ Atom.keepAlive,59+ Atom.withLabel("git-status:null"),60+);61+packages/client-runtime/src/environmentConnection.ts lines 239 to 242OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +152,21 @@152+ return {153+ kind: input.kind,154+ environmentId,155+ knownEnvironment: input.knownEnvironment,156+ client: input.client,157+ ensureBootstrapped: () => bootstrapGate.wait(),158+ reconnect: async () => {159+ bootstrapGate.reset();160+ try {161+ await input.client.reconnect();162+ await input.refreshMetadata?.();163+ await bootstrapGate.wait();164+ } catch (error) {165+ bootstrapGate.reject(error);166+ throw error;167+ }168+ },169+ dispose: async () => {170+ cleanup();171+ await input.client.dispose();172+ },apps/mobile/src/features/threads/use-project-actions.ts line 160Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +136,21 @@136+ projectCwd: input.project.workspaceRoot,137+ baseBranch: input.branch!,138+ branch: buildTemporaryWorktreeBranchName(),139+ },140+ runSetupScript: true,141+ }142+ : {}),143+ },144+ createdAt: new Date().toISOString(),145+ });146+147+ await refreshRemoteData([input.project.environmentId]);148+ return {149+ environmentId: input.project.environmentId,150+ threadId,151+ };152+ },153+ [refreshRemoteData],154+ );155+156+ const onCreateThread = useCallback(
- apps/mobile/src/lib/repositoryGroups.ts line 130Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +108,21 @@108+ });109+ continue;110+ }111+112+ grouped.set(key, {113+ ...existing,114+ title: existing.repositoryIdentity ? existing.title : deriveRepositoryTitle(project),115+ subtitle: existing.subtitle ?? deriveRepositorySubtitle(project.repositoryIdentity),116+ repositoryIdentity: existing.repositoryIdentity ?? project.repositoryIdentity ?? null,117+ projectCount: existing.projectCount + 1,118+ threadCount: existing.threadCount + threads.length,119+ latestActivityAt:120+ compareIsoDateDescending(existing.latestActivityAt, latestActivityAt) > 0121+ ? latestActivityAt122+ : existing.latestActivityAt,123+ projects: Arr.sortWith(124+ [...existing.projects, projectGroup],125+ (s) => new Date(s.latestActivityAt),126+ Order.Date,127+ ),128+ });
- apps/mobile/src/lib/storage.ts lines 29 to 29OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +9,21 @@9+async function readStorageItem(key: string): Promise<string | null> {10+ return await SecureStore.getItemAsync(key);11+}12+13+async function writeStorageItem(key: string, value: string): Promise<void> {14+ await SecureStore.setItemAsync(key, value);15+}16+17+export async function loadSavedConnections(): Promise<ReadonlyArray<SavedRemoteConnection>> {18+ const raw = (await readStorageItem(CONNECTIONS_KEY)) ?? "";19+ if (!raw.trim()) {20+ return [];21+ }22+23+ try {24+ const parsed = JSON.parse(raw) as {25+ readonly connections?: ReadonlyArray<SavedRemoteConnection>;26+ };27+ return pipe(28+ parsed.connections ?? [],29+ Arr.filter((c) => !!c.environmentId && !!c.bearerToken?.trim()),
- apps/mobile/src/features/review/reviewWordDiffs.ts lines 211 to 213OutdatedResolvedby juliusmarminge@@ -0,0 +193,21 @@193+ if (tokens.length === 0 || ranges.length === 0) {194+ return tokens;195+ }196+197+ const nextTokens: ReviewHighlightedToken[] = [];198+ let tokenOffset = 0;199+ let rangeIndex = 0;200+201+ tokens.forEach((token) => {202+ const tokenStart = tokenOffset;203+ const tokenEnd = tokenStart + token.content.length;204+ tokenOffset = tokenEnd;205+206+ if (token.content.length === 0) {207+ nextTokens.push(token);208+ return;209+ }210+211+ while ((ranges[rangeIndex]?.end ?? 0) <= tokenStart) {212+ rangeIndex += 1;213+ }
- @@ -0,0 +64,21 @@64+ updates: {65+ enabled: true,66+ url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",67+ checkAutomatically: "ON_LOAD",68+ fallbackToCacheTimeout: 0,69+ },70+ splash: {71+ image: "./assets/splash-icon.png",72+ resizeMode: "contain",73+ backgroundColor: "#ffffff",74+ },75+ ios: {76+ icon: variant.iosIcon,77+ supportsTablet: true,78+ bundleIdentifier: variant.iosBundleIdentifier,79+ infoPlist: {80+ NSAppTransportSecurity: {81+ NSAllowsArbitraryLoads: true,82+ },83+ ITSAppUsesNonExemptEncryption: false,84+ },
- packages/client-runtime/src/terminalSessionState.ts lines 47 to 48OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +28,21 @@28+ readonly state: TerminalSessionState;29+}30+31+export interface TerminalSessionManagerConfig {32+ readonly getRegistry: () => AtomRegistry.AtomRegistry;33+ readonly maxBufferBytes?: number;34+}35+36+export const EMPTY_TERMINAL_SESSION_STATE = Object.freeze<TerminalSessionState>({37+ snapshot: null,38+ buffer: "",39+ status: "closed",40+ error: null,41+ hasRunningSubprocess: false,42+ updatedAt: null,43+ version: 0,44+});45+46+const DEFAULT_MAX_BUFFER_BYTES = 512 * 1024;47+const knownTerminalSessionKeys = new Set<string>();48+const textEncoder = new TextEncoder();@@ -0,0 +36,21 @@36+}37+38+export function getTerminalStatusLabel(input: {39+ readonly status: TerminalMenuSession["status"];40+ readonly hasRunningSubprocess?: boolean;41+}): string {42+ if (input.status === "running") {43+ return input.hasRunningSubprocess ? "Task running" : "Ready";44+ }45+ if (input.status === "starting") {46+ return "Starting";47+ }48+ if (input.status === "exited") {49+ return "Exited";50+ }51+ if (input.status === "error") {52+ return "Error";53+ }54+55+ return "Not started";56+}@@ -0,0 +788,21 @@788+ }789+ return { ...current, [file.id]: result };790+ });791+ } catch (error) {792+ logReviewDiffDiagnostic("highlight request failed", {793+ fileId: file.id,794+ filePath: file.path,795+ error: error instanceof Error ? error.message : String(error),796+ });797+ }798+ }799+ } finally {800+ highlightQueueActiveRef.current = false;801+ if (802+ generation === highlightQueueGenerationRef.current &&803+ highlightQueueRef.current.length > 0804+ ) {805+ startHighlightQueueRunner();806+ }807+ }808+ })();
- apps/mobile/src/features/threads/ComposerCommandPopover.tsx line 130Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +110,21 @@110+ return null;111+ }112+}113+114+function emptyText(triggerKind: ComposerTriggerKind | null, isLoading: boolean): string {115+ if (isLoading) {116+ return triggerKind === "path" ? "Searching files…" : "Loading…";117+ }118+ switch (triggerKind) {119+ case "path":120+ return "No matching files or folders.";121+ case "skill":122+ return "No skills found.";123+ case "slash-command":124+ return "No matching commands.";125+ default:126+ return "No results.";127+ }128+}129+130+const CommandRow = memo(function CommandRow(props: {apps/mobile/src/lib/repositoryGroups.ts lines 56 to 62Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +40,21 @@40+ const identity = project.repositoryIdentity;41+ return identity?.displayName ?? identity?.name ?? project.title;42+}43+44+function deriveRepositorySubtitle(identity: RepositoryIdentity | null | undefined): string | null {45+ if (!identity) {46+ return null;47+ }48+ if (identity.owner && identity.name) {49+ return `${identity.owner}/${identity.name}`;50+ }51+ return identity.canonicalKey;52+}53+54+function deriveProjectLatestActivity(55+ project: EnvironmentScopedProjectShell,56+ threads: ReadonlyArray<EnvironmentScopedThreadShell>,57+): string {58+ const latestThread = threads[0];59+ return latestThread?.updatedAt ?? latestThread?.createdAt ?? project.updatedAt;60+}apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift lines 54 to 62Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +42,21 @@42+ var ghosttyColorScheme: ghostty_color_scheme_e {43+ switch self {44+ case .light:45+ return GHOSTTY_COLOR_SCHEME_LIGHT46+ case .dark:47+ return GHOSTTY_COLOR_SCHEME_DARK48+ }49+ }50+}51+52+private extension UIColor {53+ convenience init(hexString: String) {54+ let sanitized = hexString.replacingOccurrences(of: "#", with: "")55+ let value = Int(sanitized, radix: 16) ?? 056+ self.init(57+ red: CGFloat((value >> 16) & 0xFF) / 255,58+ green: CGFloat((value >> 8) & 0xFF) / 255,59+ blue: CGFloat(value & 0xFF) / 255,60+ alpha: 161+ )62+ }apps/mobile/src/lib/composerImages.ts lines 197 to 214Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +194,21 @@194+ };195+}196+197+function mimeTypeFromUri(uri: string): string {198+ const ext = uri.split(".").pop()?.toLowerCase();199+ switch (ext) {200+ case "png":201+ return "image/png";202+ case "jpg":203+ case "jpeg":204+ return "image/jpeg";205+ case "gif":206+ return "image/gif";207+ case "webp":208+ return "image/webp";209+ case "heic":210+ return "image/heic";211+ default:212+ return "image/png";213+ }214+}@@ -0,0 +16,21 @@16+}17+18+export function parsePairingUrl(url: string): { host: string; code: string } {19+ const trimmed = url.trim();20+ if (!trimmed) return { host: "", code: "" };21+22+ try {23+ const parsed = new URL(trimmed);24+ const hashParams = new URLSearchParams(parsed.hash.slice(1));25+ const hashToken = hashParams.get("token");26+ const queryToken = parsed.searchParams.get("token");27+ const code = hashToken || queryToken || "";28+29+ parsed.hash = "";30+ parsed.search = "";31+ parsed.pathname = "/";32+ return { host: parsed.toString().replace(/\/$/, ""), code };33+ } catch {34+ return { host: trimmed, code: "" };35+ }36+}
- @@ -0,0 +10,21 @@10+ shadowColor: "rgba(23,23,23,0.08)",11+ shadowOffset: { width: 0, height: 4 },12+ shadowOpacity: 1,13+ shadowRadius: 16,14+ },15+ android: { elevation: 3 },16+});17+18+const CARD_SHADOW_DARK = Platform.select({19+ ios: {20+ shadowColor: "#000",21+ shadowOffset: { width: 0, height: 2 },22+ shadowOpacity: 0.18,23+ shadowRadius: 8,24+ },25+ android: { elevation: 4 },26+});27+28+export { CARD_SHADOW, CARD_SHADOW_DARK };29+30+export function ConnectionSheetButton(props: {apps/mobile/src/features/review/reviewWordDiffs.ts line 211OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +191,21 @@191+ ranges: ReadonlyArray<ReviewDiffHighlightRange>,192+): ReadonlyArray<ReviewHighlightedToken> {193+ if (tokens.length === 0 || ranges.length === 0) {194+ return tokens;195+ }196+197+ const nextTokens: ReviewHighlightedToken[] = [];198+ let tokenOffset = 0;199+ let rangeIndex = 0;200+201+ tokens.forEach((token) => {202+ const tokenStart = tokenOffset;203+ const tokenEnd = tokenStart + token.content.length;204+ tokenOffset = tokenEnd;205+206+ if (token.content.length === 0) {207+ nextTokens.push(token);208+ return;209+ }210+211+ while ((ranges[rangeIndex]?.end ?? 0) <= tokenStart) {
- packages/client-runtime/src/terminalSessionState.ts lines 124 to 130OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +99,21 @@99+ error: null,100+ hasRunningSubprocess: false,101+ updatedAt: null,102+ version: 0,103+});104+105+const EMPTY_KNOWN_TERMINAL_SESSIONS = Object.freeze<Array<KnownTerminalSession>>([]);106+const EMPTY_TERMINAL_ID_LIST = Object.freeze<Array<string>>([]);107+const DEFAULT_MAX_BUFFER_BYTES = 512 * 1024;108+const knownTerminalMetadataEnvironmentIds = new Set<EnvironmentId>();109+const knownTerminalBufferTargets = new Map<string, KnownTerminalSessionTarget>();110+const textEncoder = new TextEncoder();111+const textDecoder = new TextDecoder();112+113+export const terminalSessionMetadataAtom = Atom.family((environmentId: EnvironmentId) => {114+ knownTerminalMetadataEnvironmentIds.add(environmentId);115+ return Atom.make<Record<string, KnownTerminalMetadata>>({}).pipe(116+ Atom.keepAlive,117+ Atom.withLabel(`terminal-session:metadata:${environmentId}`),118+ );119+});apps/mobile/src/features/terminal/terminalMenu.ts lines 110 to 112Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +84,21 @@84+ for (const session of input.knownSessions) {85+ if (86+ session.state.status !== "running" &&87+ session.state.status !== "starting" &&88+ session.target.terminalId !== input.currentSession?.terminalId89+ ) {90+ continue;91+ }92+93+ sessionsById.set(session.target.terminalId, {94+ terminalId: session.target.terminalId,95+ cwd: session.state.summary?.cwd ?? input.workspaceRoot,96+ status: session.state.status,97+ hasRunningSubprocess: session.state.hasRunningSubprocess,98+ updatedAt: session.state.updatedAt,99+ });100+ }101+102+ if (input.currentSession && !sessionsById.has(input.currentSession.terminalId)) {103+ sessionsById.set(input.currentSession.terminalId, input.currentSession);104+ }apps/web/src/terminalUiStateStore.ts lines 310 to 316OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +299,21 @@299+ const usedGroupIds = new Set(terminalGroups.map((group) => group.id));300+ const nextGroupId = assignUniqueGroupId(301+ fallbackGroupId(normalized.activeTerminalId),302+ usedGroupIds,303+ );304+ terminalGroups.push({ id: nextGroupId, terminalIds: [normalized.activeTerminalId] });305+ activeGroupIndex = terminalGroups.length - 1;306+ }307+308+ const destinationGroup = terminalGroups[activeGroupIndex];309+ if (!destinationGroup) {310+ return normalized;311+ }312+313+ if (314+ isNewTerminal &&315+ !destinationGroup.terminalIds.includes(terminalId) &&316+ destinationGroup.terminalIds.length >= MAX_TERMINALS_PER_GROUP317+ ) {318+ return normalized;319+ }apps/mobile/src/features/threads/git/GitOverviewSheet.tsx lines 71 to 73Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +52,21 @@52+ () => (isRepo ? buildMenuItems(gitStatus.data, busy, hasOriginRemote) : []),53+ [busy, gitStatus.data, hasOriginRemote, isRepo],54+ );55+56+ const sheetMenuItems = useMemo(57+ () =>58+ menuItems.map((item) => ({59+ item,60+ disabledReason: getGitActionDisabledReason({61+ item,62+ gitStatus: gitStatus.data,63+ isBusy: busy,64+ hasOriginRemote,65+ }),66+ })),67+ [busy, gitStatus.data, hasOriginRemote, menuItems],68+ );69+70+ useEffect(() => {71+ void gitActions.refreshSelectedThreadGitStatus({ quiet: true });72+ }, [gitActions]);apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx lines 42 to 43Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +4,21 @@4+import { Pressable, View } from "react-native";5+import Animated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";6+import { useThemeColor } from "../../lib/useThemeColor";7+8+import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";9+import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";10+import { ConnectionStatusDot } from "./ConnectionStatusDot";11+12+export function ConnectionEnvironmentRow(props: {13+ readonly environment: ConnectedEnvironmentSummary;14+ readonly expanded: boolean;15+ readonly onToggle: () => void;16+ readonly onReconnect: (environmentId: EnvironmentId) => void;17+ readonly onRemove: (environmentId: EnvironmentId) => void;18+ readonly onUpdate: (19+ environmentId: EnvironmentId,20+ updates: { readonly label: string; readonly displayUrl: string },21+ ) => void;22+}) {23+ const [label, setLabel] = useState(props.environment.environmentLabel);24+ const [url, setUrl] = useState(props.environment.displayUrl);
- packages/client-runtime/src/wsTransport.ts lines 20 to 39OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +11,21 @@11+} from "./wsRpcProtocol.ts";12+13+export interface WsTransportOptions {14+ /**15+ * Merged into the transport `ManagedRuntime` alongside the RPC protocol layer16+ * (for example a `Tracer` layer for OTLP).17+ */18+ readonly tracingLayer?: Layer.Layer<never, never, never>;19+ /**20+ * Override protocol construction (defaults to {@link createWsRpcProtocolLayer}).21+ * The web app supplies its instrumented layer factory.22+ */23+ readonly createProtocolLayer?: (24+ url: WsRpcProtocolSocketUrlProvider,25+ lifecycleHandlers?: WsProtocolLifecycleHandlers,26+ ) => Layer.Layer<RpcClient.Protocol, never, never>;27+ /**28+ * Invoked at the start of {@link WsTransport.reconnect} before the session is replaced.29+ */30+ readonly onBeforeReconnect?: () => void;31+}
- apps/mobile/src/app/connections/new.tsx lines 27 to 32Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +13,21 @@13+import { extractPairingUrlFromQrPayload } from "../../features/connection/pairing";14+import { useRemoteConnections } from "../../state/use-remote-environment-registry";15+import { buildPairingUrl, parsePairingUrl } from "../../features/connection/pairing";16+17+export default function ConnectionsNewRouteScreen() {18+ const {19+ connectionError,20+ connectionPairingUrl,21+ connectionState,22+ onChangeConnectionPairingUrl,23+ onConnectPress,24+ } = useRemoteConnections();25+ const router = useRouter();26+ const params = useLocalSearchParams<{ mode?: string }>();27+ const insets = useSafeAreaInsets();28+ const [hostInput, setHostInput] = useState("");29+ const [codeInput, setCodeInput] = useState("");30+ const [isSubmitting, setIsSubmitting] = useState(false);31+ const [showScanner, setShowScanner] = useState(params.mode === "scan_qr");32+ const [cameraPermission, requestCameraPermission] = useCameraPermissions();33+ const [scannerLocked, setScannerLocked] = useState(false);
- apps/mobile/src/features/terminal/ThreadTerminalPanel.tsx lines 80 to 82OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +62,21 @@62+ terminalDebugLog("panel:attach", {63+ environmentId: props.environmentId,64+ threadId: props.threadId,65+ terminalId,66+ });67+68+ return attachTerminalSession({69+ environmentId: props.environmentId,70+ client,71+ terminal: {72+ threadId: props.threadId,73+ terminalId,74+ cwd: props.cwd,75+ worktreePath: props.worktreePath,76+ cols: lastGridSize.cols,77+ rows: lastGridSize.rows,78+ },79+ });80+ }, [81+ lastGridSize.cols,82+ lastGridSize.rows,apps/web/src/components/ChatView.tsx lines 569 to 575Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -451,0 +503,21 @@503+ () => knownTerminalSessions.map((session) => session.target.terminalId),504+ [knownTerminalSessions],505+ );506+ const storeSetTerminalHeight = useTerminalUiStateStore((state) => state.setTerminalHeight);507+ const storeSplitTerminal = useTerminalUiStateStore((state) => state.splitTerminal);508+ const storeNewTerminal = useTerminalUiStateStore((state) => state.newTerminal);509+ const storeSetActiveTerminal = useTerminalUiStateStore((state) => state.setActiveTerminal);510+ const storeCloseTerminal = useTerminalUiStateStore((state) => state.closeTerminal);511+ const reconcileTerminalIds = useTerminalUiStateStore((state) => state.reconcileTerminalIds);512+513+ useEffect(() => {514+ if (terminalIdListsEqual(serverOrderedTerminalIds, terminalUiState.terminalIds)) {515+ return;516+ }517+ if (518+ serverTerminalIdsStrictSubsetOfClient(serverOrderedTerminalIds, terminalUiState.terminalIds)519+ ) {520+ return;521+ }522+ reconcileTerminalIds(threadRef, serverOrderedTerminalIds);523+ }, [reconcileTerminalIds, serverOrderedTerminalIds, terminalUiState.terminalIds, threadRef]);apps/server/src/terminal/Layers/Manager.ts lines 184 to 184OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -146,3 +165,20 @@146165 killFibers: Map<PtyProcess, Fiber.Fiber<void, never>>;147166 }148167168+function truncateTerminalWireLabel(value: string): string {169+ if (value.length <= MAX_TERMINAL_LABEL_LENGTH) return value;170+ return value.slice(0, MAX_TERMINAL_LABEL_LENGTH);171+}172+173+function normalizeChildCommandName(raw: string, platform: NodeJS.Platform): string | null {174+ let trimmed = raw.trim();175+ if (trimmed.length === 0) return null;176+ if (177+ (trimmed.startsWith("[") && trimmed.endsWith("]")) ||178+ (trimmed.startsWith("(") && trimmed.endsWith(")"))179+ ) {180+ trimmed = trimmed.slice(1, -1).trim();181+ }182+ const firstToken = (trimmed.split(/\s+/)[0] ?? trimmed).trim();183+ if (firstToken.length === 0) return null;184+ const base = platform === "win32" ? path.win32.basename(firstToken) : path.basename(firstToken);apps/mobile/src/features/threads/ThreadComposer.tsx lines 206 to 213OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +193,21 @@193+ "high") as ClaudeAgentEffort)194+ : "high";195+ const currentFastMode =196+ getModelSelectionBooleanOptionValue(currentModelSelection, "fastMode") ?? false;197+ const currentContextWindow =198+ currentModelSelection.provider === "claudeAgent"199+ ? (getModelSelectionStringOptionValue(currentModelSelection, "contextWindow") ?? "1M")200+ : "1M";201+202+ const handleNativePaste = useNativePaste((uris) => {203+ void props.onNativePasteImages(uris);204+ });205+206+ // ── Trigger detection ────────────────────────────────────207+ const [cursorPosition, setCursorPosition] = useState(0);208+ const [composerTrigger, setComposerTrigger] = useState<ComposerTrigger | null>(null);209+ const [pathSearchResults, setPathSearchResults] = useState<210+ ReadonlyArray<{ path: string; kind: "file" | "directory" }>211+ >([]);212+ const [pathSearchLoading, setPathSearchLoading] = useState(false);213+ const pathSearchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
- @@ -0,0 +687,21 @@687+ tokenAttributedStringsByRowId.removeAll()688+ rebuildRowLayout()689+ setNeedsDisplayForVisibleBounds()690+ }691+ }692+ var tokensByRowId: [String: [ReviewDiffNativeToken]] = [:] {693+ didSet {694+ tokenAttributedStringsByRowId.removeAll()695+ clampHorizontalOffsets()696+ setNeedsDisplayForVisibleBounds()697+ }698+ }699+700+ func mergeTokensByRowId(_ tokensPatch: [String: [ReviewDiffNativeToken]]) {701+ tokensPatch.forEach { rowId, tokens in702+ tokensByRowId[rowId] = tokens703+ tokenAttributedStringsByRowId.removeValue(forKey: rowId)704+ }705+ clampHorizontalOffsets()706+ setNeedsDisplayForVisibleBounds()707+ }
- @@ -0,0 +1583,21 @@1583+ }1584+1585+ private func fileStatusColor(_ changeType: String?) -> UIColor {1586+ switch changeType {1587+ case "new":1588+ return theme.addText1589+ case "deleted":1590+ return theme.deleteText1591+ case "renamed", "rename-pure", "rename-changed":1592+ return theme.hunkText1593+ default:1594+ return theme.hunkText1595+ }1596+ }1597+1598+ private func drawStatusPill(_ text: String, rect: CGRect, color: UIColor, font: UIFont) {1599+ let path = UIBezierPath(roundedRect: rect, cornerRadius: rect.height / 2)1600+ color.withAlphaComponent(0.12).setFill()1601+ path.fill()1602+ drawCenteredText(text, rect: rect, color: color, font: font)1603+ }apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift line 1470Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1344,21 @@1344+ let rangeMaxY = visibleMaxY + overscan1345+ guard let firstRowIndex = firstVisibleRowIndex(atOrAfter: rangeMinY),1346+ let lastRowIndex = lastVisibleRowIndex(atOrBefore: rangeMaxY),1347+ firstRowIndex <= lastRowIndex else {1348+ return1349+ }1350+1351+ var drawnRowCount = 01352+ for rowIndex in firstRowIndex...lastRowIndex {1353+ let rowStart = rowOffsets[rowIndex]1354+ let rowHeight = height(for: rows[rowIndex])1355+ if rowHeight <= 0 {1356+ continue1357+ }1358+ let rowEnd = rowStart + rowHeight1359+ if rowEnd < visibleMinY || rowStart > visibleMaxY {1360+ continue1361+ }1362+ drawRow(rows[rowIndex], rowIndex: rowIndex, context: context)1363+ drawnRowCount += 11364+ }
- @@ -0,0 +1133,21 @@1133+ lowerBound = midpoint + 11134+ } else {1135+ return midpoint1136+ }1137+ }1138+1139+ return nil1140+ }1141+1142+ private func firstVisibleRowIndex(atOrAfter absoluteY: CGFloat) -> Int? {1143+ guard !rows.isEmpty else {1144+ return nil1145+ }1146+1147+ var lowerBound = 01148+ var upperBound = rows.count1149+ while lowerBound < upperBound {1150+ let midpoint = (lowerBound + upperBound) / 21151+ let rowEnd = rowOffsets[midpoint] + height(for: rows[midpoint])1152+1153+ if rowEnd < absoluteY {
- apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift lines 1183 to 1194Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1072,21 @@1072+ }1073+1074+ let matchIndex = lowerBound - 11075+ guard matchIndex >= 0 else {1076+ return nil1077+ }1078+ return ReviewDiffStickyFileHeaderIndex(position: matchIndex, rowIndex: fileHeaderRowIndices[matchIndex])1079+ }1080+1081+ func scrollAnchor(forFileId fileId: String) -> ReviewDiffScrollAnchor? {1082+ if let stickyHeader = stickyFileHeaderTarget(),1083+ resolvedFileId(for: stickyHeader.row) == fileId {1084+ return ReviewDiffScrollAnchor(fileId: fileId, screenY: 0)1085+ }1086+1087+ guard let headerOffset = fileHeaderOffset(forFileId: fileId) else {1088+ return nil1089+ }1090+1091+ return ReviewDiffScrollAnchor(fileId: fileId, screenY: headerOffset - verticalOffset)1092+ }
- apps/mobile/src/lib/repositoryGroups.ts line 89Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +67,21 @@67+68+ for (const thread of input.threads) {69+ const key = scopedProjectKey(thread.environmentId, thread.projectId);70+ const existing = threadsByProjectKey.get(key);71+ if (existing) {72+ existing.push(thread);73+ } else {74+ threadsByProjectKey.set(key, [thread]);75+ }76+ }77+78+ const grouped = new Map<string, MobileRepositoryGroup>();79+80+ for (const project of input.projects) {81+ const key = deriveRepositoryGroupKey(project);82+ const projectKey = scopedProjectKey(project.environmentId, project.id);83+ const threads = Arr.sortWith(84+ threadsByProjectKey.get(projectKey) ?? [],85+ (s) => new Date(s.updatedAt ?? s.createdAt),86+ Order.Date,87+ );apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift line 773Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +721,21 @@721+ var style = ReviewDiffNativeStyle.resolve(nil) {722+ didSet {723+ tokenAttributedStringsByRowId.removeAll()724+ rebuildRowLayout()725+ clampHorizontalOffsets()726+ setNeedsDisplayForVisibleBounds()727+ }728+ }729+ var viewportWidth: CGFloat = 0 {730+ didSet {731+ clampHorizontalOffsets()732+ setNeedsDisplayForVisibleBounds()733+ }734+ }735+ var verticalOffset: CGFloat = 0736+ var theme = ReviewDiffNativeTheme.resolve("light") {737+ didSet {738+ tokenColorsByHex.removeAll()739+ tokenAttributedStringsByRowId.removeAll()740+ }741+ }
- @@ -15,3 +16,4 @@1516 "perf": "warn"1617 },1718 "rules": {19+ "unicorn/no-array-sort": "off",
- @@ -0,0 +79,21 @@79+ : `${selectedLines.length} lines selected`;80+ const previewHeight = Math.max(81+ Math.min(selectedLines.length, REVIEW_COMMENT_PREVIEW_MAX_LINES) * REVIEW_DIFF_LINE_HEIGHT,82+ REVIEW_DIFF_LINE_HEIGHT,83+ );84+ const previewViewportWidth = Math.max(width - 40, 280);85+ const handleNativePaste = useNativePaste((uris) => {86+ void (async () => {87+ try {88+ const images = await convertPastedImagesToAttachments({89+ uris,90+ existingCount: attachments.length,91+ });92+ if (images.length > 0) {93+ setAttachments((current) => [...current, ...images]);94+ }95+ } catch (error) {96+ console.error("[review comment] error converting pasted images", error);97+ }98+ })();99+ });apps/mobile/src/features/review/ReviewSheet.tsx lines 207 to 207OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +187,21 @@187+ [loadingTurnIds, readyCheckpoints, reviewCache.gitSections, reviewCache.turnDiffById],188+ );189+190+ const selectedSection =191+ reviewSections.find((section) => section.id === reviewCache.selectedSectionId) ??192+ reviewSections[0] ??193+ null;194+ const topContentInset = insets.top + IOS_NAV_BAR_HEIGHT;195+ const parsedDiff = useMemo(196+ () =>197+ measureReviewWork("parse-diff", () =>198+ getCachedReviewParsedDiff({199+ threadKey: reviewCache.threadKey,200+ sectionId: selectedSection?.id ?? null,201+ diff: selectedSection?.diff,202+ }),203+ ),204+ [reviewCache.threadKey, selectedSection?.diff, selectedSection?.id],205+ );206+ const headerDiffSummary = useMemo(() => formatHeaderDiffSummary(parsedDiff), [parsedDiff]);207+ const NativeReviewDiffView = resolveNativeReviewDiffView()!;
- apps/server/src/terminal/Layers/Manager.ts line 2185Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1743,0 +2127,21 @@2127+ }).pipe(2128+ Effect.map((terminal) =>2129+ terminal2130+ ? {2131+ type: "upsert" as const,2132+ terminal,2133+ }2134+ : null,2135+ ),2136+ );2137+ };2138+2139+ const offerMetadataEvent = (2140+ listener: (event: TerminalMetadataStreamEvent) => Effect.Effect<void>,2141+ event: TerminalEvent,2142+ ) =>2143+ metadataEventFromTerminalEvent(event).pipe(2144+ Effect.flatMap((metadataEvent) => (metadataEvent ? listener(metadataEvent) : Effect.void)),2145+ );2146+2147+ const subscribeMetadata: TerminalManagerShape["subscribeMetadata"] = (listener) => {
- apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift line 1390Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1268,21 @@1268+ }1269+1270+ private func startHorizontalDeceleration(fileId: String, velocity: CGFloat) {1271+ guard abs(velocity) > 80 else {1272+ return1273+ }1274+1275+ let currentOffset = horizontalOffset(for: fileId)1276+ let maxOffset = maxHorizontalOffset(for: (fileId: fileId, kind: .code))1277+ if (currentOffset <= 0 && velocity < 0) || (currentOffset >= maxOffset && velocity > 0) {1278+ return1279+ }1280+1281+ stopHorizontalDeceleration()1282+ deceleratingFileId = fileId1283+ horizontalVelocity = velocity1284+ lastDecelerationTimestamp = 01285+1286+ let displayLink = CADisplayLink(target: self, selector: (stepHorizontalDeceleration(_:)))1287+ displayLink.add(to: .main, forMode: .common)1288+ decelerationDisplayLink = displayLink
- @@ -0,0 +72,21 @@72+ PATH="$(dirname "${GHOSTTY_ZIG}"):${PATH}" "${GHOSTTY_ZIG}" build \73+ -Dapp-runtime=none \74+ -Demit-xcframework=true \75+ -Demit-macos-app=false \76+ -Demit-exe=false \77+ -Demit-docs=false \78+ -Demit-webdata=false \79+ -Demit-helpgen=false \80+ -Demit-terminfo=false \81+ -Demit-termcap=false \82+ -Demit-themes=false \83+ -Doptimize=ReleaseFast \84+ -Dstrip \85+ -Dxcframework-target=universal86+)87+88+xcframework="${GHOSTTY_SOURCE_DIR}/macos/GhosttyKit.xcframework"89+ios_archive="${xcframework}/ios-arm64/libghostty-fat.a"90+sim_archive="${xcframework}/ios-arm64-simulator/libghostty-fat.a"91+[[ -f "${ios_archive}" ]] || die "missing built iOS archive: ${ios_archive}"92+[[ -f "${sim_archive}" ]] || die "missing built iOS simulator archive: ${sim_archive}"
- packages/client-runtime/src/wsTransport.ts lines 255 to 261OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +234,21 @@234+235+ async dispose() {236+ if (this.disposed) {237+ return;238+ }239+240+ this.disposed = true;241+ await this.closeSession(this.session);242+ }243+244+ isHeartbeatFresh(maxAgeMs = 15_000): boolean {245+ return this.lastHeartbeatPongAt > 0 && Date.now() - this.lastHeartbeatPongAt <= maxAgeMs;246+ }247+248+ private closeSession(session: TransportSession) {249+ this.intentionalCloseDepth += 1;250+ return session.runtime.runPromise(Scope.close(session.clientScope, Exit.void)).finally(() => {251+ this.intentionalCloseDepth -= 1;252+ session.runtime.dispose();253+ });254+ }
Sign in to join this conversation.



Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
737ef88d-a537-46af-ae68-8e407554fa6eYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.