Skip to content

Commit dfa5b50

Browse files
Improve Linux doctor checks, gnome extension, ibus behavior, and other bugs (#11)
* Improve Linux doctor checks, gnome extension, ibus behavior, and other bugs * Improve Linux doctor checks, gnome extension, ibus behavior, and other bugs
1 parent 930a4e0 commit dfa5b50

File tree

25 files changed

+496
-126
lines changed

25 files changed

+496
-126
lines changed

apps/dashboard/src/App.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { useState } from "react";
3636
import { usePlatformInfo } from "./hooks/store/usePlatformInfo";
3737
import { Platform } from "@amzn/fig-io-api-bindings";
3838
import { matchesPlatformRestrictions } from "./lib/platform";
39+
import { gnomeExtensionInstallCheck } from "./data/install";
3940

4041
function App() {
4142
const store = useRef(createStore()).current;
@@ -239,10 +240,20 @@ const useNavData = () => {
239240
};
240241

241242
function Layout() {
243+
const platformInfo = usePlatformInfo();
242244
const [accessibilityCheck] = useAccessibilityCheck();
243245
const [dotfilesCheck] = useDotfilesCheck();
246+
const [gnomeExtensionCheck] = useGnomeExtensionCheck();
244247
const navData = useNavData();
245-
const error = accessibilityCheck === false || dotfilesCheck === false;
248+
const error =
249+
accessibilityCheck === false ||
250+
dotfilesCheck === false ||
251+
(platformInfo &&
252+
matchesPlatformRestrictions(
253+
platformInfo,
254+
gnomeExtensionInstallCheck.platformRestrictions,
255+
) &&
256+
gnomeExtensionCheck === false);
246257

247258
// eslint-disable-next-line
248259
const [notifCount, _] = useLocalStateZodDefault(

apps/dashboard/src/components/installs/modal/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export default function OnboardingModal() {
6060
function finish() {
6161
refreshAccessibility();
6262
refreshDotfiles();
63+
refreshDesktopEntry();
64+
refreshGnomeExtension();
6365
Internal.sendOnboardingRequest({
6466
action: Fig.OnboardingAction.FINISH_ONBOARDING,
6567
})

apps/dashboard/src/components/installs/modal/install.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export default function InstallModal({
6868
return;
6969
}
7070
if (key === "desktopEntry") {
71+
// The app should autostart by default, thus immediately install the autostart entry.
7172
Install.install("autostartEntry")
7273
.then(() => {
7374
setChecking(false);

apps/dashboard/src/components/installs/statusCheck.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from "../ui/collapsible";
99
import { Check, ChevronDown, X } from "lucide-react";
1010
import { Button } from "../ui/button";
11-
import { useStatusCheck } from "@/hooks/store";
11+
import { useSetting, useStatusCheck } from "@/hooks/store";
1212

1313
export default function StatusCheck({
1414
check,
@@ -18,10 +18,28 @@ export default function StatusCheck({
1818
const [expanded, setExpanded] = useState(false);
1919
const [status, refreshStatus] = useStatusCheck(check.installKey);
2020
const [err, setErr] = useState("");
21+
const [launchOnStartup] = useSetting("app.launchOnStartup");
2122

2223
function fixInstall() {
2324
Install.install(check.installKey)
24-
.then(() => refreshStatus())
25+
.then(() => {
26+
// Default behavior for launchOnStartup should be true, hence check for undefined.
27+
if (
28+
check.installKey === "desktopEntry" &&
29+
(launchOnStartup === undefined || launchOnStartup === true)
30+
) {
31+
Install.install("autostartEntry")
32+
.then(() => {
33+
refreshStatus();
34+
})
35+
.catch((e) => {
36+
console.error(e);
37+
setErr(e.toString());
38+
});
39+
}
40+
41+
refreshStatus();
42+
})
2543
.catch((e) => {
2644
console.error(e);
2745
setErr(e.toString());

apps/dashboard/src/data/install.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ const getBackupsDir = (): string => {
1515
}
1616
};
1717

18+
export const gnomeExtensionInstallCheck = {
19+
id: "gnomeExtension",
20+
installKey: "gnomeExtension",
21+
platformRestrictions: {
22+
os: Platform.Os.LINUX,
23+
desktopEnvironment: Platform.DesktopEnvironment.GNOME,
24+
displayServerProtocol: Platform.DisplayServerProtocol.WAYLAND,
25+
},
26+
title: "Install the GNOME Shell Extension",
27+
description: [
28+
`In order for ${PRODUCT_NAME} to function properly under Wayland, we need to install the ${PRODUCT_NAME} GNOME Shell Extension.`,
29+
`New GNOME Shell extensions will require you to restart your current session by logging out.`,
30+
],
31+
image: gnome_shell_extension,
32+
action: "Install",
33+
};
34+
1835
const installChecks: InstallCheckWithInstallKey[] = [
1936
{
2037
id: "dotfiles",

apps/dashboard/src/lib/store.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ export const createStore = () => {
183183
store.setState({ inputMethodIsInstalled: isInstalled });
184184
});
185185

186+
Install.isInstalled("desktopEntry").then((isInstalled) => {
187+
store.setState({ desktopEntryIsInstalled: isInstalled });
188+
});
189+
190+
Install.isInstalled("gnomeExtension").then((isInstalled) => {
191+
store.setState({ gnomeExtensionIsInstalled: isInstalled });
192+
});
193+
186194
Install.installStatus.subscribe("accessibility", (isInstalled) => {
187195
store.setState({ accessibilityIsInstalled: isInstalled });
188196
return { unsubscribe: false };

build-config/buildspec-linux-ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ phases:
88
run-as: root
99
commands:
1010
- apt-get update
11-
- apt-get install -y -qq build-essential pkg-config jq dpkg curl wget zsh zstd cmake clang libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libdbus-1-dev libwebkit2gtk-4.1-dev libjavascriptcoregtk-4.1-dev valac libibus-1.0-dev libglib2.0-dev sqlite3 libxdo-dev protobuf-compiler libfuse2 dpkg-sig
11+
- apt-get install -y -qq build-essential pkg-config jq dpkg curl wget zsh zstd cmake clang libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libdbus-1-dev libwebkit2gtk-4.0-37 libwebkit2gtk-4.1-dev libjavascriptcoregtk-4.1-dev valac libibus-1.0-dev libglib2.0-dev sqlite3 libxdo-dev protobuf-compiler libfuse2 dpkg-sig
1212
pre_build:
1313
commands:
1414
- export HOME=/home/codebuild-user

fig_desktop/src/install.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,12 @@ where
480480
info!("Extension {} not installed, installing now.", extension_uuid);
481481
shell_extensions.install_bundled_extension(bundled_path).await?;
482482
},
483+
ExtensionInstallationStatus::Errored => {
484+
error!(
485+
"Extension {} is in an errored state. It must be manually uninstalled, and the current desktop session must be restarted.",
486+
extension_uuid
487+
);
488+
},
483489
ExtensionInstallationStatus::RequiresReboot => {
484490
info!(
485491
"Extension {} already installed but not loaded. User must reboot their machine.",

fig_desktop/src/local_ipc/commands.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,25 @@ pub fn dump_state(
271271
DumpStateResponse { json },
272272
))))
273273
}
274+
275+
pub async fn connect_to_ibus(proxy: EventLoopProxy, platform_state: &PlatformState) -> LocalResult {
276+
cfg_if::cfg_if! {
277+
if #[cfg(target_os = "linux")] {
278+
use crate::platform::ibus::launch_ibus_connection;
279+
match launch_ibus_connection(proxy, platform_state.inner()).await {
280+
Ok(_) => Ok(LocalResponse::Success(None)),
281+
Err(err) => {
282+
Err(LocalResponse::Error {
283+
code: None,
284+
message: Some(format!("Failed connecting to ibus: {:?}", err)),
285+
})
286+
},
287+
}
288+
} else {
289+
Err(LocalResponse::Error {
290+
code: None,
291+
message: Some("Connecting to IBus is only supported on Linux".to_owned()),
292+
})
293+
}
294+
}
295+
}

fig_desktop/src/local_ipc/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ async fn handle_local_ipc<Ctx>(
164164
},
165165
Some(command) => {
166166
use fig_proto::local::command::Command::{
167+
ConnectToIbus,
167168
DebugMode,
168169
Devtools,
169170
Diagnostics,
@@ -202,6 +203,7 @@ async fn handle_local_ipc<Ctx>(
202203
&webview_notifications_state,
203204
&platform_state,
204205
),
206+
ConnectToIbus(_) => commands::connect_to_ibus(proxy.clone(), &platform_state).await,
205207
Update(_) => fig_install::update(
206208
ctx.context_arc(),
207209
Some(Box::new(move |_| {

0 commit comments

Comments
 (0)