Skip to content

Commit 2fda067

Browse files
Merge branch 'main' into fix/windows-sign-native-addons
2 parents 939a597 + 33b650a commit 2fda067

69 files changed

Lines changed: 2874 additions & 323 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.

‎.github/workflows/desktop-macos-preview.yml‎

Lines changed: 209 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,38 @@ name: Desktop macOS Preview
22

33
on:
44
pull_request:
5-
types: [labeled, synchronize, reopened]
5+
types: [labeled, unlabeled, synchronize, reopened, closed]
66

77
permissions:
88
contents: read
9-
pull-requests: write
109

10+
# Build events and cleanup events use separate groups: a push must cancel a
11+
# stale in-flight build, but must never cancel a cleanup run mid-delete. The
12+
# publish job re-checks PR state before uploading to cover the reverse race.
1113
concurrency:
12-
group: desktop-macos-preview-${{ github.event.pull_request.number }}
13-
cancel-in-progress: true
14+
group: desktop-macos-preview-${{ github.event.pull_request.number }}-${{ contains(fromJSON('["closed", "unlabeled"]'), github.event.action) && 'cleanup' || 'build' }}
15+
# Cleanup runs must complete (a close event right after an unlabel queues
16+
# behind the running cleanup instead of canceling it mid-delete), and events
17+
# that skip the build job, such as adding an unrelated label, must not
18+
# cancel an in-flight build either.
19+
cancel-in-progress: ${{ !contains(fromJSON('["closed", "unlabeled"]'), github.event.action) && (github.event.action != 'labeled' || github.event.label.name == 'preview:mac') }}
1420

