mrmd-editor 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mrmd-editor",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Markdown editor with realtime collaboration - the core editor package",
5
5
  "type": "module",
6
6
  "main": "dist/mrmd.cjs",
@@ -535,9 +535,12 @@ export async function createStudio(target, options = {}) {
535
535
  initialPath: python?.venv || '~',
536
536
  showHidden: true, // Show hidden folders like .venv
537
537
  onSelect: async (path) => {
538
+ console.log('[ChangeVenv] onSelect called with path:', path, 'for doc:', docName);
538
539
  try {
539
540
  // Create a dedicated runtime for this document with the selected venv
541
+ console.log('[ChangeVenv] Calling createSession...');
540
542
  const sessionInfo = await shellState.createSession(docName, 'dedicated', path);
543
+ console.log('[ChangeVenv] createSession returned:', sessionInfo);
541
544
 
542
545
  // Reconnect the editor to the new runtime
543
546
  if (editor?.connectRuntime && sessionInfo.url) {
@@ -591,8 +594,46 @@ export async function createStudio(target, options = {}) {
591
594
  },
592
595
 
593
596
  async onRestartRuntime(language) {
594
- // TODO: Implement runtime restart via orchestrator
595
- console.log('Restart runtime:', language);
597
+ console.log('[RestartRuntime] Starting restart for:', language);
598
+
599
+ const docName = shellState.get('currentDoc');
600
+ if (!docName) {
601
+ console.warn('[RestartRuntime] No current document');
602
+ return;
603
+ }
604
+
605
+ try {
606
+ // Get current session info to preserve venv
607
+ const python = shellState.get('runtimes.python') || {};
608
+ const currentVenv = python.venv;
609
+ console.log('[RestartRuntime] Current venv:', currentVenv);
610
+
611
+ // Destroy existing session (kills the daemon)
612
+ console.log('[RestartRuntime] Destroying session for:', docName);
613
+ await orchestratorClient.destroySession(docName);
614
+
615
+ // Small delay to ensure cleanup
616
+ await new Promise(r => setTimeout(r, 500));
617
+
618
+ // Create new session with same venv
619
+ console.log('[RestartRuntime] Creating new session with venv:', currentVenv);
620
+ const sessionInfo = await shellState.createSession(docName, 'dedicated', currentVenv);
621
+ console.log('[RestartRuntime] New session created:', sessionInfo);
622
+
623
+ // Reconnect editor to new runtime
624
+ if (editor?.connectRuntime && sessionInfo.url) {
625
+ editor.connectRuntime('python', sessionInfo.url);
626
+ }
627
+
628
+ // Update execution manager
629
+ if (editor?.execution?.setRuntimeUrl) {
630
+ editor.execution.setRuntimeUrl(sessionInfo.url);
631
+ }
632
+
633
+ emit('runtimeRestarted', { language, session: sessionInfo });
634
+ } catch (error) {
635
+ console.error('[RestartRuntime] Error:', error);
636
+ }
596
637
  },
597
638
 
598
639
  async onNewFile() {