Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .agents/skills/update-t3code/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ and anything worth testing on the currently installed version.

- Make the agreed changes in the style of the existing patches.
- Run `./scripts/build-flatpak build` from the repo root. It runs the desktop
tests, the server tests listed in `flatpak/modules/t3code.yml` and both
typechecks, but no web tests. Check web changes directly. Make sure the test
tests, the server tests listed in `flatpak/modules/t3code.yml`, both
typechecks, and upstream's lint and format checks on the patched files, but
no web tests or web typecheck. Check web changes directly. Make sure the test
files the manifest lists still exist.
- Run `./scripts/test-packaged` to check the built package where the sandbox
and host meet. When the release changes a flow these checks don't cover,
Expand Down
10 changes: 5 additions & 5 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ or update them.
```

This builds the package, runs desktop tests and the editor launcher test,
typechecks the desktop and server, and writes
`build-flatpak/com.t3tools.t3code.flatpak`.
typechecks the desktop and server, lints and format-checks the files the
patches change, and writes `build-flatpak/com.t3tools.t3code.flatpak`.

To build and install the package for your user, then launch it:

Expand All @@ -30,9 +30,9 @@ Build state and output stay in `build-flatpak/`.
The packaged app checks install a build in a throwaway container, launch it
headless, and check the places where the sandbox and host meet: the host
server, agent CLIs found through the login shell, downloads, terminals,
editors, SSH, Tailscale, managed policy, database maintenance, and the recovery
screen when the host is out of reach. Docker runs them by default; set
`CONTAINER_ENGINE=podman` to use Podman.
editors, SSH, Tailscale, managed policy, deleting the old database, reclaiming
database space, and the recovery screen when the host is out of reach. Docker
runs them by default; set `CONTAINER_ENGINE=podman` to use Podman.

```sh
./scripts/test-packaged # the build from ./scripts/build-flatpak build
Expand Down
9 changes: 5 additions & 4 deletions docs/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ on this repository and store its client ID as the Actions variable
New commits cancel older validation runs for the same PR. Website-only changes
skip package validation and do not change the build cache key.
The workflow applies the patches, builds the Flatpak, runs desktop tests and
the editor launcher test, and typechecks the desktop and server. The WSL test
file is excluded because some of its tests inspect host processes that the
Flatpak build sandbox cannot see. It then installs the build in the CI
container and runs the packaged app checks described in
the editor launcher test, typechecks the desktop and server, and lints and
format-checks the files the patches change. The WSL test file is excluded
because some of its tests inspect host processes that the Flatpak build sandbox
cannot see. It then installs the build in the CI container and runs the
packaged app checks described in
[Building](building.md#testing-the-packaged-app). Failed checks upload their
screenshots and logs as a workflow artifact.

Expand Down
9 changes: 9 additions & 0 deletions flatpak/com.t3tools.t3code.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
<launchable type="desktop-id">com.t3tools.t3code.desktop</launchable>
<url type="homepage">https://t3.codes</url>
<releases>
<release version="0.1.8" date="2026-11-09">
<url type="details">https://github.com/pingdotgg/t3code/releases/tag/v0.1.8</url>
<description>
<p>Update to T3 Code 0.1.8.</p>
<p>Reclaiming database space now uses T3 Code's own Reclaim button in
Settings. Settings still offers to delete the database kept from before
0.1.0. Browser import keeps finding your browsers' profiles.</p>
</description>
</release>
<release version="0.1.7-1" date="2026-11-04">
<url type="details">https://github.com/pingdotgg/t3code/releases/tag/v0.1.7</url>
<description>
Expand Down
14 changes: 11 additions & 3 deletions flatpak/modules/t3code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,18 @@ test-commands:
src/cli/doctor.test.ts
src/persistence/DatabaseMaintenance.test.ts
- pnpm --filter t3 typecheck
# Upstream's lint and format rules, on the files the patches change or add.
- >-
git ls-files --modified --others --exclude-standard
-- '*.ts' '*.tsx' ':!flatpak-output' ':!flatpak-package'
> patched-files
- xargs -r -a patched-files pnpm exec vp lint --report-unused-disable-directives
- xargs -r -a patched-files pnpm exec vp fmt --check
sources:
- type: git
url: https://github.com/pingdotgg/t3code.git
tag: v0.1.7
commit: 322f6544dfad0a3c8a0c8cbecf2c7f7874b14268
tag: v0.1.8
commit: bf469bb19669671d0df2efda74ed73867a7137c0
x-checker-data:
type: json
url: https://api.github.com/repos/pingdotgg/t3code/releases/latest
Expand All @@ -79,10 +86,11 @@ sources:
- ../../patches/0008-flatpak-cli-launcher.patch
- ../../patches/0009-flatpak-server-updates.patch
- ../../patches/0010-flatpak-browser-requirements.patch
- ../../patches/0011-flatpak-database-maintenance.patch
- ../../patches/0011-flatpak-legacy-database.patch
- ../../patches/0012-flatpak-update-channel.patch
- ../../patches/0013-flatpak-startup-recovery.patch
- ../../patches/0014-flatpak-managed-policy.patch
- ../../patches/0015-flatpak-browser-import.patch
use-git: true
- type: dir
path: ../package
Expand Down
7 changes: 0 additions & 7 deletions flatpak/package/host-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,4 @@ unset T3CODE_DESKTOP_HTTPS_ENDPOINTS T3CODE_TAILSCALE_SERVE T3CODE_TAILSCALE_SER
cd "$HOME"

export ELECTRON_RUN_AS_NODE=1
# Desktop maintenance runs with the same runtime and sanitized host environment.
# The desktop stops its server first when compacting. No user-facing CLI is installed.
if [ "${1:-}" = "--database-maintenance" ]; then
shift
exec "$T3CODE_FLATPAK_SERVER" --require "$T3CODE_FLATPAK_COMPILE_CACHE" "$T3CODE_FLATPAK_ENTRY" flatpak-database-maintenance --base-dir "$T3CODE_HOME" "$@"
fi

exec "$T3CODE_FLATPAK_SERVER" --require "$T3CODE_FLATPAK_COMPILE_CACHE" "$T3CODE_FLATPAK_ENTRY" --bootstrap-fd 3
64 changes: 36 additions & 28 deletions patches/0001-flatpak-desktop-integration.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/apps/desktop/src/app/DesktopConfig.ts b/apps/desktop/src/app/DesktopConfig.ts
index 11f975a6b8..586db466b6 100644
index ef2909045b..98a7852535 100644
--- a/apps/desktop/src/app/DesktopConfig.ts
+++ b/apps/desktop/src/app/DesktopConfig.ts
@@ -37,6 +37,7 @@ export const DesktopConfig = Config.all({
Expand Down Expand Up @@ -137,10 +137,10 @@ index cfa8498ae6..4626a2601c 100644
}
yield* writeDesktopEntry;
diff --git a/apps/desktop/src/app/DesktopPreReadyPlatform.test.ts b/apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
index f2b176ee37..0baac17608 100644
index 22bfc969c4..da1d29ea71 100644
--- a/apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
+++ b/apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
@@ -60,6 +60,23 @@ vi.mock("node:child_process", () => ({
@@ -61,6 +61,24 @@ import * as DesktopConfig from "./DesktopConfig.ts";
import * as DesktopPreReadyPlatform from "./DesktopPreReadyPlatform.ts";

describe("DesktopPreReadyPlatform", () => {
Expand All @@ -155,6 +155,7 @@ index f2b176ee37..0baac17608 100644
+ Effect.provide(
+ DesktopPreReadyPlatform.layer.pipe(
+ Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
+ Layer.provide(DesktopConfig.layerTest({ FLATPAK_ID: "com.t3tools.t3code" })),
+ ),
+ ),
+ Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())),
Expand All @@ -165,25 +166,26 @@ index f2b176ee37..0baac17608 100644
appendSwitchMock.mockReset();
getSwitchValueMock.mockReset();
diff --git a/apps/desktop/src/app/DesktopPreReadyPlatform.ts b/apps/desktop/src/app/DesktopPreReadyPlatform.ts
index d77544f54b..cbf87853eb 100644
index ff8c97b8f8..7214f0d672 100644
--- a/apps/desktop/src/app/DesktopPreReadyPlatform.ts
+++ b/apps/desktop/src/app/DesktopPreReadyPlatform.ts
@@ -9,6 +9,7 @@ import * as Layer from "effect/Layer";
import * as Electron from "electron";
import * as HostProcess from "@t3tools/shared/HostProcess";
@@ -56,6 +56,7 @@ const LinuxDesktopEntryConfig = Config.all({
xdgDataHome: trimmedString("XDG_DATA_HOME"),
launcherPath: trimmedString("T3CODE_DESKTOP_LAUNCHER_PATH"),
appImagePath: trimmedString("APPIMAGE"),
+ flatpakId: trimmedString("FLATPAK_ID"),
});

+import { flatpakAppId } from "./Flatpak.ts";
import * as DesktopEarlyElectronStartup from "./DesktopEarlyElectronStartup.ts";
import { resolveDesktopAppBranding } from "./DesktopEnvironment.ts";
import { renderUrlHandlerDesktopEntry } from "./DesktopLinuxUrlHandler.ts";
@@ -75,50 +76,52 @@ export const make = Effect.gen(function* () {
/** @public */
@@ -85,54 +86,56 @@ export const make = Effect.gen(function* () {
});
// The portal also requires a valid desktop entry. An AppImage update may
// have removed the executable referenced by the previous launch's entry.
- try {
- const applicationsDir = NodePath.posix.join(
- process.env.XDG_DATA_HOME?.trim() ||
- Option.getOrElse(linuxDesktopEntryConfig.xdgDataHome, () =>
- NodePath.posix.join(homeDirectory, ".local", "share"),
- ),
- "applications",
- );
- NodeFS.mkdirSync(applicationsDir, { recursive: true });
Expand Down Expand Up @@ -215,20 +217,16 @@ index d77544f54b..cbf87853eb 100644
- appVersion: Electron.app.getVersion(),
- }).displayName,
- execTarget:
- process.env.T3CODE_DESKTOP_LAUNCHER_PATH?.trim() ||
- process.env.APPIMAGE?.trim() ||
- process.execPath,
- scheme: ElectronProtocol.getDesktopScheme(linux.isDevelopment),
- ...(iconPath === undefined ? {} : { iconPath }),
- }),
- "utf8",
- );
- } catch {}
+ if (flatpakAppId(process.env, platform) === null) {
- Option.getOrUndefined(
- Option.orElse(
- linuxDesktopEntryConfig.launcherPath,
- () => linuxDesktopEntryConfig.appImagePath,
+ if (Option.isNone(linuxDesktopEntryConfig.flatpakId)) {
+ try {
+ const applicationsDir = NodePath.posix.join(
+ process.env.XDG_DATA_HOME?.trim() ||
+ Option.getOrElse(linuxDesktopEntryConfig.xdgDataHome, () =>
+ NodePath.posix.join(homeDirectory, ".local", "share"),
+ ),
+ "applications",
+ );
+ NodeFS.mkdirSync(applicationsDir, { recursive: true });
Expand All @@ -247,7 +245,14 @@ index d77544f54b..cbf87853eb 100644
+ NodePath.posix.join(
+ Electron.app.getAppPath(),
+ "apps/desktop/prod-resources/icon.png",
+ ),
),
- ) ?? process.execPath,
- scheme: ElectronProtocol.getDesktopScheme(linux.isDevelopment),
- ...(iconPath === undefined ? {} : { iconPath }),
- }),
- "utf8",
- );
- } catch {}
+ iconPath,
+ );
+ } catch {}
Expand All @@ -260,9 +265,12 @@ index d77544f54b..cbf87853eb 100644
+ appVersion: Electron.app.getVersion(),
+ }).displayName,
+ execTarget:
+ process.env.T3CODE_DESKTOP_LAUNCHER_PATH?.trim() ||
+ process.env.APPIMAGE?.trim() ||
+ process.execPath,
+ Option.getOrUndefined(
+ Option.orElse(
+ linuxDesktopEntryConfig.launcherPath,
+ () => linuxDesktopEntryConfig.appImagePath,
+ ),
+ ) ?? process.execPath,
+ scheme: ElectronProtocol.getDesktopScheme(linux.isDevelopment),
+ ...(iconPath === undefined ? {} : { iconPath }),
+ }),
Expand Down
30 changes: 12 additions & 18 deletions patches/0002-flatpak-host-backend.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/apps/desktop/src/backend/DesktopBackendConfiguration.ts b/apps/desktop/src/backend/DesktopBackendConfiguration.ts
index 69a70b68a4..bcf48615be 100644
index abadf58f3f..c1d7300493 100644
--- a/apps/desktop/src/backend/DesktopBackendConfiguration.ts
+++ b/apps/desktop/src/backend/DesktopBackendConfiguration.ts
@@ -1,5 +1,8 @@
Expand All @@ -10,8 +10,8 @@ index 69a70b68a4..bcf48615be 100644
+
import { parsePersistedServerObservabilitySettings } from "@t3tools/shared/serverSettings";
import { currentDesktopBootstrapToken } from "@t3tools/shared/desktopBootstrapToken";
import * as Clock from "effect/Clock";
@@ -518,7 +521,7 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
import * as HostProcess from "@t3tools/shared/HostProcess";
@@ -520,7 +523,7 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
...buildObservabilityFragment(input.observabilitySettings),
};

