Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/src/core/codemirror/placeholder/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Copyright 2024 Marimo. All rights reserved. */
import type { Extension } from "@codemirror/state";
import { EditorView, keymap, placeholder } from "@codemirror/view";
import { isEditorReadonly } from "../readonly/extension";

/**
* A placeholder that will be shown when the editor is empty and support
Expand All @@ -25,6 +26,10 @@ export function smartPlaceholderExtension(text: string): Extension[] {
}

function acceptPlaceholder(cm: EditorView, text: string) {
if (isEditorReadonly(cm.state)) {
return false;
}

// if empty, insert the placeholder
const docLength = cm.state.doc.length;
if (docLength === 0) {
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/core/network/requests-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import { once } from "lodash-es";
import { getRuntimeManager } from "../runtime/config";
import { store } from "../state/jotai";
import { API, createClientWithRuntimeManager } from "./api";
import { waitForConnectionOpen } from "./connection";
import { isConnectedAtom, waitForConnectionOpen } from "./connection";
import type { EditRequests, RunRequests } from "./types";

const { handleResponse, handleResponseReturnNull } = API;
Expand Down Expand Up @@ -83,7 +84,11 @@ export function createNetworkRequests(): EditRequests & RunRequests {
.then(handleResponseReturnNull);
},
sendRun: async (request) => {
await waitForConnectionOpen();
// Rather than waiting, we just drop all sendRun requests if the connection is not open.
// Otherwise we can get into a weird state of sending requests for cells that no longer exist.
if (!store.get(isConnectedAtom)) {
return null;
}
return getClient()
.POST("/api/kernel/run", {
body: request,
Expand Down
Loading