Skip to content

feat(client/renderer): added markdown cell type feature#1253

Merged
johbaxter merged 27 commits intodevfrom
1090-Markdown-cell
Jun 13, 2025
Merged

feat(client/renderer): added markdown cell type feature#1253
johbaxter merged 27 commits intodevfrom
1090-Markdown-cell

Conversation

@Paulson-Robert
Copy link
Copy Markdown
Contributor

Description

Changes Made

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes

@Paulson-Robert Paulson-Robert requested a review from johbaxter June 4, 2025 08:54
@Paulson-Robert Paulson-Robert self-assigned this Jun 4, 2025
@Paulson-Robert Paulson-Robert requested a review from a team as a code owner June 4, 2025 08:54
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 4, 2025

@CodiumAI-Agent /describe

@QodoAI-Agent
Copy link
Copy Markdown

Title

feat(client/renderer): added markdown cell type feature


User description

Description

Changes Made

How to Test

  1. Steps to reproduce/test the behavior
  2. Expected outcomes

Notes


PR Type

Enhancement


Description

  • Render code cells as markdown when selected

  • Add MarkdownIcon and select option in UI

  • Handle run action and store cell state

  • Exclude markdown cells from outputs collapse


Changes walkthrough 📝

Relevant files
Enhancement
8 files
CodeCell.tsx
Render markdown cells with Markdown component                       
+111/-62
config.ts
Support markdown type in config conversion                             
+2/-0     
MarkdownIcon.tsx
Add MarkdownIcon SVG component                                                     
+20/-0   
index.ts
Export MarkdownIcon in icons index                                             
+2/-1     
cell.state.ts
Mark markdown cells on run                                                             
+11/-1   
state.actions.ts
Define RunMarkdownCell action type                                             
+11/-0   
state.store.ts
Implement runMarkdownCell logic                                                   
+10/-0   
NotebookCell.tsx
Exclude markdown cells from output collapse                           
+191/-171

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented Jun 4, 2025

    @CodiumAI-Agent /review

    @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented Jun 4, 2025

    @CodiumAI-Agent /improve

    @Paulson-Robert Paulson-Robert linked an issue Jun 4, 2025 that may be closed by this pull request
    4 tasks
    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Loading State

    After processing markdown cells, isLoading is never reset to false, which may cause the UI to remain stuck in a loading state.

    if (this._store.parameters.type === "markdown") {
        // set the value
        this._update("parameters.marked", true);
    
        runInAction(() => {
            // store the operation and output
            this._store.operation = ["MARKDOWN"];
            // save the last output
            this._store.output = this._store.parameters.code;
        });
    } else if (typeof raw === "string") {
    Duplicate Rendering

    The Markdown vs Editor rendering logic is duplicated in multiple branches; consider extracting common rendering into a shared component to avoid drift and simplify maintenance.

    <StyledContainer
        onDoubleClick={() =>
            EDITOR_TYPE[cell.parameters.type].language ===
                "Markdown" &&
            state.dispatch({
                message: ActionMessages.RUN_MARKDOWN_CELL,
                payload: {
                    queryId: cell.query.id,
                    cellId: cell.id,
                    marked: false,
                },
            })
        }
    >

    @QodoAI-Agent
    Copy link
    Copy Markdown

    QodoAI-Agent commented Jun 4, 2025

    PR Code Suggestions ✨

    Latest suggestions up to fe1a9ee

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Stop loading & set executed

    Mark the cell as executed and clear the loading state for markdown cells so the UI
    stops showing a spinner and displays the content. Add isExecuted and isLoading
    updates.

    libs/renderer/src/store/state/cell.state.ts [359-368]

     if (this._store.parameters.type === "markdown") {
    -    // set the value
    -    this._update("parameters.marked", true);
    -
    -    runInAction(() => {
    -        // store the operation and output
    -        this._store.operation = ["MARKDOWN"];
    -        // save the last output
    -        this._store.output = this._store.parameters.code;
    -    });
    +  this._update("parameters.marked", true);
    +  runInAction(() => {
    +    this._store.operation = ["MARKDOWN"];
    +    this._store.output = this._store.parameters.code;
    +  });
    +  this._update("isExecuted", true);
    +  this._store.isLoading = false;
    +  return;
     }
    Suggestion importance[1-10]: 8

    __

    Why: Setting isExecuted and clearing isLoading after rendering markdown stops the spinner and correctly marks cell completion.

    Medium
    Toggle markdown marked flag

    Toggle the marked flag instead of always sending false so double-click can both mark
    and unmark. Use the current value to invert the state. This ensures correct toggling
    of markdown rendering.

    libs/renderer/src/components/cell-defaults/code-cell/CodeCell.tsx [631-642]

     onDoubleClick={() =>
    -    EDITOR_TYPE[cell.parameters.type].language ===
    -        "Markdown" &&
    +    EDITOR_TYPE[cell.parameters.type].language === "Markdown" &&
         state.dispatch({
    -        message: ActionMessages.RUN_MARKDOWN_CELL,
    -        payload: {
    -            queryId: cell.query.id,
    -            cellId: cell.id,
    -            marked: false,
    -        },
    +      message: ActionMessages.RUN_MARKDOWN_CELL,
    +      payload: {
    +        queryId: cell.query.id,
    +        cellId: cell.id,
    +        marked: !cell.parameters.marked,
    +      },
         })
     }
    Suggestion importance[1-10]: 7

    __

    Why: The change correctly flips the marked flag on double-click, ensuring markdown cells can be toggled on and off.

    Medium
    Early return for markdown branch

    After handling the markdown branch, return early to avoid pixel execution logic.
    This prevents unintended calls to runPixel or array handling for markdown cells.

    libs/renderer/src/store/state/cell.state.ts [359-369]

     if (this._store.parameters.type === "markdown") {
    -    // set the value
    -    this._update("parameters.marked", true);
    -
    -    runInAction(() => {
    -        // store the operation and output
    -        this._store.operation = ["MARKDOWN"];
    -        // save the last output
    -        this._store.output = this._store.parameters.code;
    -    });
    +  this._update("parameters.marked", true);
    +  runInAction(() => {
    +    this._store.operation = ["MARKDOWN"];
    +    this._store.output = this._store.parameters.code;
    +  });
    +  return;
     } else if (typeof raw === "string") {
    Suggestion importance[1-10]: 7

    __

    Why: An early return prevents the pixel execution logic from running for markdown cells, avoiding unintended calls to runPixel.

    Medium
    Wrap state update in runInAction

    Wrap the direct mutation of observable state in runInAction so MobX picks up the
    change. This ensures the UI observes the update to parameters.marked.

    libs/renderer/src/store/state/state.store.ts [1678-1683]

     private runMarkdownCell = (queryId: string, cellId: string, marked: boolean): void => {
    -    const q = this._store.queries[queryId];
    -    const c = q.getCell(cellId);
    -    // make the cell as marked
    -    this._store.queries[queryId].cells[cellId].parameters.marked = marked
    +  runInAction(() => {
    +    this._store.queries[queryId].cells[cellId].parameters.marked = marked;
    +  });
     }
    Suggestion importance[1-10]: 6

    __

    Why: Encapsulating the direct mutation in runInAction ensures MobX picks up the change to parameters.marked, improving reactivity.

    Low

    Previous suggestions

    Suggestions up to commit 9c4b4eb
    CategorySuggestion                                                                                                                                    Impact
    General
    Toggle markdown marked flag

    Check the cell type directly and toggle the marked flag instead of hard-coding
    false. This ensures double-click correctly shows or hides the markdown view.

    libs/renderer/src/components/cell-defaults/code-cell/CodeCell.tsx [630-643]

     <StyledContainer
         onDoubleClick={() =>
    -        EDITOR_TYPE[cell.parameters.type].language ===
    -            "Markdown" &&
    +        cell.parameters.type === "markdown" &&
             state.dispatch({
                 message: ActionMessages.RUN_MARKDOWN_CELL,
                 payload: {
                     queryId: cell.query.id,
                     cellId: cell.id,
    -                marked: false,
    +                marked: !cell.parameters.marked,
                 },
             })
         }
     >
    Suggestion importance[1-10]: 7

    __

    Why: Toggling marked instead of hard-coding false improves UX by allowing users to show/hide markdown on double-click and aligns with the new "markdown" type.

    Medium
    Wrap mutation in runInAction

    Wrap the state mutation in runInAction to batch updates and avoid MobX warnings.
    This ensures the UI reacts correctly to the flag change.

    libs/renderer/src/store/state/state.store.ts [1682-1687]

     private runMarkdownCell = (queryId: string, cellId: string, marked: boolean): void => {
    -    const q = this._store.queries[queryId];
    -    const c = q.getCell(cellId);
    -    // make the cell as marked
    -    this._store.queries[queryId].cells[cellId].parameters.marked = marked
    +    runInAction(() => {
    +        this._store.queries[queryId].cells[cellId].parameters.marked = marked;
    +    });
     }
    Suggestion importance[1-10]: 7

    __

    Why: Wrapping the direct mutation of parameters.marked in runInAction ensures MobX batches the update and prevents warnings while keeping UI in sync.

    Medium

    @johbaxter
    Copy link
    Copy Markdown
    Contributor

    image

    Im cool with the v1 we need to iterate on this and clean UX @ehynd

    @johbaxter johbaxter merged commit 3ed4908 into dev Jun 13, 2025
    3 checks passed
    @johbaxter johbaxter deleted the 1090-Markdown-cell branch June 13, 2025 20:01
    @github-actions
    Copy link
    Copy Markdown

    @CodiumAI-Agent /update_changelog

    @QodoAI-Agent
    Copy link
    Copy Markdown

    Changelog updates: 🔄

    2025-06-13 *

    Added

    • Support for Markdown cell type in code cells (rendering, icon, and execution)

    to commit the new content to the CHANGELOG.md file, please type:
    '/update_changelog --pr_update_changelog.push_changelog_changes=true'

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    Create Markdown Cell

    6 participants