1521
jobs:
22+
# Builds run PR code, so this job keeps a read-only token. Publishing to the
23+
# release happens in the publish job below, which never checks out PR code.
1624
build:
1725
name: Build macOS Apple Silicon preview
1826
if: >-
27+
github.event.action != 'closed' &&
28+
github.event.action != 'unlabeled' &&
1929
github.event.pull_request.head.repo.full_name == github.repository &&
2030
contains(github.event.pull_request.labels.*.name, 'preview:mac') &&
2131
(github.event.action != 'labeled' || github.event.label.name == 'preview:mac')
2232
runs-on: blacksmith-12vcpu-macos-26
2333
timeout-minutes: 30
34+
outputs:
35+
dmg_name: ${{ steps.build.outputs.dmg_name }}
36+
version: ${{ steps.version.outputs.version }}
2437
steps:
2538
- name: Checkout
2639
uses: actions/checkout@v6
@@ -93,8 +106,9 @@ jobs:
93106
fi
94107
printf 'dmg_name=%s\n' "$(basename "${dmg_files[0]}")" >> "$GITHUB_OUTPUT"
95108
96-
- id: upload
97-
name: Upload macOS DMG
109+
# archive: false uploads the file as its own artifact named after the
110+
# file, so the publish job downloads by *.dmg pattern, not by name.
111+
- name: Upload macOS DMG
98112
uses: actions/upload-artifact@v7
99113
with:
100114
path: release/*.dmg
@@ -103,21 +117,124 @@ jobs:
103117
overwrite: true
104118
retention-days: 7
105119

120+
# Release assets download without a GitHub account, unlike workflow
121+
# artifacts. All preview DMGs live on one rolling prerelease tagged
122+
# "desktop-preview" (release.yml only matches v*.*.* tags), so publishing a
123+
# build never notifies release watchers. This job holds the write token and
124+
# only handles the artifact the build job produced; it never runs PR code.
125+
publish:
126+
name: Publish anonymous download
127+
needs: build
128+
runs-on: blacksmith-8vcpu-ubuntu-2404
129+
timeout-minutes: 10
130+
permissions:
131+
contents: write
132+
pull-requests: write
133+
steps:
134+
- name: Download macOS DMG
135+
uses: actions/download-artifact@v8
136+
with:
137+
pattern: "*.dmg"
138+
merge-multiple: true
139+
path: release
140+
141+
- id: upload
142+
name: Upload DMG to the rolling preview release
143+
shell: bash
144+
env:
145+
GH_TOKEN: ${{ github.token }}
146+
PR_NUMBER: ${{ github.event.pull_request.number }}
147+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
148+
run: |
149+
set -euo pipefail
150+
151+
tag="desktop-preview"
152+
153+
# True while the PR is open and still carries the preview label.
154+
preview_eligible() {
155+
[[ "$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" \
156+
--json state,labels \
157+
--jq '.state + " " + (.labels | map(.name) | contains(["preview:mac"]) | tostring)')" == "OPEN true" ]]
158+
}
159+
160+
# The build ran for many minutes. If the PR closed or lost the label
161+
# meanwhile, cleanup already ran in its own concurrency group, so
162+
# publishing now would resurrect a deleted download.
163+
if ! preview_eligible; then
164+
echo "PR closed or preview label removed while building. Skipping publish."
165+
exit 0
166+
fi
167+
168+
dmg_path="$(find release -type f -name '*.dmg' -print -quit)"
169+
if [[ -z "$dmg_path" ]]; then
170+
echo "No DMG found in the downloaded artifact." >&2
171+
exit 1
172+
fi
173+
174+
# The filename comes out of the build, which runs PR code. Requiring
175+
# this PR's marker keeps a build from clobbering or deleting another
176+
# PR's asset, since those names carry a different -pr.N. marker.
177+
if [[ "$(basename "$dmg_path")" != *"-pr.${PR_NUMBER}."* ]]; then
178+
echo "DMG name '$(basename "$dmg_path")' does not carry this PR's -pr.${PR_NUMBER}. marker. Refusing to publish." >&2
179+
exit 1
180+
fi
181+
182+
if ! gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
183+
# "|| true" tolerates a concurrent publish job creating the
184+
# release between the check and the create.
185+
gh release create "$tag" \
186+
--repo "$GITHUB_REPOSITORY" \
187+
--target "$DEFAULT_BRANCH" \
188+
--prerelease \
189+
--title "Desktop preview builds" \
190+
--notes "Rolling unsigned desktop builds from pull requests with a preview label. Each download is removed when its pull request closes or loses the label. Install stable builds from the latest release instead." \
191+
|| true
192+
fi
193+
194+
# Keep one DMG per PR: drop this PR's older builds first. The
195+
# trailing dot keeps -pr.12. from matching -pr.123. builds.
196+
gh release view "$tag" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name' \
197+
| { grep -F -- "-pr.${PR_NUMBER}." || true; } \
198+
| while read -r asset; do
199+
gh release delete-asset "$tag" "$asset" --repo "$GITHUB_REPOSITORY" --yes \
200+
|| echo "Asset $asset was already removed by a concurrent run."
201+
done
202+
203+
gh release upload "$tag" "$dmg_path" --repo "$GITHUB_REPOSITORY" --clobber
204+
205+
# Re-check after uploading. A cleanup run that started during the
206+
# upload listed assets before ours existed, so it cannot delete it.
207+
# Whichever writer acts last sees the final PR state; if the preview
208+
# became ineligible, delete what we just uploaded.
209+
if ! preview_eligible; then
210+
gh release delete-asset "$tag" "$(basename "$dmg_path")" --repo "$GITHUB_REPOSITORY" --yes \
211+
|| echo "Asset was already removed by a concurrent run."
212+
echo "PR closed or preview label removed during upload. Removed the download."
213+
exit 0
214+
fi
215+
216+
echo "download_url=https://github.com/${GITHUB_REPOSITORY}/releases/download/${tag}/$(basename "$dmg_path")" >> "$GITHUB_OUTPUT"
217+
106218
- name: Comment download link
219+
if: steps.upload.outputs.download_url != ''
107220
uses: actions/github-script@v8
108221
env:
109-
ARTIFACT_URL: ${{ steps.upload.outputs.artifact-url }}
110-
DMG_NAME: ${{ steps.build.outputs.dmg_name }}
222+
DOWNLOAD_URL: ${{ steps.upload.outputs.download_url }}
223+
DMG_NAME: ${{ needs.build.outputs.dmg_name }}
111224
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
112-
PREVIEW_VERSION: ${{ steps.version.outputs.version }}
225+
PREVIEW_VERSION: ${{ needs.build.outputs.version }}
113226
with:
114227
script: |
115228
const { data: pullRequest } = await github.rest.pulls.get({
116229
owner: context.repo.owner,
117230
repo: context.repo.repo,
118231
pull_number: context.payload.pull_request.number,
119232
});
120-
if (pullRequest.head.sha !== process.env.HEAD_SHA) {
233+
if (
234+
pullRequest.head.sha !== process.env.HEAD_SHA ||
235+
pullRequest.state !== "open" ||
236+
!pullRequest.labels.some((label) => label.name === "preview:mac")
237+
) {
121238
core.info("Skipping the outdated macOS preview comment.");
122239
return;
123240
}
@@ -127,7 +244,7 @@ jobs:
127244
marker,
128245
"### macOS preview",
129246
"",
130-
`[Download Apple Silicon DMG](${process.env.ARTIFACT_URL})`,
247+
`[Download Apple Silicon DMG](${process.env.DOWNLOAD_URL})`,
131248
"",
132249
`Version: ${process.env.PREVIEW_VERSION}`,
133250
`Commit: ${process.env.HEAD_SHA.slice(0, 7)}`,
@@ -137,10 +254,10 @@ jobs:
137254
`xattr -d com.apple.quarantine ~/Downloads/${process.env.DMG_NAME}`,
138255
"```",
139256
"",
140-
"The download requires GitHub access and expires after 7 days.",
257+
"No GitHub sign-in is needed. The download stays available until this PR closes or the preview label is removed.",
141258
].join("\n");
142259
143-
const { data: comments } = await github.rest.issues.listComments({
260+
const comments = await github.paginate(github.rest.issues.listComments, {
144261
owner: context.repo.owner,
145262
repo: context.repo.repo,
146263
issue_number: context.payload.pull_request.number,
@@ -163,3 +280,82 @@ jobs:
163280
body,
164281
});
165282
}
283+
284+
# The way out: closing the PR or removing the label deletes its DMG from the
285+
# rolling release and updates the PR comment to say so.
286+
cleanup:
287+
name: Remove preview download
288+
if: >-
289+
github.event.pull_request.head.repo.full_name == github.repository &&
290+
((github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'preview:mac')) ||
291+
(github.event.action == 'unlabeled' && github.event.label.name == 'preview:mac'))
292+
runs-on: blacksmith-8vcpu-ubuntu-2404
293+
timeout-minutes: 10
294+
permissions:
295+
contents: write
296+
pull-requests: write
297+
steps:
298+
- id: delete
299+
name: Delete this PR's preview assets
300+
shell: bash
301+
env:
302+
GH_TOKEN: ${{ github.token }}
303+
PR_NUMBER: ${{ github.event.pull_request.number }}
304+
run: |
305+
set -euo pipefail
306+
307+
tag="desktop-preview"
308+
309+
# A stale cleanup must not delete a download that became valid
310+
# again. If the PR is open and labeled once more, the next publish
311+
# owns this PR's assets and replaces them itself.
312+
if [[ "$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" \
313+
--json state,labels \
314+
--jq '.state + " " + (.labels | map(.name) | contains(["preview:mac"]) | tostring)')" == "OPEN true" ]]; then
315+
echo "PR is open and labeled again. Skipping cleanup."
316+
echo "removed=false" >> "$GITHUB_OUTPUT"
317+
exit 0
318+
fi
319+
320+
echo "removed=true" >> "$GITHUB_OUTPUT"
321+
322+
if ! gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
323+
echo "No preview release exists. Nothing to clean up."
324+
exit 0
325+
fi
326+
327+
gh release view "$tag" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name' \
328+
| { grep -F -- "-pr.${PR_NUMBER}." || true; } \
329+
| while read -r asset; do
330+
gh release delete-asset "$tag" "$asset" --repo "$GITHUB_REPOSITORY" --yes \
331+
|| echo "Asset $asset was already removed by a concurrent run."
332+
done
333+
334+
- name: Mark the preview comment as removed
335+
if: steps.delete.outputs.removed == 'true'
336+
uses: actions/github-script@v8
337+
with:
338+
script: |
339+
const marker = "<!-- desktop-macos-preview -->";
340+
const comments = await github.paginate(github.rest.issues.listComments, {
341+
owner: context.repo.owner,
342+
repo: context.repo.repo,
343+
issue_number: context.payload.pull_request.number,
344+
per_page: 100,
345+
});
346+
const existing = comments.find((comment) => comment.body?.includes(marker));
347+
if (!existing) {
348+
return;
349+
}
350+
351+
await github.rest.issues.updateComment({
352+
owner: context.repo.owner,
353+
repo: context.repo.repo,
354+
comment_id: existing.id,
355+
body: [
356+
marker,
357+
"### macOS preview",
358+
"",
359+
"The preview download was removed because this PR closed or the preview label was removed.",
360+
].join("\n"),
361+
});

‎.github/workflows/release.yml‎

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
- "v*.*.*"
77
- "!v*-nightly.*"
88
schedule:
9-
- cron: "0 */3 * * *"
9+
# Off minute zero: GitHub delays scheduled runs most at the top of the hour.
10+
- cron: "7 */3 * * *"
1011
workflow_dispatch:
1112
inputs:
1213
channel:
@@ -22,6 +23,17 @@ on:
2223
required: false
2324
type: string
2425

