Skip to content

Instantly share code, notes, and snippets.

@arockwell
Created July 13, 2025 07:28
Show Gist options
  • Select an option

  • Save arockwell/da8548cc7cc6bc200cdb9464a34848d2 to your computer and use it in GitHub Desktop.

Select an option

Save arockwell/da8548cc7cc6bc200cdb9464a34848d2 to your computer and use it in GitHub Desktop.
EMDX Background Execution + Log Viewer Architecture - Alternative to tmux panes with async job execution
  1. Background Job Manager

    • Press key in emdx GUI → spawns background process
    • Each job gets a unique ID (maybe tied to doc ID)
    • Logs stream to files or database
  2. TUI Log Viewer (new mode in emdx)

    • Press l for "logs" view
    • Shows active/recent jobs
    • Live tail of outputs
    • Filter by document, tag, status
def action_git_operation(self):
    job_id = f"git-{self.current_doc_id}-{timestamp}"
    
    subprocess.Popen([
        'bash', '-c', f'''
        exec > >(tee -a ~/.emdx/logs/{job_id}.log)
        exec 2>&1
        echo "=== Git Operation for: {doc['title']} ==="
        git checkout -b gameplan-{doc_id}
        git add .
        git commit -m "WIP: {doc['title']}"
        echo "=== Complete ==="
        '''
    ])
    
    status.update(f"Git operation started → Press 'l' to view logs")
def action_claude_execute(self):
    job = {
        'id': f"claude-{doc_id}-{timestamp}",
        'doc_id': doc_id,
        'type': 'claude-execution',
        'status': 'running',
        'log_file': f"~/.emdx/logs/claude-{doc_id}.log"
    }
    
    subprocess.Popen([
        'claude-code',
        '--file', temp_path,
        '--output-format', 'json',  # For structured parsing
        '--log-file', job['log_file']
    ])

Using something like Textual (which you already use), you could build:

┌─ EMDX Logs ──────────────────────────────────────────┐
│ Jobs (j/k to navigate, Enter to view)                │
├──────────────────────────────────────────────────────┤
│ ● [RUNNING] Claude: Implement Auth System      2m ago│
│ ✓ [DONE]    Git: Create feature branch        5m ago│
│ ✗ [FAILED]  Claude: Database Migration        10m ago│
│ ● [RUNNING] Monitor: API Health Check         Active │
└──────────────────────────────────────────────────────┘

┌─ Log Output ─────────────────────────────────────────┐
│ [13:45:02] Starting Claude execution...              │
│ [13:45:03] Analyzing document: Auth System Gameplan  │
│ [13:45:04] Found 5 implementation tasks              │
│ [13:45:05] Task 1/5: Create user model              │
│ [13:45:06] > Running: poetry add bcrypt             │
│ [13:45:08] > Success: bcrypt==4.0.1 installed       │
│ [13:45:09] > Creating: models/user.py               │
│ ▌                                                    │
└──────────────────────────────────────────────────────┘
  1. Non-blocking - Can trigger multiple operations
  2. Persistent logs - Review what happened later
  3. Pattern matching - Search across all executions
  4. Status tracking - See what's running/failed/completed
  5. Less tmux clutter - Clean workspace
  • stern - Multi-pod Kubernetes log tailing
  • lnav - Advanced log file navigator
  • multitail - Multiple log monitoring
  • glogg - Fast log explorer

But building it into emdx means:

  • Integrated with your documents

  • Custom formatting for Claude/Git output

  • Smart filtering by tags/projects

  • Direct jump from log → document

  • Press c in emdx GUI → Claude runs in background

  • Press g → Git operations in background

  • Press l → See all running/completed jobs

  • Select a job → View live streaming logs

  • Press d in log view → Jump back to source document

This creates a complete async workflow where you can trigger multiple operations and monitor them all from within emdx!

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