From 851ca70780dd84576cfe098f61105a83c5d2cd16 Mon Sep 17 00:00:00 2001 From: Hamel Husain Date: Wed, 4 Feb 2026 22:28:48 -0800 Subject: [PATCH 01/15] feat: Jupyter-style in-place markdown cell rendering - Add MarkdownCell component with edit/render mode toggle - Double-click rendered markdown to enter edit mode - Press Escape or click away to render markdown - Fix Monaco editor layout issue causing horizontal expansion - Remove window.innerWidth fallback in adjustHeight() - Add contain: inline-size to prevent feedback loop - Add min-w-0/max-w-full CSS constraints throughout - Add tests for MarkdownCell component Amp-Thread-ID: https://ampcode.com/threads/T-019c2c77-9f58-726f-9c8d-21d4e1b6aff1 Co-authored-by: Amp --- app/src/components/Actions/Actions.tsx | 133 +++---- app/src/components/Actions/Editor.tsx | 13 +- app/src/components/Actions/MarkdownCell.tsx | 57 ++- packages/react-components/package.json | 1 + .../src/components/Actions/MarkdownCell.tsx | 343 ++++++++++++++++++ .../Actions/__tests__/MarkdownCell.test.tsx | 223 ++++++++++++ .../react-components/src/components/index.tsx | 1 + pnpm-lock.yaml | 190 ++++++++++ 8 files changed, 855 insertions(+), 106 deletions(-) create mode 100644 packages/react-components/src/components/Actions/MarkdownCell.tsx create mode 100644 packages/react-components/src/components/Actions/__tests__/MarkdownCell.test.tsx diff --git a/app/src/components/Actions/Actions.tsx b/app/src/components/Actions/Actions.tsx index a4cee3a..33487d9 100644 --- a/app/src/components/Actions/Actions.tsx +++ b/app/src/components/Actions/Actions.tsx @@ -9,7 +9,7 @@ import { } from "react"; import { create } from "@bufbuild/protobuf"; -import { Box, ScrollArea, Tabs, Text } from "@radix-ui/themes"; +import { Box, Button, Card, ScrollArea, Tabs, Text } from "@radix-ui/themes"; import { useParams } from "react-router-dom"; import { Cross2Icon } from "@radix-ui/react-icons"; @@ -94,35 +94,17 @@ function RunActionButton({ return "Run code"; }; - const isRunning = exitCode === null && pid !== null; - const isSuccess = exitCode !== null && exitCode === 0; - const isError = exitCode !== null && exitCode > 0; - const isIdle = exitCode === null && pid === null; - return ( - + {exitCode !== null && exitCode === 0 && } + {exitCode !== null && exitCode > 0 && } + ); } @@ -551,7 +533,9 @@ export function Action({ cellData, isFirst }: { cellData: CellData; isFirst: boo // Determine if this cell is a markdown cell (either MARKUP kind or CODE with markdown language) const isMarkdownCell = useMemo(() => { if (!cell) return false; + // Check if cell kind is MARKUP if (cell.kind === parser_pb.CellKind.MARKUP) return true; + // Check if cell is CODE but with markdown language const lang = (cell.languageId ?? "").toLowerCase(); return lang === "markdown" || lang === "md"; }, [cell]); @@ -560,23 +544,23 @@ export function Action({ cellData, isFirst }: { cellData: CellData; isFirst: boo return null; } - // Render markdown cells with in-place rendering (Jupyter-style): - // no run button, no output area – just the markdown rendered in-place. + // Render markdown cells with in-place rendering (Jupyter-style) + // No run button, no output area - just the markdown rendered in-place if (isMarkdownCell) { return (
{!isFirst && ( -
+
)} - +
-
+
- {sequenceLabel.trim() && ( - - {sequenceLabel} - - )} + + [{sequenceLabel}] +
-
+
Language @@ -710,7 +673,7 @@ export function Action({ cellData, isFirst }: { cellData: CellData; isFirst: boo id={languageSelectId} value={selectedLanguage} onChange={handleLanguageChange} - className="cursor-pointer rounded border border-gray-200 bg-white px-2 py-0.5 text-xs text-gray-700 focus:outline-none focus:ring-2 focus:ring-amber-300/50 focus:border-amber-300" + className="cursor-pointer rounded border border-sky-200/70 bg-[#111111] px-2 py-0.5 text-[10px] font-mono text-gray-100 focus:outline-none focus:ring-2 focus:ring-sky-200/50" > {LANGUAGE_OPTIONS.map((option) => (