GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: reference local checkouts in a message or link them to a thread… · adampeterhiggins/t3code@d42edbb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps
    • mobile/src
      • components
        • CheckoutPickerSheet.tsx
        • ComposerAttachmentButton.tsx
      • features/threads
        • NewTaskDraftScreen.tsx
        • ThreadComposer.tsx
      • lib
        • composerChipPresentation.ts
    • server/src
      • auth
        • RpcAuthorization.ts
      • checkouts
        • CheckoutInspect.ts
      • observability
        • RpcInstrumentation.ts
      • orchestration-v2
        • Adapters
          • ClaudeAdapterV2.ts
        • Orchestrator.ts
        • ProjectionStore.ts
        • ProviderTurnStartService.ts
        • RunExecutionService.ts
        • testkit
          • OrchestratorScenario.ts
      • server.ts
      • ws.ts
    • web/src
      • checkoutContextStore.ts
      • components
        • ChatView.tsx
        • ContextChip.tsx
        • chat
          • ChatComposer.tsx
          • CheckoutAttachPicker.tsx
          • ComposerAttachMenu.tsx
          • ComposerCommandMenu.tsx
          • MessagesTimeline.tsx
          • ThreadDetailsPanel.tsx
          • ThreadLinkedCheckouts.tsx
          • composerReferenceMenu.logic.test.ts
          • composerReferenceMenu.logic.ts
          • useComposerCheckoutItems.ts
        • composerContextPresentation.tsx
        • contextChipParts.tsx
        • contextPresentationRegistry.ts
      • lib
        • composerContextRecords.ts
  • docs
    • fork-differences.md
    • user
      • composer.md
  • packages
    • client-runtime/src
      • operations
        • commands.ts
      • state
        • sourceControl.ts
        • threadCommands.ts
    • contracts/src
      • checkouts.ts
      • composerContext.test.ts
      • composerContext.ts
      • index.ts
      • orchestrationV2.ts
      • rpc.ts
    • provider-core/src/server
      • ProviderAdapter.ts
    • shared
      • package.json
      • src
        • checkouts.test.ts
        • checkouts.ts
        • composerContextReferences.ts

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/src/components/CheckoutPickerSheet.tsx‎

