Skip to content

Commit 3ee15f5

Browse files
committed
fix some FE local conn stuff
1 parent fb4c63b commit 3ee15f5

5 files changed

Lines changed: 41 additions & 8 deletions

File tree

frontend/app/block/blockutil.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const ConnectionButton = React.memo(
166166
React.forwardRef<HTMLDivElement, ConnectionButtonProps>(
167167
({ connection, changeConnModalAtom }: ConnectionButtonProps, ref) => {
168168
const [connModalOpen, setConnModalOpen] = jotai.useAtom(changeConnModalAtom);
169-
const isLocal = util.isBlank(connection);
169+
const isLocal = util.isLocalConnName(connection);
170170
const connStatusAtom = getConnStatusAtom(connection);
171171
const connStatus = jotai.useAtomValue(connStatusAtom);
172172
let showDisconnectedSlash = false;
@@ -178,9 +178,15 @@ export const ConnectionButton = React.memo(
178178
};
179179
let titleText = null;
180180
let shouldSpin = false;
181+
let connDisplayName: string = null;
181182
if (isLocal) {
182183
color = "var(--grey-text-color)";
183-
titleText = "Connected to Local Machine";
184+
if (connection === "local:gitbash") {
185+
titleText = "Connected to Git Bash";
186+
connDisplayName = "Git Bash";
187+
} else {
188+
titleText = "Connected to Local Machine";
189+
}
184190
connIconElem = (
185191
<i
186192
className={clsx(util.makeIconClass("laptop", false), "fa-stack-1x")}
@@ -238,7 +244,11 @@ export const ConnectionButton = React.memo(
238244
}}
239245
/>
240246
</span>
241-
{isLocal ? null : <div className="connection-name ellipsis">{connection}</div>}
247+
{connDisplayName ? (
248+
<div className="connection-name ellipsis">{connDisplayName}</div>
249+
) : isLocal ? null : (
250+
<div className="connection-name ellipsis">{connection}</div>
251+
)}
242252
</div>
243253
);
244254
}

frontend/app/store/global.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ import {
1717
import { getWebServerEndpoint } from "@/util/endpoints";
1818
import { fetch } from "@/util/fetchutil";
1919
import { setPlatform } from "@/util/platformutil";
20-
import { base64ToString, deepCompareReturnPrev, fireAndForget, getPrefixedSettings, isBlank } from "@/util/util";
20+
import {
21+
base64ToString,
22+
deepCompareReturnPrev,
23+
fireAndForget,
24+
getPrefixedSettings,
25+
isBlank,
26+
isLocalConnName,
27+
} from "@/util/util";
2128
import { atom, Atom, PrimitiveAtom, useAtomValue } from "jotai";
2229
import { globalStore } from "./jotaiStore";
2330
import { modalsModel } from "./modalmodel";
@@ -730,8 +737,7 @@ function getConnStatusAtom(conn: string): PrimitiveAtom<ConnStatus> {
730737
const connStatusMap = globalStore.get(ConnStatusMapAtom);
731738
let rtn = connStatusMap.get(conn);
732739
if (rtn == null) {
733-
if (isBlank(conn)) {
734-
// create a fake "local" status atom that's always connected
740+
if (isLocalConnName(conn)) {
735741
const connStatus: ConnStatus = {
736742
connection: conn,
737743
connected: true,

frontend/app/view/term/termwrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,14 @@ export class TermWrap {
526526
oref: WOS.makeORef("block", this.blockId),
527527
});
528528

529-
if (rtInfo["shell:integration"]) {
529+
if (rtInfo && rtInfo["shell:integration"]) {
530530
const shellState = rtInfo["shell:state"] as ShellIntegrationStatus;
531531
globalStore.set(this.shellIntegrationStatusAtom, shellState || null);
532532
} else {
533533
globalStore.set(this.shellIntegrationStatusAtom, null);
534534
}
535535

536-
const lastCmd = rtInfo["shell:lastcmd"];
536+
const lastCmd = rtInfo ? rtInfo["shell:lastcmd"] : null;
537537
globalStore.set(this.lastCommandAtom, lastCmd || null);
538538
} catch (e) {
539539
console.log("Error loading runtime info:", e);

frontend/util/util.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ function isBlank(str: string): boolean {
1212
return str == null || str == "";
1313
}
1414

15+
function isLocalConnName(connName: string): boolean {
16+
if (isBlank(connName)) {
17+
return true;
18+
}
19+
return connName === "local" || connName.startsWith("local:");
20+
}
21+
1522
function base64ToString(b64: string): string {
1623
if (b64 == null) {
1724
return null;
@@ -509,6 +516,7 @@ export {
509516
getPromiseState,
510517
getPromiseValue,
511518
isBlank,
519+
isLocalConnName,
512520
jotaiLoadableValue,
513521
jsonDeepEqual,
514522
lazy,

pkg/wshrpc/wshserver/wshserver.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,9 @@ func (ws *WshServer) ConnDisconnectCommand(ctx context.Context, connName string)
647647
if strings.HasPrefix(connName, "aws:") {
648648
return nil
649649
}
650+
if conncontroller.IsLocalConnName(connName) {
651+
return nil
652+
}
650653
if strings.HasPrefix(connName, "wsl://") {
651654
distroName := strings.TrimPrefix(connName, "wsl://")
652655
conn := wslconn.GetWslConn(distroName)
@@ -671,6 +674,9 @@ func (ws *WshServer) ConnConnectCommand(ctx context.Context, connRequest wshrpc.
671674
if strings.HasPrefix(connRequest.Host, "aws:") {
672675
return nil
673676
}
677+
if conncontroller.IsLocalConnName(connRequest.Host) {
678+
return nil
679+
}
674680
ctx = genconn.ContextWithConnData(ctx, connRequest.LogBlockId)
675681
ctx = termCtxWithLogBlockId(ctx, connRequest.LogBlockId)
676682
connName := connRequest.Host
@@ -698,6 +704,9 @@ func (ws *WshServer) ConnReinstallWshCommand(ctx context.Context, data wshrpc.Co
698704
if strings.HasPrefix(data.ConnName, "aws:") {
699705
return nil
700706
}
707+
if conncontroller.IsLocalConnName(data.ConnName) {
708+
return nil
709+
}
701710
ctx = genconn.ContextWithConnData(ctx, data.LogBlockId)
702711
ctx = termCtxWithLogBlockId(ctx, data.LogBlockId)
703712
connName := data.ConnName

0 commit comments

Comments
 (0)