fix(clients): resolve thread file chips beyond the workspace #21928
Openjuliusmarmingewants to merge 250+ commits into
misc-02/thread-file-candidates fromrefs/pull/21928/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge changed the title
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/mobile/src/features/threads/useThreadFileLinks.ts line 63OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +43,21 @@43+ index = createThreadFilePathIndex(paths);44+ setIndexed({ key: pathsKey, index });45+ }46+ const canRead = useEnvironmentScope(ref.environmentId, AuthFilesystemReadScope);47+ const connection = usePreparedConnection(ref.environmentId);48+ const enabled = canRead && connection._tag === "Some";49+ const { environmentId, threadId } = ref;50+ useAtomValue(projectEnvironment.fileMetadataThread(ref));51+ const generation = useRef(0);52+ useLayoutEffect(53+ () => () => {54+ generation.current++;55+ },56+ // oxlint-disable-next-line react/exhaustive-effect-dependencies -- Leaving this scope invalidates delayed native actions.57+ [environmentId, threadId, cwd, connection, canRead, enabled],58+ );59+ const capture = () => {60+ const current = generation.current;61+ return () => generation.current === current;62+ };63+ const scope = { environmentId, threadId, cwd, connection, canRead, enabled };
- apps/web/src/components/ChatMarkdown.assets.browser.test.tsx lines 81 to 85OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -51,3 +77,9 @@51775278 const roots: Root[] = [];5379 let registry: AtomRegistry.AtomRegistry;80+let allowMetadata = false;81+const metadataResults = Atom.family((_key: string) =>82+ Atom.make<AsyncResult.AsyncResult<FilesystemEntryMetadata | null, Error>>(83+ AsyncResult.initial(true),84+ ),85+);
- apps/mobile/src/features/threads/useThreadFileLinks.ts line 56OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +30,21 @@30+export function useThreadFileLinks(ref: ScopedThreadRef, cwd: string | null) {31+ const visible = useThreadVisibleTurnItems(ref);32+ const paths = collectThreadFilePaths(33+ visible.map(({ item }) => item),34+ cwd,35+ );36+ const pathsKey = JSON.stringify(paths);37+ const [indexed, setIndexed] = useState(() => ({38+ key: pathsKey,39+ index: createThreadFilePathIndex(paths),40+ }));41+ let index = indexed.index;42+ if (indexed.key !== pathsKey) {43+ index = createThreadFilePathIndex(paths);44+ setIndexed({ key: pathsKey, index });45+ }46+ const canRead = useEnvironmentScope(ref.environmentId, AuthFilesystemReadScope);47+ const connection = usePreparedConnection(ref.environmentId);48+ const enabled = canRead && connection._tag === "Some";49+ const { environmentId, threadId } = ref;50+ useAtomValue(projectEnvironment.fileMetadataThread(ref));
- @@ -0,0 +93,21 @@93+ let existing = null;94+ for (let page = 1; existing === null; page++) {95+ const comments = await github(96+ `/repos/${repository}/issues/${pr}/comments?per_page=100&page=${page}`,97+ );98+ // Only this workflow's own comment: anyone can post the marker, and nobody else's is editable.99+ existing =100+ comments.find(101+ (comment) =>102+ comment.user?.login === "github-actions[bot]" && readState(comment.body) !== null,103+ ) ?? null;104+ if (comments.length < 100) break;105+ }106+ const state = mergeState(readState(existing?.body), {107+ fingerprint: process.env.FINGERPRINT ?? "",108+ client: process.env.CLIENT ?? "",109+ group: process.env.GROUP ?? "",110+ });111+ const body = JSON.stringify({ body: render(state, runUrl) });112+ if (existing) {113+ await github(`/repos/${repository}/issues/comments/${existing.id}`, { method: "PATCH", body });@@ -0,0 +60,21 @@60+ - name: Checkout default branch61+ uses: actions/checkout@v662+ with:63+ ref: ${{ github.event.repository.default_branch }}64+ sparse-checkout: |65+ /*66+ !/.repos/67+ sparse-checkout-cone-mode: false68+69+ - name: Setup Vite+70+ uses: voidzero-dev/setup-vp@v171+ with:72+ node-version-file: package.json73+ cache: true74+ run-install: |75+ args:76+ - --filter=t3code-relay...77+78+ # Destroy also runs the preview tunnel sweep, which is part of the stack.79+ - name: Destroy preview stage80+ run: vp run --filter t3code-relay destroy --stage "$STAGE" --yes --no-input@@ -0,0 +79,21 @@79+ - name: Destroy preview stage80+ run: vp run --filter t3code-relay destroy --stage "$STAGE" --yes --no-input81+ env:82+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}83+ PLANETSCALE_API_TOKEN_ID: ${{ secrets.PLANETSCALE_API_TOKEN_ID }}84+ PLANETSCALE_API_TOKEN: ${{ secrets.PLANETSCALE_API_TOKEN }}85+ AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}86+ CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}87+88+ # Only reached after a successful destroy. A failed one keeps the label,89+ # so the scheduled retry picks the PR up again.90+ - name: Clear the teardown marker91+ if: github.event.action == 'closed'92+ run: gh pr edit "${{ github.event.pull_request.number }}" --repo "$GITHUB_REPOSITORY" --remove-label relay:preview93+94+ # An unlabeled event has already removed the label, so a failed teardown95+ # must put it back or no retry will ever see the stage. Labels added with96+ # GITHUB_TOKEN do not start new runs, so this does not redeploy.97+ - name: Restore the teardown marker after a failed destroy98+ if: failure() && github.event.action == 'unlabeled'99+ run: gh pr edit "${{ github.event.pull_request.number }}" --repo "$GITHUB_REPOSITORY" --add-label relay:preview@@ -0,0 +4,21 @@4+# This job runs the PR's own code with account credentials, so it waits for an5+# approval in the `relay-preview` environment on every run. Teardown is in6+# relay-preview-cleanup.yml and never runs PR code.7+on:8+ pull_request:9+ types: [labeled, synchronize, reopened]10+11+permissions:12+ contents: read13+ pull-requests: read14+15+concurrency:16+ group: relay-preview-${{ github.event.pull_request.number }}17+ cancel-in-progress: false18+19+jobs:20+ deploy_preview:21+ name: Deploy relay preview22+ if: >-23+ github.event.pull_request.head.repo.full_name == github.repository &&24+ contains(github.event.pull_request.labels.*.name, 'relay:preview')@@ -0,0 +209,21 @@209+ - id: update210+ name: Publish the Android update211+ if: steps.expo-token.outputs.present == 'true'212+ working-directory: apps/mobile213+ shell: bash214+ env:215+ EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}216+ PR: ${{ github.event.pull_request.number }}217+ run: |218+ group="$(eas update --auto --branch "pr-$PR" --platform android --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')"219+ echo "group=$group" >> "$GITHUB_OUTPUT"220+221+ - name: Comment222+ if: steps.expo-token.outputs.present == 'true'223+ env:224+ GH_TOKEN: ${{ github.token }}225+ PR: ${{ github.event.pull_request.number }}226+ FINGERPRINT: ${{ steps.client.outputs.fingerprint }}227+ CLIENT: ${{ steps.client.outputs.link }}228+ GROUP: ${{ steps.update.outputs.group }}229+ run: node .trusted/.github/scripts/mobile-preview-comment.cjs
Pushedcb6667b
Sign in to join this conversation.




macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed