Skip to content

Commit

Permalink
(#85) VSCode extension 0.1.7 released. Many installation+UI fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed May 22, 2024
1 parent 6e6b246 commit af1e5e4
Show file tree
Hide file tree
Showing 11 changed files with 376 additions and 267 deletions.
6 changes: 3 additions & 3 deletions rust/demo-app/move/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.25.0"
compiler-version = "1.25.1"
edition = "2024.beta"
flavor = "sui"

Expand All @@ -49,6 +49,6 @@ published-version = "1"

[env.testnet_proxy]
chain-id = "4c78adac"
original-published-id = "0xdfebbe9396d28c054dec993c5d209f8564b7d8559aba93bd5722958bbd080d69"
latest-published-id = "0xdfebbe9396d28c054dec993c5d209f8564b7d8559aba93bd5722958bbd080d69"
original-published-id = "0x47a6d73defe78b2c2500fd25c01dd520aec45bb7fae178b92ffd39036f1d31b1"
latest-published-id = "0x47a6d73defe78b2c2500fd25c01dd520aec45bb7fae178b92ffd39036f1d31b1"
published-version = "1"
10 changes: 5 additions & 5 deletions rust/suibase/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/suibase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ members = ["crates/suibase-daemon",
[workspace.package]
# Bump 'version' for the daemon to self-restart after an update.
# (this is not the Suibase package version, it is specifically for the Rust crates).
version = "0.0.7"
version = "0.0.8"
edition = "2021"

[workspace.dependencies]
Expand Down
18 changes: 11 additions & 7 deletions rust/suibase/crates/common/src/workers/shell_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use std::{path::PathBuf, process::Command};
use anyhow::Result;
use tokio_graceful_shutdown::{FutureExt, SubsystemHandle};

use crate::{
basic_types::{GenericChannelMsg, GenericRx, WorkdirIdx},
};
use crate::basic_types::{GenericChannelMsg, GenericRx, WorkdirIdx};

use home::home_dir;

Expand Down Expand Up @@ -101,14 +99,20 @@ impl ShellWorker {

match output {
Ok(output) => {
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
let mut outputs = if stderr.is_empty() {
stdout
} else {
format!("{}\n{}", stderr, stdout)
};
outputs = outputs.trim().to_string();
if output.status.success() {
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
resp = Some(stdout.trim().to_string());
resp = Some(outputs);
} else {
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
let error_msg = format!(
"Error: do_exec({:?}, {:?}) returned {}",
msg.workdir_idx, cmd, stderr
msg.workdir_idx, cmd, outputs
);
log::error!("{}", error_msg);
resp = Some(error_msg);
Expand Down
6 changes: 5 additions & 1 deletion typescript/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log

When upgrading the extension, do also "~/suibase/update" to get the latest Suibase CLI.
Important:
When upgrading the extension, do also "~/suibase/update" to get the latest Suibase CLI.

## 0.1.7
- Better UI to help the user get started. Less "unexplained" spinners...

## 0.1.6
- Make installation/upgrade more user friendly, better error messages.
Expand Down
2 changes: 1 addition & 1 deletion typescript/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"license": "Apache-2.0",
"icon": "media/logo_128.png",
"version": "0.1.6",
"version": "0.1.7",
"repository": {
"type": "git",
"url": "https://github.com/ChainMovers/suibase.git"
Expand Down
28 changes: 22 additions & 6 deletions typescript/vscode-extension/src/BackendSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
SETUP_ISSUE_SUIBASE_NOT_INSTALLED,
WEBVIEW_BACKEND,
WORKDIRS_KEYS,
WORKDIR_IDX_TESTNET,
} from "./common/Consts";
import { Mutex } from "async-mutex";
import { BaseWebview } from "./bases/BaseWebview";
Expand All @@ -16,6 +17,7 @@ import {
} from "./common/ViewMessages";
import { SuibaseJson, SuibaseJsonVersions } from "./common/SuibaseJson";
import { SuibaseExec } from "./SuibaseExec";
import * as vscode from "vscode";

// One instance per workdir, instantiated in same size and order as WORKDIRS_KEYS.
class BackendWorkdirTracking {
Expand All @@ -36,6 +38,7 @@ export class BackendSync {
private mWorkdir: string; // Last known active workdir. One of "localnet", "mainnet", "testnet", "devnet".
private mWorkdirTrackings: BackendWorkdirTracking[] = []; // One instance per workdir, align with WORKDIRS_KEYS.
private mForceRefreshOnNextReconnect: boolean; // Force some refresh when there was a lost of backend connection.
private activeWorkdir: string = WORKDIRS_KEYS[WORKDIR_IDX_TESTNET];

// Singleton
private constructor() {
Expand Down Expand Up @@ -102,6 +105,11 @@ export class BackendSync {
void this.replyWorkdirStatus(message as RequestWorkdirStatus);
} else if (message.name === "RequestWorkdirPackages") {
void this.replyWorkdirPackages(message as RequestWorkdirPackages);
} else if (message.name === "OpenDiagnosticPanel") {
// Call the VSCode command "suibase.dashboard" to open/reveal the dashboard panel.
vscode.commands.executeCommand("suibase.dashboard").then(undefined, (error) => {
console.error(`Error executing suibase.dashboard command: ${error}`);
});
}
} catch (error) {
console.error(`Error in handleViewMessage: ${JSON.stringify(error)}`);
Expand Down Expand Up @@ -298,16 +306,21 @@ export class BackendSync {
// Sanity check that the data is valid.
// - result should have a header with method "getVersions".
// - the key must match the workdir.
// - asuiSelection should always be set to one of "localnet", "mainnet", "testnet", "devnet".
if (
data?.result?.header?.method !== "getVersions" ||
data?.result?.header?.key !== workdir ||
data?.result?.asuiSelection === "Unknown"
) {
if (data?.result?.header?.method !== "getVersions" || data?.result?.header?.key !== workdir) {
await this.diagnoseBackendError(workdirIdx);
return;
}

// In the UI, the asuiSelection should always be one of "localnet", "mainnet", "testnet", "devnet".
//
// If the backend has trouble to identify the active, just default to the last known valid.
if (!data.result.asuiSelection || !WORKDIRS_KEYS.includes(data.result.asuiSelection)) {
data.result.asuiSelection = this.activeWorkdir;
} else {
// Got a valid active workdir from backend, make it the last known valid.
this.activeWorkdir = data.result.asuiSelection;
}

// Update the SuibaseJson instance for the workdir.
const workdirTracking = this.mWorkdirTrackings[workdirIdx];
const hasChanged = workdirTracking.versions.update(data.result);
Expand All @@ -328,6 +341,9 @@ export class BackendSync {
}
}
}

// TODO Robustness. If there was no valid active workdir coming from the backend, then
// try to resolve it with the ~/suibase/workdirs/active symlink.
}

private async replyWorkdirStatus(message: RequestWorkdirStatus) {
Expand Down
6 changes: 5 additions & 1 deletion typescript/vscode-extension/src/common/ViewMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export class RequestWorkdirStatus extends ViewMessages {
methodUuid: string;
dataUuid: string;


constructor(sender: string, workdirIdx: number, methodUuid: string, dataUuid: string) {
super("RequestWorkdirStatus", sender);
this.workdirIdx = workdirIdx;
Expand All @@ -134,3 +133,8 @@ export class RequestWorkdirPackages extends ViewMessages {
}
}

export class OpenDiagnosticPanel extends ViewMessages {
constructor() {
super("OpenDiagnosticPanel", "");
}
}
398 changes: 199 additions & 199 deletions typescript/vscode-extension/webview-ui/build/assets/index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ export const DashboardController = () => {

const switchProps = { inputProps: { 'aria-label': 'workdir on/off' } };

// Calculated states that consider both the backend and the user requests.
const [allDisabled, setAllDisabled] = useState(false);
const [workdirStates, setWorkdirStates] = useState<WorkdirStates[]>(WORKDIRS_KEYS.map(() => new WorkdirStates()));

const updateWorkdirStates = (index: number, updates: Partial<WorkdirStates>) => {
setWorkdirStates(currentStates =>
currentStates.map((item, idx) =>
Expand Down Expand Up @@ -121,6 +122,21 @@ export const DashboardController = () => {
return () => {};
}, [commonTrigger,statusTrigger,workdirs,workdirStates]);

useEffect(() => {
// Check if all workdirs are disabled.
let allDisabledCalc = true;
for (let i = 0; i < WORKDIRS_KEYS.length; i++) {
if (workdirs[i].workdirStatus.status !== "DISABLED") {
allDisabledCalc = false;
break;
}
}
// Update the state.
if (allDisabledCalc !== allDisabled) {
setAllDisabled(allDisabledCalc);
}
}, [workdirs, statusTrigger]);

return (
<Box sx={{paddingLeft:1}}>
{common.current.setupIssue && <SetupIssue issue={common.current.setupIssue}/>}
Expand All @@ -133,35 +149,36 @@ export const DashboardController = () => {
<TableRow>
<TableCell style={{ width: '115px' }}></TableCell>
<TableCell align="center" style={{ width: '105px' }}>Status</TableCell>
<TableCell style={{ width: '100px' }}>Version</TableCell>
<TableCell align="center" style={{ width: '100px' }}>Version</TableCell>
<TableCell style={{ width: '100px' }}>{/*More Controls*/}</TableCell>
</TableRow>
</TableHead>
<TableBody>
{workdirStates.map((workdirState,index) => {
const workdirStates = workdirs[index];
const viewData = workdirs[index];
const badgeInvisible = allDisabled || !viewData.workdirStatus.isLoaded || index !== common.current.activeWorkdirIdx;
return (
<TableRow key={WORKDIRS_LABELS[index]} sx={{ p: 0, m: 0, '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell sx={{ width: 115, maxWidth: 115, p: 0, m: 0}}>
<TableRow key={WORKDIRS_LABELS[index]} sx={{p: 0, m: 0, '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell sx={{width: 115, maxWidth: 115, pt: '6px', pb: '6px', pl: 0, pr: 0, m: 0}}>
<Box display="flex" alignItems="center" flexWrap="nowrap">
<Box width="10px" display="flex" justifyContent="left" alignItems="center">
{workdirState.showSpinner && <CircularProgress size={9}/>}
</Box>
<Box width="50px" display="flex" justifyContent="center" alignItems="center">
<AntSwitch {...switchProps} checked={workdirState.switchState} onChange={(event) => handleSwitchChange(index, event.target.checked)}/>
<AntSwitch {...switchProps} size="small" disabled={workdirState.showSpinner} checked={workdirState.switchState} onChange={(event) => handleSwitchChange(index, event.target.checked)}/>
</Box>
<Box width="50px" display="flex" justifyContent="left" alignItems="center">
<Badge variant="dot" color="info" anchorOrigin={{vertical: 'top', horizontal: 'left',}} invisible={!workdirStates.workdirStatus.isLoaded || index !== common.current.activeWorkdirIdx}>
<Badge variant="dot" color="info" anchorOrigin={{vertical: 'top', horizontal: 'left',}} invisible={badgeInvisible}>
<Typography variant="body2" sx={{pl:'2px'}}>{WORKDIRS_LABELS[index]}</Typography>
</Badge>
</Box>
</Box>
</TableCell>
<TableCell align="center" sx={{ width: 105, maxWidth: 105, p: 0, m: 0}}>
<Typography variant="subtitle2">{workdirStates.workdirStatus.status}</Typography>
<TableCell align="center" sx={{width: 105, maxWidth: 105, p: 0, m: 0}}>
<Typography variant="subtitle2">{viewData.workdirStatus.status}</Typography>
</TableCell>
<TableCell>
<Typography variant="body2">{workdirStates.workdirStatus.isLoaded && workdirStates.workdirStatus.suiClientVersionShort}</Typography>
<TableCell align="center" sx={{width: 65, maxWidth: 65, p: 0, m: 0}}>
<Typography variant="body2">{viewData.workdirStatus.isLoaded && viewData.workdirStatus.suiClientVersionShort}</Typography>
</TableCell>
<TableCell>
{/* Not supported for now
Expand Down
Loading

0 comments on commit af1e5e4

Please sign in to comment.