maw-workspaces 0.49.0

Multi-Agent Workflow coordinator for Manifold git workspaces
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# maw TUI Specification

A terminal UI for maw, inspired by lazygit. Built with ratatui.

## Launch

```bash
maw ui
```

## Design Goals

1. **At-a-glance status** - See all agent workspaces and their state instantly
2. **Quick actions** - Common operations (create, merge, destroy) accessible via single keys
3. **Live updates** - Watch agents work in real-time
4. **Keyboard-driven** - Full control without mouse, vim-style navigation

## Layout

```
┌─[1]-Workspaces────────────────┬─[0]-Details─────────────────────────┐
│ > default        @ main       │ Workspace: agent-1                  │
│   agent-1        abc123 wip   │ Path: ws/agent-1           │
│   agent-2        def456 feat  │ Change: abc123                      │
│   agent-3        (stale)      │ Status: active                      │
│                               │                                     │
│                               │ Description:                        │
│                               │   wip: implementing auth            │
│                               │                                     │
│                         3 of 4│ Files changed: 3                    │
├─[2]-Commits───────────────────┤   M src/auth.rs                     │
│ ○ abc123 wip: implementing    │   A src/auth_test.rs                │
│ ○ def456 feat: add user model │   M Cargo.toml                      │
│ ○─┬ 12c05c merge: agent work  │                                     │
│   ├─○ d654a4 feat(ws): status │                                     │
│   └─○ 869308 feat(ws): sync   │                                     │
│ ◆ 396d8a main: initial impl   ├─────────────────────────────────────┤
│                               │ [Command Log]                       │
│                        6 of 12│ > jj workspace list                 │
├─[3]-Issues────────────────────│ > jj log -r @                       │
│ ● bd-1cj [P1] Add TUI         │ > jj status                         │
│ ○ bd-v29 [P2] Add tests       │                                     │
│                         2 of 2│                                     │
└───────────────────────────────┴─────────────────────────────────────┘
 c:create  d:destroy  m:merge  s:sync  r:refresh  ?:help  q:quit
```

## Panels

### [1] Workspaces (Primary)

Lists all jj workspaces with their current state.

| Column | Description |
|--------|-------------|
| Selection | `>` marks selected row |
| Name | Workspace name |
| Current | `@` marks the workspace you're currently in |
| Change ID | Short change ID (8 chars) |
| Description | Commit description (truncated) |

**Status indicators** (shown after name):
- `(stale)` - Working copy is stale, needs sync
- `(conflict)` - Has unresolved conflicts
- `(empty)` - No changes yet

### [2] Commits

Shows `jj log --all` as a graph, highlighting commits from the selected workspace.

| Symbol | Meaning |
|--------|---------|
| `` | Normal commit |
| `` | Immutable commit (pushed) |
| `` | Commit with conflicts |
| `├─` `└─` | Merge lines |

### [3] Issues (Optional)

Shows beads issues if `.beads/` directory exists. Hidden if beads not configured.

| Column | Description |
|--------|-------------|
| Status | `` open, `` closed |
| ID | Issue ID (e.g., `bd-1cj`) |
| Priority | `[P1]` through `[P5]` |
| Title | Issue title (truncated) |

### [0] Details (Right Panel, Top)

Context-sensitive detail view based on selected panel:

**Workspace selected:**
```
Workspace: agent-1
Path: ws/agent-1
Change: abc123def456
Status: active | stale | conflict

Description:
  wip: implementing authentication

Files changed: 3
  M src/auth.rs
  A src/auth_test.rs
  M Cargo.toml
```

**Commit selected:**
```
Commit: abc123def456
Author: bob@example.com
Date: 2024-01-15 10:30:00

feat: add authentication module

This commit adds the basic auth module with
JWT token support.

Files: 3 changed, +150, -20
```

**Issue selected:**
```
bd-1cj: Add TUI for maw
Priority: P1 | Type: feature | Status: open

Description:
  Build a lazygit-inspired TUI using ratatui.
  Should show workspaces, commits, and issues.

Blocked by: (none)
Blocking: bd-2ab, bd-3cd
```

### Command Log (Right Panel, Bottom)

Shows recent commands executed by the TUI:

```
[Command Log]
> jj workspace list
> jj log -r 'all()' --no-graph -T '...'
> jj status
```

Scrollable with `j/k` when focused. Helps users understand what the TUI is doing.

## Keybindings

### Global

| Key | Action |
|-----|--------|
| `1` | Focus Workspaces panel |
| `2` | Focus Commits panel |
| `3` | Focus Issues panel |
| `0` | Focus Details panel |
| `Tab` | Cycle panels forward |
| `Shift+Tab` | Cycle panels backward |
| `r` | Refresh all data |
| `?` | Show help popup |
| `q` / `Ctrl+c` | Quit |

### Navigation (All Panels)

| Key | Action |
|-----|--------|
| `j` / `↓` | Move down |
| `k` / `↑` | Move up |
| `g` | Go to top |
| `G` | Go to bottom |
| `Enter` | Select / expand |
| `/` | Search (future) |

### Workspaces Panel

| Key | Action |
|-----|--------|
| `c` | Create new workspace |
| `d` | Destroy selected workspace |
| `s` | Sync selected workspace (update-stale) |
| `m` | Merge selected workspace into current |
| `M` | Merge all workspaces |
| `Enter` | Show workspace details |

### Commits Panel

| Key | Action |
|-----|--------|
| `Enter` | Show commit details/diff |
| `e` | Edit commit message (jj describe) |

### Issues Panel