Copy file name to clipboard
+197Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
import type { EnvironmentId } from "@t3tools/contracts";
2+
import { formatComposerContextReference } from "@t3tools/shared/composerContextReferences";
3+
import {
4+
checkoutAccessForDriver,
5+
checkoutCandidates,
6+
checkoutContextRecord,
7+
checkoutDisplayName,
8+
checkoutPathKey,
9+
looksLikeCheckoutPath,
10+
rankCheckoutCandidates,
11+
} from "@t3tools/shared/checkouts";
12+
import { useMemo, useState, type ReactNode } from "react";
13+
import { Alert, FlatList, Pressable, View } from "react-native";
14+
import { useSafeAreaInsets } from "react-native-safe-area-context";
15+
16+
import { useEnvironmentServerConfig, useProjects, useThreadShells } from "../state/entities";
17+
import { useDebouncedValue } from "../state/queries";
18+
import { useEnvironmentQuery } from "../state/query";
19+
import { sourceControlEnvironment } from "../state/sourceControl";
20+
import {
21+
captureComposerDraftInsertion,
22+
insertComposerDraftContext,
23+
type ComposerDraftInsertion,
24+
} from "../state/use-composer-drafts";
25+
import { AppText as Text, AppTextInput } from "./AppText";
26+
import { PickerSheet } from "./PickerSheet";
27+
28+
export interface CheckoutPickerTarget {
29+
readonly environmentId: EnvironmentId;
30+
readonly draftKey: string;
31+
readonly driver: string | null;
32+
}
33+
34+
type OpenedCheckoutPicker = CheckoutPickerTarget & {
35+
readonly insertion: ComposerDraftInsertion;
36+
};
37+
38+
/** Picks a local checkout to reference in the draft. The owner renders `sheet`. */
39+
export function useCheckoutPicker(target: CheckoutPickerTarget | null): {
40+
readonly open: () => void;
41+
readonly sheet: ReactNode;
42+
} {
43+
const [opened, setOpened] = useState<OpenedCheckoutPicker | null>(null);
44+
return {
45+
open: () => {
46+
if (target)
47+
setOpened({ ...target, insertion: captureComposerDraftInsertion(target.draftKey) });
48+
},
49+
sheet: opened ? <CheckoutPickerSheet {...opened} onClose={() => setOpened(null)} /> : null,
50+
};
51+
}
52+
53+
function CheckoutPickerSheet(props: OpenedCheckoutPicker & { readonly onClose: () => void }) {
54+
const insets = useSafeAreaInsets();
55+
const projects = useProjects();
56+
const threads = useThreadShells();
57+
const config = useEnvironmentServerConfig(props.environmentId);
58+
const [query, setQuery] = useState("");
59+
const candidates = useMemo(
60+
() =>
61+
checkoutCandidates({
62+
currentEnvironmentId: props.environmentId,
63+
projects,
64+
worktrees: threads.map((thread) => ({
65+
environmentId: thread.environmentId,
66+
worktreePath: thread.worktreePath,
67+
})),
68+
environmentLabel: (id) =>
69+
id === props.environmentId
70+
? (config?.environment.label ?? "This environment")
71+
: "Another environment",
72+
}).filter((candidate) => candidate.selectable),
73+
[config?.environment.label, projects, props.environmentId, threads],
74+
);
75+
const ranked = useMemo(
76+
() => rankCheckoutCandidates(candidates, looksLikeCheckoutPath(query) ? "" : query, new Map()),
77+
[candidates, query],
78+
);
79+
const pasted = looksLikeCheckoutPath(query) ? checkoutPathKey(query.trim()) : null;
80+
const paths = useMemo(() => {
81+
const listed = ranked.slice(0, 20).map((candidate) => candidate.path);
82+
if (pasted !== null && !listed.includes(pasted)) listed.unshift(pasted);
83+
return listed;
84+
}, [pasted, ranked]);
85+
const settled = useDebouncedValue(paths.join("\n"), 200);
86+
const inspection = useEnvironmentQuery(
87+
settled.length === 0
88+
? null
89+
: sourceControlEnvironment.checkouts({
90+
environmentId: props.environmentId,
91+
input: { paths: settled.split("\n") },
92+
}),
93+
);
94+
const rows = useMemo(() => {
95+
const listed = ranked.slice(0, 20);
96+
if (pasted === null || listed.some((candidate) => checkoutPathKey(candidate.path) === pasted)) {
97+
return listed;
98+
}
99+
return [
100+
{
101+
environmentId: props.environmentId,
102+
environmentLabel: "",
103+
selectable: true,
104+
path: pasted,
105+
name: checkoutDisplayName(pasted),
106+
kind: "project" as const,
107+
},
108+
...listed,
109+
];
110+
}, [pasted, props.environmentId, ranked]);
111+
112+
const attach = (path: string, name: string) => {
113+
const entry = inspection.data?.entries.find(
114+
(candidate) => checkoutPathKey(candidate.path) === checkoutPathKey(path),
115+
);
116+
const record = checkoutContextRecord({
117+
path: entry?.path ?? path,
118+
name,
119+
branch: entry?.branch ?? null,
120+
headSha: entry?.headSha ?? null,
121+
changedFiles: entry?.changedFiles ?? 0,
122+
ahead: entry?.ahead ?? 0,
123+
access: checkoutAccessForDriver(props.driver),
124+
environmentId: props.environmentId,
125+
});
126+
if (
127+
!insertComposerDraftContext(
128+
props.draftKey,
129+
{
130+
text: formatComposerContextReference(record),
131+
context: { version: 1, records: [record] },
132+
},
133+
props.insertion,
134+
)
135+
) {
136+
Alert.alert("Too many context items", "Remove some context from the draft and try again.");
137+
return;
138+
}
139+
props.onClose();
140+
};
141+
142+
return (
143+
<PickerSheet title="Attach checkout" onClose={props.onClose}>
144+
<View className="px-4 pb-3">
145+
<AppTextInput
146+
accessibilityLabel="Search checkouts"
147+
autoFocus
148+
autoCapitalize="none"
149+
autoCorrect={false}
150+
clearButtonMode="while-editing"
151+
placeholder="Search by name or paste a path"
152+
value={query}
153+
onChangeText={setQuery}
154+
/>
155+
</View>
156+
<FlatList
157+
data={rows}
158+
keyExtractor={(row) => row.path}
159+
keyboardShouldPersistTaps="handled"
160+
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 16) }}
161+
ListEmptyComponent={
162+
<View className="items-center p-6">
163+
<Text className="text-center text-foreground-muted">
164+
{pasted
165+
? "Press return to use that path."
166+
: "No local checkouts yet. Paste a path to use a folder."}
167+
</Text>
168+
</View>
169+
}
170+
renderItem={({ item }) => {
171+
const entry = inspection.data?.entries.find(
172+
(candidate) => checkoutPathKey(candidate.path) === checkoutPathKey(item.path),
173+
);
174+
const status =
175+
entry === undefined
176+
? item.path
177+
: `${entry.branch ?? "detached"} · ${entry.changedFiles === 0 ? "clean" : `${entry.changedFiles} changed`}`;
178+
return (
179+
<Pressable
180+
accessibilityRole="button"
181+
accessibilityLabel={`Attach ${item.name}`}
182+
onPress={() => attach(item.path, item.name)}
183+
className="gap-0.5 px-4 py-3 active:bg-subtle"
184+
>
185+
<Text className="text-base text-foreground" numberOfLines={1}>
186+
{item.name}
187+
</Text>
188+
<Text className="text-sm text-foreground-muted" numberOfLines={1}>
189+
{status}
190+
</Text>
191+
</Pressable>
192+
);
193+
}}
194+
/>
195+
</PickerSheet>
196+
);
197+
}
Collapse file

