Repository: stateful/vscode-runme
Pull request #1372 (2024-05-22 18:28:32)

Annotations as JSON & actionable warning for Gist
Two UX improvements as per title.

sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=stateful_vscode-runme&pullRequest=1372) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=stateful_vscode-runme&pullRequest=1372&resolved=false&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=stateful_vscode-runme&pullRequest=1372&resolutions=WONTFIX)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=stateful_vscode-runme&pullRequest=1372&resolved=false&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [16.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=stateful_vscode-runme&pullRequest=1372&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=stateful_vscode-runme&pullRequest=1372&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=stateful_vscode-runme&pullRequest=1372)



Patch:
diff --git a/src/extension/cell.ts b/src/extension/cell.ts
index c961bcc9..58fba880 100644
--- a/src/extension/cell.ts
+++ b/src/extension/cell.ts
@@ -171,8 +171,7 @@ export class NotebookCellOutputManager {
 
         return new NotebookCellOutput([
           NotebookCellOutputItem.json(annotationJson, OutputType.annotations),
-          // disable to prevent rendering in session outputs
-          // NotebookCellOutputItem.json(annotationJson),
+          NotebookCellOutputItem.json(annotationJson),
         ])
       }
 
diff --git a/src/extension/messages/github.ts b/src/extension/messages/github.ts
index 2bf0338b..fa8b9722 100644
--- a/src/extension/messages/github.ts
+++ b/src/extension/messages/github.ts
@@ -1,4 +1,4 @@
-import { NotebookEditor, NotebookRendererMessaging, workspace, window } from 'vscode'
+import { NotebookEditor, NotebookRendererMessaging, workspace, window, commands } from 'vscode'
 
 import { ClientMessages } from '../../constants'
 import { ClientMessage } from '../../types'
@@ -67,9 +67,17 @@ export async function handleGistMessage({
       () => false,
     )
     if (!sessionFileExists) {
-      return window.showWarningMessage(
-        'No session files found, turn on Auto-Save and run the cell again to generate one',
-      )
+      return window
+        .showWarningMessage(
+          'No session outputs files found. Enable Auto-Save, rerun the cell, and click again.',
+          'Enable and Re-run',
+        )
+        .then(async (selected) => {
+          if (selected === 'Enable and Re-run') {
+            await commands.executeCommand('runme.notebookAutoSaveOff')
+            await commands.executeCommand('notebook.cell.execute')
+          }
+        })
     }
     openFileAsRunmeNotebook(outputFilePath)
   }


Test patch:
diff --git a/tests/extension/cell.test.ts b/tests/extension/cell.test.ts
index e0a871f6..a91888f7 100644
--- a/tests/extension/cell.test.ts
+++ b/tests/extension/cell.test.ts
@@ -297,7 +297,7 @@ describe('NotebookCellOutputManager', () => {
     await outputs.toggleOutput(OutputType.annotations)
     const result = replaceOutput.mock.calls[0][0]
     expect(result).toHaveLength(1)
-    expect(result[0].items).toHaveLength(1)
+    expect(result[0].items).toHaveLength(2)
     expect(result[0].items[0].mime).toBe(OutputType.annotations)
   })
 
@@ -314,7 +314,7 @@ describe('NotebookCellOutputManager', () => {
     const result = replaceOutput.mock.calls[0][0]
 
     expect(result).toHaveLength(1)
-    expect(result[0].items).toHaveLength(1)
+    expect(result[0].items).toHaveLength(2)
     expect(result[0].items[0].mime).toBe(OutputType.annotations)
   })