From 3a53e0aa580529b1ff626c8e0f66f9d4dc59e705 Mon Sep 17 00:00:00 2001 From: tegwick Date: Sat, 25 Oct 2025 18:16:25 +0200 Subject: [PATCH] fix: resolve md-render --edit functionality and add enhanced version tracking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the critical md-render --edit regression that was causing "blue box, no content" issues and adds comprehensive version tracking. Key fixes: - Fixed JavaScript newline escaping in f-string templates (\\n\\n not \\\\n\\\\n) - Restored proper content rendering with marked.js CDN and graceful fallback - Removed problematic validation logic that was blocking content display - Cleaned up html-inject-editing command and related experimental code Enhancements: - Added version display in edit mode header with git commit and timestamp - Enhanced version tracking to show local uncommitted changes with timestamps - Added comprehensive regression tests to prevent future breakage - Improved error handling and recovery mechanisms The md-render --edit functionality now works reliably with full version visibility. 🤖 Generated with Claude Code Co-Authored-By: Claude --- markitect/document_manager.py | 173 +++--- .../plugins/builtin/markdown_commands.py | 542 +----------------- tests/test_issue_144_edit_mode_regression.py | 123 ++-- 3 files changed, 151 insertions(+), 687 deletions(-) diff --git a/markitect/document_manager.py b/markitect/document_manager.py index 40626078..1d56de9e 100644 --- a/markitect/document_manager.py +++ b/markitect/document_manager.py @@ -617,9 +617,82 @@ class DocumentManager: # Edit mode status and error reporting section edit_mode_html = "" if edit_mode: + # Get version info for header + try: + import markitect + from pathlib import Path + import subprocess + + # Get base version + version = "0.3.0" # fallback + try: + from importlib.metadata import version as get_version + version = get_version('markitect') + except: + pass + + # Get git commit with timestamp and local changes info + git_info = "" + try: + repo_path = Path(__file__).parent.parent + + # Get commit hash and timestamp + result = subprocess.run(['git', 'rev-parse', '--short', 'HEAD'], + capture_output=True, text=True, cwd=repo_path) + if result.returncode == 0: + commit_hash = result.stdout.strip() + + # Get commit timestamp + timestamp_result = subprocess.run(['git', 'show', '-s', '--format=%ci', 'HEAD'], + capture_output=True, text=True, cwd=repo_path) + commit_time = "" + if timestamp_result.returncode == 0: + from datetime import datetime + # Parse git timestamp and format it nicely + git_time = timestamp_result.stdout.strip() + try: + dt = datetime.fromisoformat(git_time.replace(' +', '+')) + commit_time = f" ({dt.strftime('%Y-%m-%d %H:%M')})" + except: + pass + + git_info = f"+{commit_hash}{commit_time}" + + # Check for uncommitted changes + status_result = subprocess.run(['git', 'status', '--porcelain'], + capture_output=True, text=True, cwd=repo_path) + if status_result.returncode == 0 and status_result.stdout.strip(): + # Get timestamp of most recent uncommitted change + import os + import glob + + latest_change = 0 + for line in status_result.stdout.strip().split('\n'): + if line.strip(): + # Extract filename (skip first 3 chars which are status indicators) + filename = line[3:].strip() + try: + file_path = repo_path / filename + if file_path.exists(): + mtime = os.path.getmtime(file_path) + latest_change = max(latest_change, mtime) + except: + pass + + if latest_change > 0: + change_dt = datetime.fromtimestamp(latest_change) + git_info += f" including local changes until {change_dt.strftime('%Y-%m-%d %H:%M')}" + + except: + pass + + version_info = f"{version}{git_info}" + except: + version_info = "0.3.0" + edit_mode_html = f"""
-
📝 Markitect Edit Mode
+
📝 Markitect Edit Mode v{version_info}
Loading edit capabilities...