26+
# Serialize nightlies (scheduled and manual) so overlapping runs cannot build
27+
# the same commit twice or publish out of order. Stable tag releases get their
28+
# own group so a nightly never blocks them. Running publishers are never
29+
# canceled, and queue: max keeps every pending run instead of the default
30+
# newest-wins single slot, so a queued stable tag can never be silently
31+
# dropped. Queued nightlies with no new commits skip via check_changes.
32+
concurrency:
33+
group: release-${{ (github.event_name == 'schedule' || inputs.channel == 'nightly') && 'nightly' || 'stable' }}
34+
cancel-in-progress: false
35+
queue: max
36+
2537
permissions:
2638
contents: read
2739
id-token: none
@@ -199,8 +211,14 @@ jobs:
199211

200212
relay_public_config:
201213
name: Resolve T3 Connect public config
202-
needs: preflight
203-
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
214+
# Consumes only the commit SHA, not preflight's resolved version, so it runs
215+
# alongside preflight instead of after it. The condition mirrors preflight's:
216+
# check_changes is skipped on non-schedule events (skipped is neither failure
217+
# nor success, so success() would be wrong here).
218+
needs: [check_changes]
219+
if: |
220+
!failure() && !cancelled() &&
221+
(github.event_name != 'schedule' || needs.check_changes.outputs.has_changes == 'true')
204222
runs-on: blacksmith-8vcpu-ubuntu-2404
205223
timeout-minutes: 5
206224
environment:
@@ -222,7 +240,7 @@ jobs:
222240
- name: Checkout
223241
uses: actions/checkout@v6
224242
with:
225-
ref: ${{ needs.preflight.outputs.ref }}
243+
ref: ${{ github.sha }}
226244
sparse-checkout: |
227245
/*
228246
!/.repos/
@@ -295,15 +313,19 @@ jobs:
295313
# machine. node-pty is N-API, so one binary works across all WSL Node versions.
296314
build_wsl_node_pty:
297315
name: Build WSL node-pty (linux-x64)
298-
needs: [preflight]
299-
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
316+
# Same gating as relay_public_config: only the commit SHA is needed, so this
317+
# runs alongside preflight. See the condition comment there.
318+
needs: [check_changes]
319+
if: |
320+
!failure() && !cancelled() &&
321+
(github.event_name != 'schedule' || needs.check_changes.outputs.has_changes == 'true')
300322
runs-on: blacksmith-8vcpu-ubuntu-2404
301323
timeout-minutes: 15
302324
steps:
303325
- name: Checkout
304326
uses: actions/checkout@v6
305327
with:
306-
ref: ${{ needs.preflight.outputs.ref }}
328+
ref: ${{ github.sha }}
307329
sparse-checkout: |
308330
/*
309331
!/.repos/
@@ -758,9 +780,8 @@ jobs:
758780
- name: Align package versions to release version
759781
run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
760782

761-
- name: Build web package
762-
run: vp run --filter @t3tools/web build
763-
783+
# The t3 build task depends on @t3tools/web#build, so the web client is
784+
# built (once) as part of this step.
764785
- name: Build CLI package
765786
run: vp run --filter t3 build
766787

‎.macroscope/check-run-agents/ui-consistency.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ The goal is not to minimize CSS or class counts at any cost. The goal is to put
7070
- Do not treat a screenshot as proof of keyboard, overflow, scrollbar, responsive, or runtime-theme behavior. Pair visual evidence with source, computed-style, emitted-CSS, or interaction checks as appropriate.
7171
- Be alert to shared primitive color indirection. When a primitive routes icon color through a CSS variable, ensure migrated contextual icons retain their intended tone, including pressed and disabled states.
7272

73+
## Environment routing in shared renderers
74+
75+
- A shared renderer that performs an environment-scoped action — a server RPC such as opening or revealing a file, an environment-gated capability check, or an OS-derived label — must resolve its target environment from explicit scope: the bound thread's `environmentId`, or an `environmentId` prop threaded from the owning surface. Never let it silently fall back to the globally active environment. Multi-environment surfaces (pull request panels, review annotations, cross-environment listings) can render content from environment B while environment A is active; a silent fallback sends B's paths to A's server and presents A's platform wording.
76+
- When a call site cannot supply an explicit environment scope, suppress the environment-scoped actions at that call site rather than guessing. A hidden menu item is correct; an item that targets the wrong server is a concrete finding.
77+
- Capability gating, action dispatch, and user-facing labels must all read from the same environment's server config that the action will execute against. Flag a renderer whose label derives from one environment while its RPC targets another.
78+
- Flag new call sites of shared markdown, chip, or menu renderers that trigger environment actions without passing explicit scope, and flag new environment-action props whose default reintroduces an active-environment fallback.
79+
7380
## Change discipline
7481

7582
- Review the pull request's changed scope and directly affected consumers. Do not turn a focused PR into a demand for unrelated legacy cleanup.

‎apps/desktop/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@t3tools/desktop",
3-
"version": "0.0.33",
3+
"version": "0.0.34",
44
"private": true,
55
"type": "module",
66
"main": "dist-electron/main.cjs",

0 commit comments

Comments
 (0)