| Key | Action |
|-----|--------|
| `Enter` | Show issue details |
| `i` | Mark as in_progress |
| `x` | Close issue |
| `n` | Create new issue |

## Popups

### Create Workspace

```
┌─ Create Workspace ─────────────────┐
│                                    │
│  Name: agent-1█                    │
│                                    │
│  Base revision: [main]             │
│                                    │
│         [Create]  [Cancel]         │
│                                    │
│  Enter: confirm  Esc: cancel       │
└────────────────────────────────────┘
```

- Name field auto-validates (shows error for invalid names)
- Base revision dropdown: main, @, or type custom

### Confirm Destroy

```
┌─ Destroy Workspace ────────────────┐
│                                    │
│  Destroy workspace 'agent-1'?      │
│                                    │
│  This will:                        │
│  • Forget workspace from jj        │
│  • Delete ws/agent-1/     │
│                                    │
│  ⚠ Unmerged changes will be lost!  │
│                                    │
│          [Yes]  [No]               │
│                                    │
│  y: confirm  n/Esc: cancel         │
└────────────────────────────────────┘
```

- Shows warning if workspace has unmerged changes
- Requires explicit confirmation

### Merge Workspaces

```
┌─ Merge Workspaces ─────────────────┐
│                                    │
│  Select workspaces to merge:       │
│                                    │
│  [x] agent-1     abc123 wip: auth  │
│  [x] agent-2     def456 feat: api  │
│  [ ] agent-3     (stale)           │
│                                    │
│  ─────────────────────────────────│
│  [ ] Destroy workspaces after      │
│                                    │
│  Message:                          │
│  merge: combine agent work█        │
│                                    │
│         [Merge]  [Cancel]          │
│                                    │
│  Space: toggle  Enter: merge       │
└────────────────────────────────────┘
```

- Checkbox list of workspaces
- Stale workspaces shown but unchecked by default
- Optional: destroy after merge
- Editable merge commit message

### Help

```
┌─ Keybindings ──────────────────────────────────────┐
│                                                    │
│  Navigation                                        │
│    j/k, ↑/↓    Move up/down                        │
│    g/G         Go to top/bottom                    │
│    1-3         Focus panel                         │
│    Tab         Cycle panels                        │
│                                                    │
│  Workspaces                                        │
│    c           Create new workspace                │
│    d           Destroy workspace                   │
│    s           Sync (fix stale)                    │
│    m           Merge selected                      │
│    M           Merge all                           │
│                                                    │
│  Issues                                            │
│    i           Mark in progress                    │
│    x           Close issue                         │
│    n           New issue                           │
│                                                    │
│  General                                           │
│    r           Refresh                             │
│    ?           This help                           │
│    q           Quit                                │
│                                                    │
│                    [Close]                         │
└────────────────────────────────────────────────────┘
```

## Color Scheme

Following lazygit conventions for familiarity:

| Element | Color |
|---------|-------|
| Panel titles | Cyan |
| Selected/focused | Cyan background |
| Current workspace (`@`) | Green |
| Stale indicator | Yellow |
| Conflict indicator | Red |
| Immutable commits | Blue |
| Issue priorities P1-P2 | Red |
| Issue priorities P3 | Yellow |
| Issue priorities P4-P5 | Gray |
| Keybindings in status bar | Yellow |
| Secondary text | Gray |

## Data Refresh

| Trigger | Action |
|---------|--------|
| Startup | Full refresh of all data |
| Focus change | Refresh details for selected item |
| Every 2s | Poll for workspace changes |
| `r` key | Force full refresh |
| After action | Refresh affected panels |

## Implementation

### Dependencies

```toml
[dependencies]
ratatui = "0.29"
crossterm = "0.28"
tokio = { version = "1", features = ["full", "rt-multi-thread"] }
```

### Module Structure

```
src/
  tui/
    mod.rs              # pub fn run() entry point
    app.rs              # App state struct
    ui.rs               # Main layout rendering
    event.rs            # Event handling (keys, resize)
    panels/
      mod.rs
      workspaces.rs     # Workspace list panel
      commits.rs        # Commit graph panel
      issues.rs         # Issues panel
      details.rs        # Detail view panel
      command_log.rs    # Command log panel
    popups/
      mod.rs
      create.rs         # Create workspace popup
      destroy.rs        # Confirm destroy popup
      merge.rs          # Merge options popup
      help.rs           # Help popup
    commands.rs         # Execute jj/br commands
    theme.rs            # Colors and styles
```

### App State

```rust
pub struct App {
    // Data
    workspaces: Vec<Workspace>,
    commits: Vec<Commit>,
    issues: Vec<Issue>,
    command_log: Vec<String>,
    
    // Selection
    focused_panel: Panel,
    workspace_state: ListState,
    commit_state: ListState,
    issue_state: ListState,
    
    // UI
    popup: Option<Popup>,
    should_quit: bool,
    last_refresh: Instant,
}

pub struct Workspace {
    name: String,
    change_id: String,
    commit_id: String,
    description: String,
    is_current: bool,
    is_stale: bool,
    has_conflict: bool,
}
```

## Future Enhancements

1. **Diff view** - Full diff viewing with syntax highlighting
2. **Botbus integration** - Show agent messages in a panel
3. **Split view** - Compare two workspaces side-by-side
4. **Search** - `/` to search across panels
5. **Mouse support** - Click to select, scroll
6. **Themes** - Light mode, custom colors

## Open Questions

1. Should Issues panel be hidden when beads unavailable, or show "not configured"?
2. Mouse support: yes/no? (lazygit supports it)
3. Should we show botbus messages if available?