-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(desktop): improve AppImage icons and remote environment #2538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mwolson
wants to merge
21
commits into
pingdotgg:main
Choose a base branch
from
mwolson:fix/linux-secret-store-backend
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d5fce53
fix(desktop): include standard Linux AppImage icons
mwolson bfc4a7c
fix(desktop): select Linux secret storage backend
mwolson 5cce063
Merge branch 'main' into fix/linux-secret-store-backend
juliusmarminge 8ad0cc9
fix(web): preserve credential error after rollback failure
mwolson b133f59
refactor(web): simplify saved environment rollback error handling
mwolson 23c7528
Merge remote-tracking branch 'upstream/main' into fix/linux-secret-st…
mwolson 58ada8b
Merge remote-tracking branch 'upstream/main' into fix/linux-secret-st…
mwolson afc9110
Configure Linux desktop startup before Electron ready
mwolson b7c2e20
Harden saved SSH environment sessions
mwolson 5f1fe13
Remove saved environments atomically
mwolson 1676dd3
Merge remote-tracking branch 'upstream/main' into fix/linux-secret-st…
mwolson 6fd6ad1
Preserve root paths in early desktop startup
mwolson 46d0228
Address desktop Effect startup review
mwolson 2489efc
Merge remote-tracking branch 'upstream/main' into fix/linux-secret-st…
mwolson a0a2a94
Tighten desktop pre-ready imports
mwolson 4e4cc84
Sort desktop settings test fixture
mwolson 27eadcd
Preserve desktop pre-ready layer ordering
mwolson 6c34906
Isolate desktop pre-ready platform reads
mwolson 0f7c19d
Accept JSONC in early desktop settings
mwolson 749bc07
Remove prescriptive Electron startup guidance
mwolson 4d69158
Guard missing desktop bridge SSH cleanup
mwolson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { assert, describe, it } from "@effect/vitest"; | ||
|
|
||
| import { | ||
| resolveEarlyLinuxElectronOptions, | ||
| resolveEarlyLinuxPasswordStorePreference, | ||
| } from "./DesktopEarlyElectronStartup.ts"; | ||
|
|
||
| describe("DesktopEarlyElectronStartup", () => { | ||
| it("reads the persisted linux password-store preference before Electron is ready", () => { | ||
| const preference = resolveEarlyLinuxPasswordStorePreference({ | ||
| env: { T3CODE_HOME: "/home/user/.t3-test" }, | ||
| homeDirectory: "/home/user", | ||
| readFileString: (path) => { | ||
| assert.equal(path, "/home/user/.t3-test/userdata/desktop-settings.json"); | ||
| return JSON.stringify({ linuxPasswordStore: "kwallet6" }); | ||
| }, | ||
| }); | ||
|
|
||
| assert.equal(preference, "kwallet6"); | ||
| }); | ||
|
|
||
| it("accepts JSONC in the early desktop settings file", () => { | ||
| const preference = resolveEarlyLinuxPasswordStorePreference({ | ||
| env: { T3CODE_HOME: "/home/user/.t3-test" }, | ||
| homeDirectory: "/home/user", | ||
| readFileString: () => `{ | ||
| // manually edited setting | ||
| "linuxPasswordStore": "gnome-libsecret", | ||
| }`, | ||
| }); | ||
|
|
||
| assert.equal(preference, "gnome-libsecret"); | ||
| }); | ||
|
|
||
| it("falls back to auto when the early settings document is missing or invalid", () => { | ||
| const preference = resolveEarlyLinuxPasswordStorePreference({ | ||
| env: {}, | ||
| homeDirectory: "/home/user", | ||
| readFileString: () => { | ||
| throw new Error("missing"); | ||
| }, | ||
| }); | ||
|
|
||
| assert.equal(preference, "auto"); | ||
| }); | ||
|
|
||
| it("preserves absolute root paths when resolving early settings", () => { | ||
| const preference = resolveEarlyLinuxPasswordStorePreference({ | ||
| env: { T3CODE_HOME: "/" }, | ||
| homeDirectory: "/home/user", | ||
| readFileString: (path) => { | ||
| assert.equal(path, "/userdata/desktop-settings.json"); | ||
| return JSON.stringify({ linuxPasswordStore: "kwallet6" }); | ||
| }, | ||
| }); | ||
|
|
||
| assert.equal(preference, "kwallet6"); | ||
| }); | ||
|
|
||
| it("resolves the early linux Electron switches and DBus fallback", () => { | ||
| const options = resolveEarlyLinuxElectronOptions({ | ||
| env: { | ||
| T3CODE_HOME: "/home/user/.t3-test", | ||
| XDG_CURRENT_DESKTOP: "niri", | ||
| XDG_RUNTIME_DIR: "/run/user/1000", | ||
| VITE_DEV_SERVER_URL: "http://127.0.0.1:5173", | ||
| }, | ||
| exists: (path) => path === "/run/user/1000/bus", | ||
| homeDirectory: "/home/user", | ||
| readFileString: (path) => { | ||
| assert.equal(path, "/home/user/.t3-test/dev/desktop-settings.json"); | ||
| return JSON.stringify({ linuxPasswordStore: "auto" }); | ||
| }, | ||
| uid: 1000, | ||
| }); | ||
|
|
||
| assert.deepEqual(options, { | ||
| dbusSessionBusAddress: "unix:path=/run/user/1000/bus", | ||
| linuxWmClass: "t3code-dev", | ||
| passwordStore: "gnome-libsecret", | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import { fromLenientJson } from "@t3tools/shared/schemaJson"; | ||
| import * as Option from "effect/Option"; | ||
| import * as Schema from "effect/Schema"; | ||
|
|
||
| import { | ||
| DEFAULT_LINUX_PASSWORD_STORE, | ||
| normalizeLinuxPasswordStorePreference, | ||
| resolveLinuxPasswordStoreSwitch, | ||
| type LinuxPasswordStoreSwitch, | ||
| type LinuxPasswordStorePreference, | ||
| } from "../linuxSecretStorage.ts"; | ||
| import { resolveDefaultLinuxDbusSessionBusAddress } from "../shell/DesktopShellEnvironment.ts"; | ||
| import { resolveDesktopBaseDir, resolveDesktopStateDir } from "./DesktopStatePaths.ts"; | ||
|
|
||
| interface EarlyDesktopSettingsInput { | ||
| readonly env: NodeJS.ProcessEnv; | ||
| readonly homeDirectory: string; | ||
| readonly readFileString: (path: string) => string; | ||
| } | ||
|
|
||
| interface EarlyLinuxElectronOptionsInput extends EarlyDesktopSettingsInput { | ||
| readonly exists: (path: string) => boolean; | ||
| readonly uid: number | undefined; | ||
| } | ||
|
|
||
| export interface EarlyLinuxElectronOptions { | ||
| readonly dbusSessionBusAddress: string | null; | ||
| readonly linuxWmClass: string; | ||
| readonly passwordStore: LinuxPasswordStoreSwitch | null; | ||
| } | ||
|
|
||
| const trimNonEmpty = (value: string | undefined): string | null => { | ||
| const trimmed = value?.trim(); | ||
| return trimmed && trimmed.length > 0 ? trimmed : null; | ||
| }; | ||
|
|
||
| const EarlyDesktopSettingsJson = fromLenientJson( | ||
| Schema.Struct({ | ||
| linuxPasswordStore: Schema.optionalKey(Schema.Unknown), | ||
| }), | ||
| ); | ||
| const decodeEarlyDesktopSettingsJson = Schema.decodeSync(EarlyDesktopSettingsJson); | ||
|
|
||
| const isDevelopmentEnvironment = (env: NodeJS.ProcessEnv): boolean => | ||
| trimNonEmpty(env.VITE_DEV_SERVER_URL) !== null; | ||
|
|
||
| const joinLinuxPath = (first: string, ...segments: string[]): string => { | ||
| const normalizedFirst = first.replace(/\/+$/u, ""); | ||
| const normalizedSegments = segments.map((segment) => segment.replace(/^\/+|\/+$/gu, "")); | ||
| if (first.length > 0 && normalizedFirst.length === 0 && first.startsWith("/")) { | ||
| const normalizedPath = normalizedSegments.filter((segment) => segment.length > 0).join("/"); | ||
| return normalizedPath.length > 0 ? `/${normalizedPath}` : "/"; | ||
| } | ||
| return [normalizedFirst, ...normalizedSegments].filter((segment) => segment.length > 0).join("/"); | ||
| }; | ||
|
|
||
| function resolveEarlyDesktopSettingsPath(input: { | ||
| readonly env: NodeJS.ProcessEnv; | ||
| readonly homeDirectory: string; | ||
| }): string { | ||
| const baseDir = resolveDesktopBaseDir({ | ||
| homeDirectory: input.homeDirectory, | ||
| joinPath: joinLinuxPath, | ||
| t3Home: Option.fromUndefinedOr(input.env.T3CODE_HOME), | ||
| }); | ||
| const stateDir = resolveDesktopStateDir({ | ||
| baseDir, | ||
| isDevelopment: isDevelopmentEnvironment(input.env), | ||
| joinPath: joinLinuxPath, | ||
| }); | ||
| return joinLinuxPath(stateDir, "desktop-settings.json"); | ||
| } | ||
|
|
||
| export function resolveEarlyLinuxPasswordStorePreference( | ||
| input: EarlyDesktopSettingsInput, | ||
| ): LinuxPasswordStorePreference { | ||
| const settingsPath = resolveEarlyDesktopSettingsPath(input); | ||
| try { | ||
| const parsed = decodeEarlyDesktopSettingsJson(input.readFileString(settingsPath)); | ||
| return normalizeLinuxPasswordStorePreference(parsed.linuxPasswordStore); | ||
| } catch { | ||
| return DEFAULT_LINUX_PASSWORD_STORE; | ||
| } | ||
| } | ||
|
|
||
| export function resolveEarlyLinuxElectronOptions( | ||
| input: EarlyLinuxElectronOptionsInput, | ||
| ): EarlyLinuxElectronOptions { | ||
| const preference = resolveEarlyLinuxPasswordStorePreference(input); | ||
| return { | ||
| dbusSessionBusAddress: | ||
| trimNonEmpty(input.env.DBUS_SESSION_BUS_ADDRESS) === null | ||
| ? resolveDefaultLinuxDbusSessionBusAddress({ | ||
| env: input.env, | ||
| exists: input.exists, | ||
| uid: input.uid, | ||
| }) | ||
| : null, | ||
| linuxWmClass: isDevelopmentEnvironment(input.env) ? "t3code-dev" : "t3code", | ||
| passwordStore: resolveLinuxPasswordStoreSwitch({ | ||
| preference, | ||
| env: input.env, | ||
| }), | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // @effect-diagnostics-next-line nodeBuiltinImport:off - pre-ready Electron setup reads persisted settings synchronously before app services are available. | ||
| import { existsSync, readFileSync } from "node:fs"; | ||
| import { homedir } from "node:os"; | ||
|
|
||
| import * as DesktopEarlyElectronStartup from "./DesktopEarlyElectronStartup.ts"; | ||
|
|
||
| export const resolveEarlyLinuxElectronOptionsFromProcess = | ||
| (): DesktopEarlyElectronStartup.EarlyLinuxElectronOptions => | ||
| DesktopEarlyElectronStartup.resolveEarlyLinuxElectronOptions({ | ||
| env: process.env, | ||
| exists: existsSync, | ||
| homeDirectory: homedir(), | ||
| readFileString: (path) => readFileSync(path, "utf8"), | ||
| uid: process.getuid?.(), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import * as Option from "effect/Option"; | ||
|
|
||
| export type JoinPath = (first: string, ...segments: string[]) => string; | ||
|
|
||
| export function resolveDesktopBaseDir(input: { | ||
| readonly homeDirectory: string; | ||
| readonly joinPath: JoinPath; | ||
| readonly t3Home: Option.Option<string>; | ||
| }): string { | ||
| if (Option.isSome(input.t3Home)) { | ||
| const trimmed = input.t3Home.value.trim(); | ||
| if (trimmed.length > 0) { | ||
| return trimmed; | ||
| } | ||
| } | ||
|
|
||
| return input.joinPath(input.homeDirectory, ".t3"); | ||
| } | ||
|
|
||
| export function resolveDesktopStateDir(input: { | ||
| readonly baseDir: string; | ||
| readonly isDevelopment: boolean; | ||
| readonly joinPath: JoinPath; | ||
| }): string { | ||
| return input.joinPath(input.baseDir, input.isDevelopment ? "dev" : "userdata"); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.