‎apps/mobile/src/components/ComposerAttachmentButton.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/components/ComposerAttachmentButton.tsx
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const GITHUB_ISSUE_ACTION: MenuAction = {
1616
const NOTION_ACTION: MenuAction = { id: "notion", title: "Notion page", image: "doc.text" };
1717
const GRANOLA_ACTION: MenuAction = { id: "granola", title: "Granola note", image: "waveform" };
1818
const SLACK_ACTION: MenuAction = { id: "slack", title: "Slack message", image: "number" };
19+
const CHECKOUT_ACTION: MenuAction = {
20+
id: "checkout",
21+
title: "Checkout",
22+
image: "laptopcomputer",
23+
};
1924
const REPOSITORY_ACTION: MenuAction = {
2025
id: "repository",
2126
title: "Repository",
@@ -37,6 +42,8 @@ export function ComposerAttachmentButton(props: {
3742
readonly onPickGranolaNote?: () => void;
3843
/** Omit to hide the Slack action. See `useSlackMessagePicker`. */
3944
readonly onPickSlackMessage?: () => void;
45+
/** Omit to hide the checkout action. See `useCheckoutPicker`. */
46+
readonly onPickCheckout?: () => void;
4047
/** Omit to hide the repository action. See `useRepositoryPicker`. */
4148
readonly onPickRepository?: () => void;
4249
}) {
@@ -49,6 +56,7 @@ export function ComposerAttachmentButton(props: {
4956
...(props.onPickNotionPage ? [NOTION_ACTION] : []),
5057
...(props.onPickGranolaNote ? [GRANOLA_ACTION] : []),
5158
...(props.onPickSlackMessage ? [SLACK_ACTION] : []),
59+
...(props.onPickCheckout ? [CHECKOUT_ACTION] : []),
5260
...(props.onPickRepository ? [REPOSITORY_ACTION] : []),
5361
];
5462
const usesMenu = !props.disabled && actions.length > 1;
@@ -96,6 +104,8 @@ export function ComposerAttachmentButton(props: {
96104
props.onPickGranolaNote?.();
97105
} else if (nativeEvent.event === "slack") {
98106
props.onPickSlackMessage?.();
107+
} else if (nativeEvent.event === "checkout") {
108+
props.onPickCheckout?.();
99109
} else if (nativeEvent.event === "repository") {
100110
props.onPickRepository?.();
101111
}
Collapse file

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

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
import { useGranolaNotePicker } from "../../components/GranolaNotePickerSheet";
6565
import { useNotionPagePicker } from "../../components/NotionPagePickerSheet";
6666
import { useSlackMessagePicker } from "../../components/SlackMessagePickerSheet";
67+
import { useCheckoutPicker } from "../../components/CheckoutPickerSheet";
6768
import { useRepositoryPicker } from "../../components/RepositoryPickerSheet";
6869
import { ControlPillMenu } from "../../components/ControlPillMenu";
6970
import { gitHubIssueEnvironment } from "../../state/githubIssues";
@@ -1105,6 +1106,15 @@ export function NewTaskDraftScreen(props: {
11051106
}
11061107
: null,
11071108
);
1109+
const checkoutPicker = useCheckoutPicker(
1110+
flow.draftKey && selectedProject
1111+
? {
1112+
environmentId: selectedProject.environmentId,
1113+
draftKey: flow.draftKey,
1114+
driver: flow.selectedProviderStatus?.driver ?? null,
1115+
}
1116+
: null,
1117+
);
11081118
const repositoryPicker = useRepositoryPicker(
11091119
flow.draftKey && selectedProject
11101120
? {
@@ -1954,6 +1964,7 @@ export function NewTaskDraftScreen(props: {
19541964
? slackMessagePicker.open
19551965
: undefined
19561966
}
1967+
onPickCheckout={flow.draftKey ? checkoutPicker.open : undefined}
19571968
onPickRepository={flow.draftKey ? repositoryPicker.open : undefined}
19581969
/>
19591970
<View className="min-w-0 flex-1 flex-row items-center justify-end gap-2">
@@ -2045,6 +2056,7 @@ export function NewTaskDraftScreen(props: {
20452056
{notionPagePicker.sheet}
20462057
{granolaNotePicker.sheet}
20472058
{startFromPullRequestPicker.sheet}
2059+
{checkoutPicker.sheet}
20482060
{repositoryPicker.sheet}
20492061
</View>
20502062
);
Collapse file

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

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/ThreadComposer.tsx
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import { useGitHubIssuePicker } from "../../components/GitHubIssuePickerSheet";
7878
import { useGranolaNotePicker } from "../../components/GranolaNotePickerSheet";
7979
import { useNotionPagePicker } from "../../components/NotionPagePickerSheet";
8080
import { useSlackMessagePicker } from "../../components/SlackMessagePickerSheet";
81+
import { useCheckoutPicker } from "../../components/CheckoutPickerSheet";
8182
import { useRepositoryPicker } from "../../components/RepositoryPickerSheet";
8283
import {
8384
ComposerAttachmentStrip,
@@ -490,6 +491,11 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
490491
? { environmentId: props.environmentId, draftKey: composerDraftKey, cwd: workspaceCwd }
491492
: null,
492493
);
494+
const checkoutPicker = useCheckoutPicker({
495+
environmentId: props.environmentId,
496+
draftKey: composerDraftKey,
497+
driver: selectedProviderStatus?.driver ?? null,
498+
});
493499
const repositoryPicker = useRepositoryPicker({
494500
environmentId: props.environmentId,
495501
draftKey: composerDraftKey,
@@ -929,6 +935,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
929935
onPickNotionPage={notionPagePicker.open}
930936
onPickGranolaNote={granolaNotePicker.open}
931937
onPickSlackMessage={slackMessagePicker.open}
938+
onPickCheckout={checkoutPicker.open}
932939
onPickRepository={repositoryPicker.open}
933940
/>
934941
) : null}
@@ -1213,6 +1220,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
12131220
onPickNotionPage={notionPagePicker.open}
12141221
onPickGranolaNote={granolaNotePicker.open}
12151222
onPickSlackMessage={slackMessagePicker.open}
1223+
onPickCheckout={checkoutPicker.open}
12161224
onPickRepository={repositoryPicker.open}
12171225
/>
12181226
<View className="min-w-0 shrink">
@@ -1278,6 +1286,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
12781286
{slackMessagePicker.sheet}
12791287
{notionPagePicker.sheet}
12801288
{granolaNotePicker.sheet}
1289+
{checkoutPicker.sheet}
12811290
{repositoryPicker.sheet}
12821291
</Animated.View>
12831292
);
Collapse file

‎apps/mobile/src/lib/composerChipPresentation.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/lib/composerChipPresentation.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const CONTEXT_CHIP_PRESENTATIONS = {
2121
"github-issue": { accent: "#009f6e", symbol: "smallcircle.filled.circle" },
2222
"slack-thread": { accent: "#c6589c", symbol: "number" },
2323
repository: { accent: "#009c9c", symbol: "folder" },
24+
checkout: { accent: "#0096af", symbol: "laptopcomputer" },
2425
} as const;
2526

2627
/**
Collapse file

‎apps/server/src/auth/RpcAuthorization.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/auth/RpcAuthorization.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export const RPC_REQUIRED_SCOPES = {
154154
[WS_METHODS.contextRepositoriesList]: AuthOrchestrationReadScope,
155155
[WS_METHODS.contextRepositoriesInspect]: AuthOrchestrationReadScope,
156156
[WS_METHODS.contextRepositoriesRemove]: AuthSourceControlWriteScope,
157+
[WS_METHODS.checkoutsInspect]: AuthOrchestrationReadScope,
157158
// Reading issues is a read; connecting or disconnecting the environment's
158159
// Linear account changes what every client of this environment can reach.
159160
[WS_METHODS.linearSubscribeState]: AuthOrchestrationReadScope,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.