Skip to content

Commit 42df5a9

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/codex-sqlite-wal-local
2 parents efc11f7 + 09a54f0 commit 42df5a9

350 files changed

Lines changed: 12216 additions & 2952 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/actions/setup-ci-deps/action.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
description: Arguments for `vp install`, such as filters. Empty installs the whole workspace.
1414
required: false
1515
default: ""
16+
save-pnpm-store:
17+
description: Set to "false" when a concurrent job with the same install args saves the pnpm store
18+
required: false
19+
default: "true"
1620
runs:
1721
using: composite
1822
steps:
@@ -125,9 +129,11 @@ runs:
125129
# A filtered install that started from the current full store adds nothing
126130
# worth a second copy of it. A stacked PR, based on a branch other than the
127131
# default, saves a ~1 GB store only its own reruns can read, so it only restores.
132+
# Concurrent jobs with the same install args reserve one key, so the losers
133+
# compress the store for nothing; all but one pass save-pnpm-store: false.
128134
- name: Save pnpm store
129135
if: >-
130-
inputs.install == 'true' &&
136+
inputs.install == 'true' && inputs.save-pnpm-store == 'true' &&
131137
(github.event_name != 'pull_request' || github.base_ref == github.event.repository.default_branch) &&
132138
steps.pnpm_cache.outputs.cache-hit != 'true' &&
133139
(steps.pnpm_store.outputs.namespace == 'full' ||

‎.github/workflows/release-desktop.yml‎

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ on:
7777
required: false
7878
default: ""
7979
type: string
80+
# Whether this job saves the workspace pnpm store. Release's two Macs
81+
# install the same store on the same runner type, so only one saves it.
82+
save_pnpm_store:
83+
required: false
84+
default: true
85+
type: boolean
8086
version:
8187
required: true
8288
type: string
@@ -160,6 +166,7 @@ jobs:
160166
uses: ./.github/actions/setup-ci-deps
161167
with:
162168
install-args: --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts...
169+
save-pnpm-store: ${{ inputs.save_pnpm_store }}
163170
env:
164171
pnpm_config_cache_dir: ${{ runner.temp }}/pnpm-metadata
165172

@@ -408,6 +415,7 @@ jobs:
408415
run: command -v patchelf || { sudo apt-get update && sudo apt-get install -y patchelf; }
409416

410417
- name: Build CLI archive
418+
id: build_cli
411419
if: inputs.cli_archive
412420
shell: bash
413421
env:
@@ -425,25 +433,38 @@ jobs:
425433
AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
426434
run: |
427435
set -euo pipefail
428-
if [[ "${{ inputs.platform }}" == "mac" && -n "${APPLE_API_KEY:-}" ]]; then
429-
key_path="$RUNNER_TEMP/AuthKey_cli_${APPLE_API_KEY_ID}.p8"
430-
printf '%s' "$APPLE_API_KEY" > "$key_path"
431-
export APPLE_API_KEY="$key_path"
436+
extra_args=()
437+
if [[ "${{ inputs.platform }}" == "mac" ]]; then
438+
if [[ -n "${APPLE_API_KEY:-}" ]]; then
439+
key_dir="$(mktemp -d "$RUNNER_TEMP/t3-cli-notary.XXXXXXXX")"
440+
trap 'rm -rf "$key_dir"' EXIT
441+
key_path="$key_dir/AuthKey.p8"
442+
(umask 077 && printf '%s' "$APPLE_API_KEY" > "$key_path")
443+
export APPLE_API_KEY="$key_path"
444+
fi
445+
# Older release refs lack deferred notarization and still wait here.
446+
cli_help="$(node scripts/build-cli-archive.ts --help)"
447+
if [[ "$cli_help" == *--notary-submission-file* ]]; then
448+
extra_args=(--notary-submission-file "$RUNNER_TEMP/t3-cli-notary-submission")
449+
echo "deferred_notarization=true" >> "$GITHUB_OUTPUT"
450+
fi
432451
fi
433452
node scripts/build-cli-archive.ts \
434453
--platform "${{ inputs.platform }}" \
435454
--arch "${{ inputs.arch }}" \
436455
--version "${{ inputs.version }}" \
437456
--resource-monitor-dir "$RUNNER_TEMP/cli-resource-monitor" \
438-
--output-dir release-cli
457+
--output-dir release-cli \
458+
${extra_args[@]+"${extra_args[@]}"}
439459
440460
- name: Smoke-test CLI archive
441461
if: inputs.cli_archive && inputs.verify_runner == ''
442462
shell: bash
443463
run: node scripts/smoke-cli-archive.ts --archive release-cli/* --expect-version "${{ inputs.version }}"
444464

465+
# macOS uploads its archive after "Await CLI notarization" instead.
445466
- name: Upload CLI archive
446-
if: inputs.cli_archive
467+
if: inputs.cli_archive && inputs.platform != 'mac'
447468
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
448469
with:
449470
name: cli-${{ inputs.platform }}-${{ inputs.arch }}
@@ -620,6 +641,39 @@ jobs:
620641
621642
vp run dist:desktop:artifact "${args[@]}"
622643
644+
# The CLI was submitted without waiting so Apple reviews it while the
645+
# desktop builds. Notarization does not change the archive bytes, but
646+
# nothing uploads them, so nothing publishes them, until Apple accepts.
647+
# With signing configured, a missing submission id fails this step.
648+
- name: Await CLI notarization
649+
if: inputs.cli_archive && inputs.platform == 'mac' && steps.build_cli.outputs.deferred_notarization == 'true'
650+
shell: bash
651+
env:
652+
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
653+
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
654+
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
655+
run: |
656+
set -euo pipefail
657+
if [[ -n "${APPLE_API_KEY:-}" ]]; then
658+
key_dir="$(mktemp -d "$RUNNER_TEMP/t3-cli-notary.XXXXXXXX")"
659+
trap 'rm -rf "$key_dir"' EXIT
660+
key_path="$key_dir/AuthKey.p8"
661+
(umask 077 && printf '%s' "$APPLE_API_KEY" > "$key_path")
662+
export APPLE_API_KEY="$key_path"
663+
fi
664+
node scripts/build-cli-archive.ts await-notarization \
665+
--submission-file "$RUNNER_TEMP/t3-cli-notary-submission"
666+
667+
- name: Upload notarized CLI archive
668+
if: inputs.cli_archive && inputs.platform == 'mac'
669+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
670+
with:
671+
name: cli-${{ inputs.platform }}-${{ inputs.arch }}
672+
path: release-cli/*
673+
if-no-files-found: error
674+
# The archive is already gzip or zip; deflating it again saves under 2%.
675+
compression-level: 0
676+
623677
# Warm installs only touch the store index, so new content means a fetch.
624678
- name: Check staged install cache for new content
625679
id: stage_pnpm_changed

‎.github/workflows/release.yml‎

Lines changed: 88 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@ jobs:
517517
if: ${{ !cancelled() && needs.preflight.result == 'success' && needs.relay_public_config.result == 'success' }}
518518
runs-on: blacksmith-32vcpu-ubuntu-2404
519519
timeout-minutes: 30
520+
outputs:
521+
npm_launcher_artifact_id: ${{ steps.npm_launcher.outputs.artifact-id }}
520522
env:
521523
T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.relay_public_config.outputs.clerk_publishable_key }}
522524
T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.relay_public_config.outputs.clerk_jwt_template }}
@@ -604,6 +606,22 @@ jobs:
604606
if-no-files-found: error
605607
retention-days: 1
606608

609+
# publish_cli publishes this exact tarball, so the trusted publisher
610+
# needs no workspace checkout or install. It is version-matched here.
611+
- name: Build the npm launcher
612+
run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages
613+
614+
# GitHub allows a failed-jobs rerun for 30 days. publish_cli downloads
615+
# this upload by its ID, which a publish_cli-only rerun keeps.
616+
- name: Upload the npm launcher
617+
id: npm_launcher
618+
uses: actions/upload-artifact@v7
619+
with:
620+
name: npm-launcher
621+
path: npm-packages/t3.tgz
622+
if-no-files-found: error
623+
retention-days: 30
624+
607625
# One job per platform and architecture (see release-desktop.yml), each
608626
# gated only on the JS bundle. Windows targets build on Linux and run their
609627
# native checks on a Windows runner of their own architecture.
@@ -635,6 +653,8 @@ jobs:
635653
resource_key: darwin-arm64
636654
cli_archive: true
637655
launch_check: true
656+
# desktop_mac_x64 saves the shared pnpm store; this job finishes last.
657+
save_pnpm_store: false
638658

639659
desktop_mac_x64:
640660
name: Desktop macOS x64
@@ -806,6 +826,24 @@ jobs:
806826
with:
807827
install-args: --filter=@t3tools/scripts...
808828

829+
# Overlaps the artifact downloads. The wait below ends it before any
830+
# workspace script runs, so the Play key lives only in this process.
831+
# `exec` lets the runner's stop signals reach node directly.
832+
- id: android_apk
833+
name: Download nightly Android APK
834+
if: needs.preflight.outputs.release_channel == 'nightly'
835+
background: true
836+
continue-on-error: true
837+
timeout-minutes: 5
838+
env:
839+
GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
840+
PACKAGE_NAME: com.t3tools.t3code
841+
APK_OUTPUT_DIR: ${{ runner.temp }}/android-apk
842+
run: |
843+
if [ -n "$GOOGLE_PLAY_SERVICE_ACCOUNT_JSON" ]; then
844+
exec node .github/scripts/mirror-play-apk.cjs
845+
fi
846+
809847
- name: Download all desktop artifacts
810848
uses: actions/download-artifact@v8
811849
with:
@@ -820,18 +858,6 @@ jobs:
820858
merge-multiple: true
821859
path: release-assets
822860

823-
- name: Download internal Android APK for Nightly
824-
if: needs.preflight.outputs.release_channel == 'nightly'
825-
continue-on-error: true
826-
env:
827-
GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
828-
PACKAGE_NAME: com.t3tools.t3code
829-
APK_OUTPUT_DIR: release-assets
830-
run: |
831-
if [ -n "$GOOGLE_PLAY_SERVICE_ACCOUNT_JSON" ]; then
832-
node .github/scripts/mirror-play-apk.cjs
833-
fi
834-
835861
# Installers verify archives against this file, so it is written from the
836862
# signed bytes that get uploaded, never from an earlier stage.
837863
- name: Write CLI archive checksums
@@ -848,6 +874,10 @@ jobs:
848874
sha256sum "${archives[@]}" > SHA256SUMS
849875
cat SHA256SUMS
850876
877+
# Always runs, even after a failed step, and keeps that failure.
878+
- name: Wait for nightly Android APK
879+
wait: android_apk
880+
851881
# The desktop build omits the publish config for preview versions, so
852882
# electron-builder emits no updater manifests for them. Refuse to publish
853883
# if one shows up anyway: a `latest*.yml` or `nightly*.yml` on a preview
@@ -913,10 +943,13 @@ jobs:
913943
echo 'release-assets/*.yml'
914944
fi
915945
echo 'release-assets/*.tar.gz'
916-
# Only list APKs when Play has a processed internal build available.
917-
for apk in release-assets/*.apk; do
918-
[[ -f "$apk" ]] && echo "$apk"
919-
done
946+
# A failed or timed-out fetch can leave partial bytes, so list the APK
947+
# only when this attempt's fetch succeeded and Play had one ready.
948+
if [[ "${{ steps.android_apk.outcome }}" == "success" ]]; then
949+
for apk in "$RUNNER_TEMP"/android-apk/*.apk; do
950+
[[ -f "$apk" ]] && echo "$apk"
951+
done
952+
fi
920953
echo 'release-assets/SHA256SUMS'
921954
echo 'EOF'
922955
} >> "$GITHUB_OUTPUT"
@@ -1010,34 +1043,65 @@ jobs:
10101043
# nothing resolves unless asked for by name.
10111044
publish_cli:
10121045
name: Publish CLI to npm
1013-
needs: [preflight, release]
1046+
needs: [preflight, build_bundle, release]
10141047
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
10151048
runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
10161049
timeout-minutes: 15
10171050
permissions:
10181051
contents: read
10191052
id-token: write
10201053
steps:
1054+
# Only what setup-ci-deps reads to install the project's Node and npm.
10211055
- name: Checkout
10221056
uses: actions/checkout@v6
10231057
with:
10241058
ref: ${{ needs.preflight.outputs.ref }}
10251059
sparse-checkout: |
1026-
/*
1027-
!/.repos/
1060+
/.github/actions/setup-ci-deps/
1061+
/package.json
1062+
/pnpm-workspace.yaml
10281063
sparse-checkout-cone-mode: false
10291064

1030-
- name: Setup dependencies
1065+
- name: Setup Node.js
10311066
uses: ./.github/actions/setup-ci-deps
10321067
with:
1033-
install-args: --filter=t3... --filter=@t3tools/scripts...
1068+
install: "false"
10341069

1035-
- name: Build the npm launcher
1036-
run: node scripts/build-npm-launcher.ts --version "${{ needs.preflight.outputs.version }}" --output-dir npm-packages
1070+
# Bind to build_bundle's exact upload: a name lookup takes the newest
1071+
# same-name artifact, and an empty ID downloads every artifact in the
1072+
# run. A later same-name upload hides this ID, so the download fails.
1073+
- name: Check the npm launcher artifact ID
1074+
env:
1075+
ARTIFACT_ID: ${{ needs.build_bundle.outputs.npm_launcher_artifact_id }}
1076+
run: |
1077+
if [[ ! "$ARTIFACT_ID" =~ ^[1-9][0-9]*$ ]]; then
1078+
echo "::error::build_bundle gave no valid npm-launcher artifact ID: '$ARTIFACT_ID'." >&2
1079+
exit 1
1080+
fi
1081+
1082+
- name: Download the npm launcher
1083+
uses: actions/download-artifact@v8
1084+
with:
1085+
artifact-ids: ${{ needs.build_bundle.outputs.npm_launcher_artifact_id }}
1086+
path: npm-packages
1087+
digest-mismatch: error
1088+
1089+
- name: Check the npm launcher version
1090+
env:
1091+
RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
1092+
run: |
1093+
built="$(tar -xzOf npm-packages/t3.tgz package/package.json | jq -r .version)"
1094+
if [[ "$built" != "$RELEASE_VERSION" ]]; then
1095+
echo "::error::npm-launcher holds t3@$built, expected t3@$RELEASE_VERSION." >&2
1096+
exit 1
1097+
fi
10371098
10381099
- name: Publish the npm launcher
1100+
env:
1101+
DIST_TAG: ${{ needs.preflight.outputs.cli_dist_tag }}
10391102
run: |
1040-
if ! node apps/server/scripts/cli.ts publish --packages-dir npm-packages --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --provenance --verbose; then
1103+
# The ./ keeps npm from reading the path as a GitHub owner/repo spec.
1104+
if ! npm publish --access public --tag "$DIST_TAG" --provenance ./npm-packages/t3.tgz; then
10411105
echo "::error::npm publish failed. Make sure package t3 has a trusted publisher registered for .github/workflows/release.yml (see docs/operations/release.md)." >&2
10421106
exit 1
10431107
fi

‎apps/desktop/src/app/DesktopAppIdentity.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const layerElectronApp = (calls: ElectronAppCalls) =>
4242
metadata: Effect.die("unexpected metadata read"),
4343
name: Effect.succeed("T3 Code"),
4444
systemLocale: Effect.succeed("en-US"),
45+
preferredSystemLanguages: Effect.succeed(["en-US"]),
4546
whenReady: Effect.void,
4647
requestSingleInstanceLock: Effect.succeed(true),
4748
quit: Effect.void,

‎apps/desktop/src/app/DesktopLifecycle.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function layerElectronApp(
3939
metadata: Effect.die("unexpected metadata read"),
4040
name: Effect.succeed("T3 Code"),
4141
systemLocale: Effect.succeed("en-US"),
42+
preferredSystemLanguages: Effect.succeed(["en-US"]),
4243
whenReady: Effect.void,
4344
requestSingleInstanceLock: Effect.succeed(true),
4445
quit,

‎apps/desktop/src/electron/ElectronApp.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class ElectronApp extends Context.Service<
4646
readonly name: Effect.Effect<string>;
4747
/** Packaged builds ship only en-US; app.getLocale() and Intl defaults do not reflect the OS locale. */
4848
readonly systemLocale: Effect.Effect<string>;
49+
readonly preferredSystemLanguages: Effect.Effect<ReadonlyArray<string>>;
4950
readonly whenReady: Effect.Effect<void, ElectronAppWhenReadyError>;
5051
readonly requestSingleInstanceLock: Effect.Effect<boolean>;
5152
readonly quit: Effect.Effect<void>;
@@ -155,6 +156,7 @@ export const make = ElectronApp.of({
155156
}
156157
return toSystemLocaleTag(identifier, hourCycle);
157158
}),
159+
preferredSystemLanguages: Effect.sync(() => Electron.app.getPreferredSystemLanguages()),
158160
whenReady: Effect.gen(function* () {
159161
const isPackaged = Electron.app.isPackaged;
160162
yield* Effect.tryPromise({

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { installNotificationBadge } from "./methods/notificationBadge.ts";
66
import { getClientSettings, setClientSettings } from "./methods/clientSettings.ts";
77
import { getConnectionCatalog, setConnectionCatalog } from "./methods/connectionCatalog.ts";
88
import {
9+
getHostEnvironmentId,
910
getLocalEnvironmentEnabled,
1011
setLocalEnvironmentEnabled,
1112
} from "./methods/localEnvironment.ts";
@@ -38,6 +39,7 @@ import {
3839
getLocalEnvironmentBearerToken,
3940
installRelayTelemetryEnabled,
4041
getSystemLocale,
42+
getPreferredSystemLanguages,
4143
getWindowFullscreenState,
4244
openExternal,
4345
readMedia,
@@ -94,10 +96,12 @@ export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers"
9496
yield* ipc.handleSync(getAppBranding);
9597
yield* installRelayTelemetryEnabled();
9698
yield* ipc.handleSync(getSystemLocale);
99+
yield* ipc.handleSync(getPreferredSystemLanguages);
97100
yield* ipc.handleSync(getWindowFullscreenState);
98101
yield* ipc.handleSync(getLocalEnvironmentBootstraps);
99102
yield* ipc.handleSync(getLocalEnvironmentEnabled);
100103
yield* ipc.handle(setLocalEnvironmentEnabled);
104+
yield* ipc.handle(getHostEnvironmentId);
101105
yield* ipc.handle(getLocalEnvironmentBearerToken);
102106

103107
yield* ipc.handle(getClientSettings);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ export const CLI_COMMAND_UNINSTALL_CHANNEL = "desktop:cli-command-uninstall";
3434
export const GET_APP_BRANDING_CHANNEL = "desktop:get-app-branding";
3535
export const GET_RELAY_TELEMETRY_ENABLED_CHANNEL = "desktop:get-relay-telemetry-enabled";
3636
export const GET_SYSTEM_LOCALE_CHANNEL = "desktop:get-system-locale";
37+
export const GET_PREFERRED_SYSTEM_LANGUAGES_CHANNEL = "desktop:get-preferred-system-languages";
3738
export const GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL = "desktop:get-local-environment-bootstraps";
3839
export const GET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL = "desktop:get-local-environment-enabled";
3940
export const SET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL = "desktop:set-local-environment-enabled";
41+
export const GET_HOST_ENVIRONMENT_ID_CHANNEL = "desktop:get-host-environment-id";
4042
export const GET_LOCAL_ENVIRONMENT_BEARER_TOKEN_CHANNEL =
4143
"desktop:get-local-environment-bearer-token";
4244
export const GET_CLIENT_SETTINGS_CHANNEL = "desktop:get-client-settings";

0 commit comments

Comments
 (0)