Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: hide terminal if not available (#7727)

Myles Scolnick2f518693d8c2
diff --git a/frontend/src/components/editor/chrome/state.ts b/frontend/src/components/editor/chrome/state.ts
index 76c28106b8..4b9cd51899 100644
--- a/frontend/src/components/editor/chrome/state.ts
+++ b/frontend/src/components/editor/chrome/state.ts
@@ -7,7 +7,7 @@ import { createReducerAndAtoms } from "@/utils/createReducer";
import { jotaiJsonStorage } from "@/utils/storage/jotai";
import { ZodLocalStorage } from "@/utils/storage/typed";
import type { PanelType } from "./types";
-import { PANELS } from "./types";
+import { isPanelHidden, PANELS } from "./types";
export interface ChromeState {
selectedPanel: PanelType | undefined;
@@ -27,10 +27,10 @@ export interface PanelLayout {
const DEFAULT_PANEL_LAYOUT: PanelLayout = {
sidebar: PANELS.filter(
- (p) => !p.hidden && p.defaultSection === "sidebar",
+ (p) => !isPanelHidden(p) && p.defaultSection === "sidebar",
).map((p) => p.type),
developerPanel: PANELS.filter(
- (p) => !p.hidden && p.defaultSection === "developer-panel",
+ (p) => !isPanelHidden(p) && p.defaultSection === "developer-panel",
).map((p) => p.type),
};
diff --git a/frontend/src/components/editor/chrome/types.ts b/frontend/src/components/editor/chrome/types.ts
index 9ff7ba6642..706096e7db 100644
--- a/frontend/src/components/editor/chrome/types.ts
+++ b/frontend/src/components/editor/chrome/types.ts
@@ -18,7 +18,9 @@ import {
VariableIcon,
XCircleIcon,
} from "lucide-react";
+import { hasCapability } from "@/core/config/capabilities";
import { getFeatureFlag } from "@/core/config/feature-flag";
+import type { Capabilities } from "@/core/kernel/messages";
import { isWasm } from "@/core/wasm/utils";
/**
@@ -56,6 +58,8 @@ export interface PanelDescriptor {
hidden?: boolean;
/** Which section this panel belongs to by default */
defaultSection: PanelSection;
+ /** Capability required for this panel to be visible. If the capability is false, the panel is hidden. */
+ requiredCapability?: keyof Capabilities;
}
/**
@@ -162,7 +166,9 @@ export const PANELS: PanelDescriptor[] = [
Icon: TerminalSquareIcon,
label: "Terminal",
tooltip: "Terminal",
+ hidden: isWasm(),
defaultSection: "developer-panel",
+ requiredCapability: "terminal",
},
{
type: "cache",
@@ -177,3 +183,19 @@ export const PANELS: PanelDescriptor[] = [
export const PANEL_MAP = new Map<PanelType, PanelDescriptor>(
PANELS.map((p) => [p.type, p]),
);
+
+/**
+ * Check if a panel should be hidden based on its `hidden` property
+ * and `requiredCapability`.
+ */
+export function isPanelHidden(panel: PanelDescriptor): boolean {
+ if (panel.hidden) {
+ return true;
+ }
+ if (panel.requiredCapability) {
+ if (!hasCapability(panel.requiredCapability)) {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/frontend/src/components/editor/chrome/wrapper/app-chrome.tsx b/frontend/src/components/editor/chrome/wrapper/app-chrome.tsx
index 354bc35e14..d45eb199c5 100644
--- a/frontend/src/components/editor/chrome/wrapper/app-chrome.tsx
+++ b/frontend/src/components/editor/chrome/wrapper/app-chrome.tsx
@@ -28,7 +28,12 @@ import { ErrorBoundary } from "../../boundary/ErrorBoundary";
import { ContextAwarePanel } from "../panels/context-aware-panel/context-aware-panel";
import { PanelSectionProvider } from "../panels/panel-context";
import { panelLayoutAtom, useChromeActions, useChromeState } from "../state";
-import { PANEL_MAP, PANELS, type PanelDescriptor } from "../types";
+import {
+ isPanelHidden,
+ PANEL_MAP,
+ PANELS,
+ type PanelDescriptor,
+} from "../types";
import { BackendConnectionStatus } from "./footer-items/backend-status";
import { Minimap } from "./minimap";
import { PanelsWrapper } from "./panels";
@@ -125,7 +130,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
const availableDevPanels = useMemo(() => {
const sidebarIds = new Set(panelLayout.sidebar);
return PANELS.filter((p) => {
- if (p.hidden) {
+ if (isPanelHidden(p)) {
return false;
}
// Exclude panels that are in the sidebar
diff --git a/frontend/src/components/editor/chrome/wrapper/sidebar.tsx b/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
index dbbae98eca..b4da4676d2 100644
--- a/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
+++ b/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
@@ -11,7 +11,12 @@ import { notebookQueuedOrRunningCountAtom } from "@/core/cells/cells";
import { cn } from "@/utils/cn";
import { FeedbackButton } from "../components/feedback-button";
import { panelLayoutAtom, useChromeActions, useChromeState } from "../state";
-import { PANEL_MAP, PANELS, type PanelDescriptor } from "../types";
+import {
+ isPanelHidden,
+ PANEL_MAP,
+ PANELS,
+ type PanelDescriptor,
+} from "../types";
export const Sidebar: React.FC = () => {
const { selectedPanel, selectedDeveloperPanelTab } = useChromeState();
@@ -28,7 +33,7 @@ export const Sidebar: React.FC = () => {
const availableSidebarPanels = useMemo(() => {
const devPanelIds = new Set(panelLayout.developerPanel);
return PANELS.filter((p) => {
- if (p.hidden) {
+ if (isPanelHidden(p)) {
return false;
}
// Exclude panels that are in the developer panel
diff --git a/frontend/src/core/config/capabilities.ts b/frontend/src/core/config/capabilities.ts
index fcf3bc7369..7e12e95890 100644
--- a/frontend/src/core/config/capabilities.ts
+++ b/frontend/src/core/config/capabilities.ts
@@ -11,5 +11,5 @@ export const capabilitiesAtom = atom<Capabilities>({
});
export function hasCapability(key: keyof Capabilities): boolean {
- return store.get(capabilitiesAtom)[key] ?? false;
+ return store.get(capabilitiesAtom)?.[key] ?? false;
}
diff --git a/frontend/src/plugins/impl/code/any-language-editor.tsx b/frontend/src/plugins/impl/code/any-language-editor.tsx
index 0399e25738..e81867c2fe 100644
--- a/frontend/src/plugins/impl/code/any-language-editor.tsx
+++ b/frontend/src/plugins/impl/code/any-language-editor.tsx
@@ -15,7 +15,7 @@ import type { ResolvedTheme } from "@/theme/useTheme";
import { Logger } from "@/utils/Logger";
import { ErrorBanner } from "../common/error-banner";
-export const LANGUAGE_MAP: Record<string, string> = {
+export const LANGUAGE_MAP: Record<string, LanguageName | undefined> = {
python: "py",
javascript: "js",
typescript: "ts",