Expand All @@ -20,28 +20,25 @@ index 69a70b68a4..bcf48615be 100644
executablePath: process.execPath,
// Packaged builds have a separate cache; --require prevents cache settings leaking to provider subprocesses.
args: [
@@ -542,6 +545,15 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
@@ -544,6 +547,12 @@ const resolvePrimaryStartConfig = Effect.fn("desktop.backendConfiguration.resolv
captureOutput: true,
preflightFailure: Option.none(),
} satisfies DesktopBackendManager.DesktopBackendStartConfig;
+
+ if (flatpakAppId(process.env, environment.platform) !== null) {
+ return flatpakBackendConfig(
+ config,
+ process.env.T3CODE_FLATPAK_RUNTIME,
+ process.env.T3CODE_FLATPAK_HOST_PATH,
+ );
+ const env = yield* HostProcess.Environment;
+ if (flatpakAppId(env, environment.platform) !== null) {
+ return flatpakBackendConfig(config, env.T3CODE_FLATPAK_RUNTIME, env.T3CODE_FLATPAK_HOST_PATH);
+ }
+ return config;
},
);

diff --git a/apps/desktop/src/backend/flatpakBackend.test.ts b/apps/desktop/src/backend/flatpakBackend.test.ts
new file mode 100644
index 0000000000..229b483064
index 0000000000..db6ebf475a
--- /dev/null
+++ b/apps/desktop/src/backend/flatpakBackend.test.ts
@@ -0,0 +1,78 @@
@@ -0,0 +1,75 @@
+import { assert, describe, it } from "@effect/vitest";
+import * as Option from "effect/Option";
+
Expand Down Expand Up @@ -79,12 +76,9 @@ index 0000000000..229b483064
+
+describe("Flatpak backend", () => {
+ it("keeps bootstrap and telemetry on forwarded FDs without exporting the sandbox environment", () => {
+ const runtime = "/home/al ice/.local/share/flatpak/app/t3/x86_64/stable/build-$literal/files/t3code";
+ const result = flatpakBackendConfig(
+ config,
+ runtime,
+ "/home/alice/.local/bin:/usr/bin",
+ );
+ const runtime =
+ "/home/al ice/.local/share/flatpak/app/t3/x86_64/stable/build-$literal/files/t3code";
+ const result = flatpakBackendConfig(config, runtime, "/home/alice/.local/bin:/usr/bin");
+ assert.equal(result.executablePath, "/usr/bin/flatpak-spawn");
+ assert.deepEqual(result.args, [
+ "--host",
Expand Down
Loading