Skip to content

Commit 8100d23

Browse files
Serial fix, TS fix
1 parent 88e7585 commit 8100d23

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/App.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ const logging = deployment.logging;
4141
const device = isMockDeviceMode()
4242
? new MockDeviceConnection()
4343
: createUSBConnection({ logging });
44+
// The connection library starts/stops its serial read loop as "serialdata"
45+
// listeners are added/removed. A remove-all-then-re-add cycle (which React
46+
// StrictMode does on every component mount in dev) races in the library:
47+
// the queued restart sees stale serialState and is silently dropped, leaving
48+
// serial off until a flash restarts it. Keep a permanent no-op listener so
49+
// the count never crosses zero; serial then runs exactly while connected,
50+
// which matches how the serial UI is shown anyway.
51+
device.addEventListener("serialdata", () => {});
4452

4553
const host = createHost(logging);
4654
const fs = new FileSystem(logging, host, fetchMicroPython);

src/serial/SerialPanel.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const SerialPanel = ({
221221
(!activeTraceback || deviceSync === SyncStatus.OUT_OF_SYNC);
222222
// The traceback only belongs in the header when collapsed; when expanded
223223
// it's already visible in the terminal itself.
224-
const showTraceback = Boolean(compact && activeTraceback);
224+
const compactTraceback = compact ? activeTraceback : undefined;
225225
// The status colour for a source: red for an (up-to-date) runtime error, a
226226
// darker shade when there's code to flash/run, otherwise the terminal
227227
// background. Applied per source so a healthy tab stays neutral even if the
@@ -316,7 +316,7 @@ const SerialPanel = ({
316316
boxSize={5}
317317
/>
318318
</Text>
319-
) : showTraceback ? (
319+
) : compactTraceback ? (
320320
<HStack spacing={1} pr={1} maxW="20rem" overflow="hidden">
321321
<Icon
322322
as={RiErrorWarningLine}
@@ -332,11 +332,11 @@ const SerialPanel = ({
332332
// Keep the line-number span the same size as the message.
333333
sx={{ span: { fontSize: "inherit" } }}
334334
>
335-
<MaybeTracebackLink traceback={activeTraceback} />
335+
<MaybeTracebackLink traceback={compactTraceback} />
336336
</Box>
337337
</HStack>
338338
) : null}
339-
{(showDeviceSync || showTraceback) && (
339+
{(showDeviceSync || compactTraceback) && (
340340
<Divider
341341
orientation="vertical"
342342
height={6}
@@ -345,7 +345,7 @@ const SerialPanel = ({
345345
/>
346346
)}
347347
<CollapsibleButton
348-
mode={showTraceback ? "icon" : "button"}
348+
mode={compactTraceback ? "icon" : "button"}
349349
variant="unstyled"
350350
display="flex"
351351
fontWeight="normal"

0 commit comments

Comments
 (0)