@adiontaegerron/claude-multi-terminal 2.1.0 → 2.2.0
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/.claude/settings.local.json +14 -1
- package/.mterm-config.json +16 -0
- package/CLAUDE.md +164 -32
- package/README.md +20 -9
- package/docs/project-retrospective-final.md +106 -0
- package/index.html +24 -6
- package/ipc-message-capture.test.js +130 -0
- package/jest.config.js +6 -0
- package/main.js +188 -41
- package/message-display-debug.test.js +78 -0
- package/package.json +6 -3
- package/renderer.js +290 -7
- package/simple-test.js +48 -0
- package/style.css +286 -6
- package/tab-switching-debug.test.js +89 -0
- package/tabbed-view.test.js +151 -0
- package/ui.test.js +151 -0
|
@@ -10,7 +10,20 @@
|
|
|
10
10
|
"Bash(*)",
|
|
11
11
|
"Bash(/tmp/create_terminals.sh:*)",
|
|
12
12
|
"Bash(ls:*)",
|
|
13
|
-
"Write(*)"
|
|
13
|
+
"Write(*)",
|
|
14
|
+
"Bash(mkdir:*)",
|
|
15
|
+
"Bash(npm install)",
|
|
16
|
+
"Bash(npm test)",
|
|
17
|
+
"Bash(npm test)",
|
|
18
|
+
"Bash(node:*)",
|
|
19
|
+
"WebFetch(domain:www.electronjs.org)",
|
|
20
|
+
"Bash(git add:*)",
|
|
21
|
+
"Bash(git commit:*)",
|
|
22
|
+
"Bash(npm test:*)",
|
|
23
|
+
"Bash(git push:*)",
|
|
24
|
+
"WebFetch(domain:docs.anthropic.com)",
|
|
25
|
+
"Bash(npm whoami:*)",
|
|
26
|
+
"Bash(npm publish:*)"
|
|
14
27
|
],
|
|
15
28
|
"deny": []
|
|
16
29
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiServer": {
|
|
3
|
+
"port": 3721,
|
|
4
|
+
"baseUrl": "http://localhost:3721",
|
|
5
|
+
"version": "v2",
|
|
6
|
+
"status": "active"
|
|
7
|
+
},
|
|
8
|
+
"project": {
|
|
9
|
+
"name": "v2",
|
|
10
|
+
"initialized": "2025-08-04T04:45:56.124Z"
|
|
11
|
+
},
|
|
12
|
+
"features": {
|
|
13
|
+
"autoSource": true,
|
|
14
|
+
"healthMonitoring": true
|
|
15
|
+
}
|
|
16
|
+
}
|
package/CLAUDE.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
You are a terminal agent running in a multi-terminal coordination system. Your terminal name will be provided when you start.
|
|
4
4
|
|
|
5
|
+
## Terminal Output
|
|
6
|
+
|
|
7
|
+
DO NOT output responses directly to the terminal. ALL communication must go through the file-based JSON messaging system described below. This includes:
|
|
8
|
+
- Responses to user messages
|
|
9
|
+
- Status updates
|
|
10
|
+
- Error messages
|
|
11
|
+
- Confirmations
|
|
12
|
+
|
|
13
|
+
The only exception is system-level output like file listings or command results that are specifically requested.
|
|
14
|
+
|
|
5
15
|
## IMPORTANT: Follow Instructions Exactly
|
|
6
16
|
|
|
7
17
|
When given a command:
|
|
@@ -10,61 +20,183 @@ When given a command:
|
|
|
10
20
|
- If asked to create 2 terminals, create exactly 2 (not 3, 4, or 6)
|
|
11
21
|
- Wait for further instructions after completing each task
|
|
12
22
|
|
|
13
|
-
## Communication
|
|
23
|
+
## Communication System
|
|
14
24
|
|
|
15
|
-
|
|
25
|
+
All communication uses JSON files written to `.ipc-messages/`. There are two types of messages:
|
|
16
26
|
|
|
17
|
-
###
|
|
27
|
+
### 1. IPC Commands (trigger actions)
|
|
28
|
+
These messages execute terminal operations and are also displayed in the Messages tab.
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
### 2. Display Messages (UI only)
|
|
31
|
+
These messages only appear in the Messages tab without triggering any actions.
|
|
21
32
|
|
|
22
|
-
|
|
33
|
+
### File Naming
|
|
34
|
+
Use Write to create files with unique names:
|
|
35
|
+
`.ipc-messages/[type]_YourName_[timestamp].json`
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
Use Write to create a file `.ipc-messages/msg_YourName_[timestamp].txt` with content:
|
|
26
|
-
```
|
|
27
|
-
YourName:IPC:SEND:TargetTerminal:Your message
|
|
28
|
-
```
|
|
37
|
+
Example: `.ipc-messages/msg_Terminal1_1234567890.json`
|
|
29
38
|
|
|
30
|
-
###
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
### Message Format
|
|
40
|
+
|
|
41
|
+
All messages use this JSON structure:
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"type": "ipc|display",
|
|
45
|
+
"command": "SEND|BROADCAST|CREATE|CLOSE|RENAME|STATUS|LIST",
|
|
46
|
+
"from": "YourTerminalName",
|
|
47
|
+
"to": "TargetTerminal",
|
|
48
|
+
"content": "Message content",
|
|
49
|
+
"timestamp": 1234567890,
|
|
50
|
+
"metadata": {
|
|
51
|
+
"category": "ipc|user|system|info",
|
|
52
|
+
"visible": true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
34
55
|
```
|
|
35
56
|
|
|
36
|
-
###
|
|
37
|
-
|
|
57
|
+
### IPC Commands
|
|
58
|
+
|
|
59
|
+
#### Send Message to Another Terminal
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"type": "ipc",
|
|
63
|
+
"command": "SEND",
|
|
64
|
+
"from": "Terminal 1",
|
|
65
|
+
"to": "Terminal 2",
|
|
66
|
+
"content": "Hello Terminal 2",
|
|
67
|
+
"timestamp": 1234567890,
|
|
68
|
+
"metadata": {"category": "ipc", "visible": true}
|
|
69
|
+
}
|
|
38
70
|
```
|
|
39
|
-
|
|
71
|
+
|
|
72
|
+
#### Broadcast to All Terminals
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"type": "ipc",
|
|
76
|
+
"command": "BROADCAST",
|
|
77
|
+
"from": "Terminal 1",
|
|
78
|
+
"content": "Hello everyone",
|
|
79
|
+
"timestamp": 1234567890,
|
|
80
|
+
"metadata": {"category": "ipc", "visible": true}
|
|
81
|
+
}
|
|
40
82
|
```
|
|
41
83
|
|
|
42
|
-
|
|
43
|
-
|
|
84
|
+
#### Create New Terminal
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"type": "ipc",
|
|
88
|
+
"command": "CREATE",
|
|
89
|
+
"from": "Terminal 1",
|
|
90
|
+
"content": "Backend Server",
|
|
91
|
+
"timestamp": 1234567890,
|
|
92
|
+
"metadata": {"category": "system", "visible": true}
|
|
93
|
+
}
|
|
44
94
|
```
|
|
45
|
-
|
|
95
|
+
Note: The `content` field contains the optional name for the new terminal.
|
|
96
|
+
|
|
97
|
+
#### Close Terminal
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"type": "ipc",
|
|
101
|
+
"command": "CLOSE",
|
|
102
|
+
"from": "Terminal 1",
|
|
103
|
+
"to": "Terminal 2",
|
|
104
|
+
"content": "Closing Terminal 2",
|
|
105
|
+
"timestamp": 1234567890,
|
|
106
|
+
"metadata": {"category": "system", "visible": true}
|
|
107
|
+
}
|
|
46
108
|
```
|
|
47
|
-
|
|
109
|
+
Note: You cannot close your own terminal.
|
|
48
110
|
|
|
49
|
-
|
|
50
|
-
|
|
111
|
+
#### Rename Terminal
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"type": "ipc",
|
|
115
|
+
"command": "RENAME",
|
|
116
|
+
"from": "Terminal 1",
|
|
117
|
+
"to": "Terminal 2",
|
|
118
|
+
"content": "New Name",
|
|
119
|
+
"timestamp": 1234567890,
|
|
120
|
+
"metadata": {"category": "system", "visible": true}
|
|
121
|
+
}
|
|
51
122
|
```
|
|
52
|
-
|
|
123
|
+
|
|
124
|
+
#### List All Terminals
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"type": "ipc",
|
|
128
|
+
"command": "LIST",
|
|
129
|
+
"from": "Terminal 1",
|
|
130
|
+
"timestamp": 1234567890,
|
|
131
|
+
"metadata": {"category": "system", "visible": true}
|
|
132
|
+
}
|
|
53
133
|
```
|
|
54
|
-
Note: You cannot close your own terminal.
|
|
55
134
|
|
|
56
|
-
|
|
57
|
-
|
|
135
|
+
#### Get Terminal Status
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"type": "ipc",
|
|
139
|
+
"command": "STATUS",
|
|
140
|
+
"from": "Terminal 1",
|
|
141
|
+
"to": "Terminal 2",
|
|
142
|
+
"timestamp": 1234567890,
|
|
143
|
+
"metadata": {"category": "system", "visible": true}
|
|
144
|
+
}
|
|
58
145
|
```
|
|
59
|
-
|
|
146
|
+
|
|
147
|
+
### Display Messages
|
|
148
|
+
|
|
149
|
+
For UI feedback without triggering IPC actions:
|
|
150
|
+
|
|
151
|
+
#### Status Update
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"type": "display",
|
|
155
|
+
"from": "Terminal 1",
|
|
156
|
+
"content": "Processing file analysis...",
|
|
157
|
+
"timestamp": 1234567890,
|
|
158
|
+
"metadata": {"category": "info", "visible": true}
|
|
159
|
+
}
|
|
60
160
|
```
|
|
61
161
|
|
|
62
|
-
|
|
63
|
-
|
|
162
|
+
#### User Response (IMPORTANT - Use this for ALL responses to users)
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"type": "display",
|
|
166
|
+
"from": "Terminal 1",
|
|
167
|
+
"content": "I've completed the task. Found 3 issues that need attention.",
|
|
168
|
+
"timestamp": 1234567890,
|
|
169
|
+
"metadata": {"category": "user", "visible": true}
|
|
170
|
+
}
|
|
64
171
|
```
|
|
65
|
-
|
|
172
|
+
|
|
173
|
+
### CRITICAL: Responding to User Input
|
|
174
|
+
|
|
175
|
+
When a user types a message in the terminal, you MUST:
|
|
176
|
+
1. Write a display message to `.ipc-messages/` with your response
|
|
177
|
+
2. DO NOT output text directly to the terminal
|
|
178
|
+
3. Use `type: "display"` and `metadata.category: "user"` for user responses
|
|
179
|
+
|
|
180
|
+
Example: If a user asks "Hello, are you there?", create a file:
|
|
181
|
+
`.ipc-messages/display_Terminal1_1234567890.json`
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"type": "display",
|
|
185
|
+
"from": "Terminal 1",
|
|
186
|
+
"content": "Yes, I'm here and ready to help!",
|
|
187
|
+
"timestamp": 1234567890,
|
|
188
|
+
"metadata": {"category": "user", "visible": true}
|
|
189
|
+
}
|
|
66
190
|
```
|
|
67
191
|
|
|
192
|
+
### Important Notes
|
|
193
|
+
|
|
194
|
+
1. Always use your exact terminal name in the "from" field
|
|
195
|
+
2. Set `visible: false` to hide messages from the UI (e.g., internal status)
|
|
196
|
+
3. Use `type: "ipc"` for commands that need to execute actions
|
|
197
|
+
4. Use `type: "display"` for UI-only messages
|
|
198
|
+
5. Include timestamp using `Date.now()` for proper ordering
|
|
199
|
+
|
|
68
200
|
**Important**: Replace [timestamp] with a unique number or use the current timestamp when creating files.
|
|
69
201
|
|
|
70
202
|
## Important Rules
|
package/README.md
CHANGED
|
@@ -28,6 +28,12 @@ A multi-terminal editor for coordinating multiple Claude Code instances. Run mul
|
|
|
28
28
|
- **Rename Terminals**: Double-click terminal titles to rename them
|
|
29
29
|
- **Responsive Layout**: Adapts to different screen sizes
|
|
30
30
|
|
|
31
|
+
## Breaking Changes in v2.2
|
|
32
|
+
|
|
33
|
+
- **JSON-based IPC System** - All Claude communication now uses JSON format
|
|
34
|
+
- **File-based messaging** - Claude writes all responses to `.ipc-messages/` as JSON files
|
|
35
|
+
- **No terminal output** - Claude no longer outputs responses directly to terminal
|
|
36
|
+
|
|
31
37
|
## Breaking Changes in v2.0
|
|
32
38
|
|
|
33
39
|
- **Removed checkbox selection system** - All commands must now use @ syntax
|
|
@@ -100,17 +106,22 @@ Send commands directly to terminals using @ syntax:
|
|
|
100
106
|
|
|
101
107
|
### Claude-to-Claude Communication
|
|
102
108
|
|
|
103
|
-
Claude instances communicate by creating files in the `.ipc-messages/` directory.
|
|
109
|
+
Claude instances communicate by creating JSON files in the `.ipc-messages/` directory. All communication uses a unified JSON format:
|
|
110
|
+
|
|
111
|
+
**IPC Commands** (trigger actions and display in Messages tab):
|
|
112
|
+
- **Send message**: `{"type":"ipc","command":"SEND","from":"Terminal1","to":"Terminal2","content":"Hello"}`
|
|
113
|
+
- **Broadcast**: `{"type":"ipc","command":"BROADCAST","from":"Terminal1","content":"Hello all"}`
|
|
114
|
+
- **Create terminal**: `{"type":"ipc","command":"CREATE","from":"Terminal1","content":"NewTerminalName"}`
|
|
115
|
+
- **Close terminal**: `{"type":"ipc","command":"CLOSE","from":"Terminal1","to":"Terminal2"}`
|
|
116
|
+
- **Rename terminal**: `{"type":"ipc","command":"RENAME","from":"Terminal1","to":"Terminal2","content":"NewName"}`
|
|
117
|
+
- **List terminals**: `{"type":"ipc","command":"LIST","from":"Terminal1"}`
|
|
118
|
+
- **Get status**: `{"type":"ipc","command":"STATUS","from":"Terminal1","to":"Terminal2"}`
|
|
104
119
|
|
|
105
|
-
|
|
106
|
-
- **
|
|
107
|
-
- **
|
|
108
|
-
- **Close terminal**: Claude creates a file with `TerminalName:IPC:CLOSE:Target`
|
|
109
|
-
- **Rename terminal**: Claude creates a file with `TerminalName:IPC:RENAME:Target:NewName`
|
|
110
|
-
- **List terminals**: Claude creates a file with `TerminalName:IPC:LIST`
|
|
111
|
-
- **Get status**: Claude creates a file with `TerminalName:IPC:STATUS:Target`
|
|
120
|
+
**Display Messages** (UI only, no actions):
|
|
121
|
+
- **User responses**: `{"type":"display","from":"Terminal1","content":"Task completed","metadata":{"category":"user","visible":true}}`
|
|
122
|
+
- **Status updates**: `{"type":"display","from":"Terminal1","content":"Processing...","metadata":{"category":"info","visible":true}}`
|
|
112
123
|
|
|
113
|
-
Claude
|
|
124
|
+
All Claude responses appear in the Messages tab with clean formatting, icons, and timestamps.
|
|
114
125
|
|
|
115
126
|
### Tips
|
|
116
127
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Multi-Terminal Coordination Project Retrospective
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
We successfully debugged and fixed a chat-focused UI for the Multi Terminal Editor, resolving issues with tab visibility, IPC message display, and agent response capture.
|
|
5
|
+
|
|
6
|
+
## What Went Well
|
|
7
|
+
|
|
8
|
+
### 1. Effective Multi-Agent Coordination
|
|
9
|
+
- The IPC file-based messaging system enabled real-time communication between terminals
|
|
10
|
+
- Clear role assignments (UIExpert for CSS, DebugSpecialist for debugging, EventTracer for monitoring) helped organize efforts
|
|
11
|
+
- The @terminal and broadcast messaging worked effectively for team coordination
|
|
12
|
+
|
|
13
|
+
### 2. Systematic Problem Solving
|
|
14
|
+
- Issues were methodically identified: CSS conflicts → race conditions → missing messages
|
|
15
|
+
- Debug tests were created to verify issues before implementing fixes
|
|
16
|
+
- The approval workflow prevented conflicting changes after initial chaos
|
|
17
|
+
|
|
18
|
+
### 3. Technical Achievements
|
|
19
|
+
- Successfully fixed CSS specificity issues with tab switching
|
|
20
|
+
- Resolved race condition by moving IPC watcher initialization
|
|
21
|
+
- Implemented real-time agent response capture from PTY output
|
|
22
|
+
- All critical issues were ultimately resolved
|
|
23
|
+
|
|
24
|
+
## What Went Poorly
|
|
25
|
+
|
|
26
|
+
### 1. Initial Coordination Chaos
|
|
27
|
+
- Multiple agents (TestLead, Frontend, Architect) made conflicting changes simultaneously
|
|
28
|
+
- This led to corrupted UI state and CSS conflicts
|
|
29
|
+
- Had to establish "one agent at a time" rule mid-project
|
|
30
|
+
|
|
31
|
+
### 2. Debugging Challenges
|
|
32
|
+
- Terminal agents couldn't directly view the UI or DevTools console
|
|
33
|
+
- Had to rely on indirect methods and code analysis
|
|
34
|
+
- EventTracer became unresponsive at critical moments
|
|
35
|
+
- Puppeteer tests conflicted with running application instance
|
|
36
|
+
|
|
37
|
+
### 3. Hidden Complexity
|
|
38
|
+
- Race condition (IPC watcher starting before mainWindow) was subtle and took time to identify
|
|
39
|
+
- Initial terminal messages bypassed IPC system entirely
|
|
40
|
+
- Agent responses required PTY output parsing, not originally anticipated
|
|
41
|
+
|
|
42
|
+
## Key Learnings
|
|
43
|
+
|
|
44
|
+
### 1. Approval-First Workflow is Essential
|
|
45
|
+
- The shift to "analyze → propose → approve → implement" dramatically improved outcomes
|
|
46
|
+
- Prevented wasted effort and conflicting changes
|
|
47
|
+
- Backup/ProjectManager's central coordination was crucial
|
|
48
|
+
|
|
49
|
+
### 2. Visibility is Critical
|
|
50
|
+
- Lack of UI access for terminal agents was a major handicap
|
|
51
|
+
- Need better ways to observe application state from terminals
|
|
52
|
+
- Console logging and debug tests became essential workarounds
|
|
53
|
+
|
|
54
|
+
### 3. Message Flow Complexity
|
|
55
|
+
- Multiple paths for messages (IPC files, terminal PTY, direct writes) caused confusion
|
|
56
|
+
- Need unified message handling architecture
|
|
57
|
+
- Real-time capture requires careful state management
|
|
58
|
+
|
|
59
|
+
## Recommendations for Tool Improvements
|
|
60
|
+
|
|
61
|
+
### 1. Enhanced Coordination Features
|
|
62
|
+
- **Shared Task Board**: Real-time todo list visible to all agents
|
|
63
|
+
- **File Lock System**: Prevent simultaneous edits to same file
|
|
64
|
+
- **Agent Status Dashboard**: Show what each agent is currently working on
|
|
65
|
+
- **Conflict Detection**: Alert when multiple agents target same code section
|
|
66
|
+
|
|
67
|
+
### 2. Better Debugging Capabilities
|
|
68
|
+
- **UI State Snapshot**: Allow terminal agents to request current UI state
|
|
69
|
+
- **Console Log Streaming**: Pipe browser console to terminal agents
|
|
70
|
+
- **Test Isolation**: Run tests in separate process to avoid conflicts
|
|
71
|
+
- **Visual Regression Testing**: Capture screenshots for terminal agents
|
|
72
|
+
|
|
73
|
+
### 3. Communication Enhancements
|
|
74
|
+
- **Message Type System**: Clearly distinguish system/user/agent messages
|
|
75
|
+
- **Message Threading**: Group related messages together
|
|
76
|
+
- **Response Correlation**: Link responses to original requests
|
|
77
|
+
- **Message Search**: Find historical messages quickly
|
|
78
|
+
|
|
79
|
+
### 4. Development Workflow
|
|
80
|
+
- **Code Review Mode**: Require approval before file modifications
|
|
81
|
+
- **Rollback Capability**: Undo changes that break functionality
|
|
82
|
+
- **Change Preview**: Show diffs before applying edits
|
|
83
|
+
- **Automated Testing**: Run tests automatically after changes
|
|
84
|
+
|
|
85
|
+
### 5. Project Management
|
|
86
|
+
- **Role Templates**: Pre-defined agent roles with permissions
|
|
87
|
+
- **Knowledge Sharing**: Broadcast important findings automatically
|
|
88
|
+
- **Progress Tracking**: Visual indicators of task completion
|
|
89
|
+
- **Retrospective Generation**: Automated summary of project activity
|
|
90
|
+
|
|
91
|
+
## Technical Debt to Address
|
|
92
|
+
|
|
93
|
+
1. **Unified Message Pipeline**: Consolidate IPC files, PTY output, and direct messages
|
|
94
|
+
2. **Robust Error Handling**: Better handling when mainWindow isn't ready
|
|
95
|
+
3. **Event System**: Replace polling/delays with proper event-driven architecture
|
|
96
|
+
4. **Type Safety**: Add TypeScript for better code reliability
|
|
97
|
+
5. **Test Infrastructure**: Isolated test environment that doesn't interfere with running app
|
|
98
|
+
|
|
99
|
+
## Final Thoughts
|
|
100
|
+
|
|
101
|
+
This project demonstrated both the power and challenges of multi-agent coordination. The ability to parallelize work across specialized agents is powerful, but requires careful orchestration. The shift from chaos to structured workflow mid-project was a key turning point.
|
|
102
|
+
|
|
103
|
+
The Multi Terminal Editor has great potential as a collaborative development environment. With the recommended improvements, it could become an invaluable tool for complex software projects requiring coordinated effort across multiple specialized agents.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
*Project completed successfully with all major issues resolved.*
|
package/index.html
CHANGED
|
@@ -10,6 +10,30 @@
|
|
|
10
10
|
<div id="app">
|
|
11
11
|
<div id="toolbar">
|
|
12
12
|
<button id="new-terminal-btn">New Terminal</button>
|
|
13
|
+
<div id="view-tabs" class="view-tabs">
|
|
14
|
+
<button class="tab-control active" data-view="messages">Messages</button>
|
|
15
|
+
<button class="tab-control" data-view="terminals">Terminals</button>
|
|
16
|
+
</div>
|
|
17
|
+
<label class="debug-toggle">
|
|
18
|
+
<input type="checkbox" id="show-raw-output" />
|
|
19
|
+
<span>Show raw output</span>
|
|
20
|
+
</label>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div id="main-content-area">
|
|
24
|
+
<!-- Messages View -->
|
|
25
|
+
<div id="message-view" class="view-panel active">
|
|
26
|
+
<div id="message-display" class="message-display">
|
|
27
|
+
<!-- Terminal-to-terminal communication messages will appear here -->
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<!-- Terminals View -->
|
|
32
|
+
<div id="terminals-area" class="view-panel">
|
|
33
|
+
<div id="terminals-container">
|
|
34
|
+
<!-- Terminal instances will be added here dynamically -->
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
13
37
|
</div>
|
|
14
38
|
|
|
15
39
|
<div id="toolbar-extended">
|
|
@@ -49,12 +73,6 @@
|
|
|
49
73
|
<button id="send-message-btn">Send</button>
|
|
50
74
|
</div>
|
|
51
75
|
</div>
|
|
52
|
-
|
|
53
|
-
<div id="terminals-area">
|
|
54
|
-
<div id="terminals-container">
|
|
55
|
-
<!-- Terminal instances will be added here dynamically -->
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
76
|
</div>
|
|
59
77
|
|
|
60
78
|
<script src="renderer.js"></script>
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const { spawn } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const { test, expect, describe, beforeAll, afterAll, beforeEach } = require('@jest/globals');
|
|
5
|
+
|
|
6
|
+
describe('IPC Message Capture Tests', () => {
|
|
7
|
+
const IPC_DIR = path.join(process.cwd(), '.ipc-messages');
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
// Clean up IPC directory before each test
|
|
11
|
+
if (fs.existsSync(IPC_DIR)) {
|
|
12
|
+
const files = fs.readdirSync(IPC_DIR);
|
|
13
|
+
files.forEach(file => {
|
|
14
|
+
fs.unlinkSync(path.join(IPC_DIR, file));
|
|
15
|
+
});
|
|
16
|
+
} else {
|
|
17
|
+
fs.mkdirSync(IPC_DIR, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterAll(() => {
|
|
22
|
+
// Clean up
|
|
23
|
+
if (fs.existsSync(IPC_DIR)) {
|
|
24
|
+
const files = fs.readdirSync(IPC_DIR);
|
|
25
|
+
files.forEach(file => {
|
|
26
|
+
fs.unlinkSync(path.join(IPC_DIR, file));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('main process should detect IPC message files', async () => {
|
|
32
|
+
// Create a test IPC message file
|
|
33
|
+
const testMessage = 'TestTerminal:IPC:SEND:Terminal 1:Test message content';
|
|
34
|
+
const testFile = path.join(IPC_DIR, 'msg_test_123.txt');
|
|
35
|
+
|
|
36
|
+
// Write the file
|
|
37
|
+
fs.writeFileSync(testFile, testMessage);
|
|
38
|
+
|
|
39
|
+
// The file should be processed and deleted quickly
|
|
40
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
41
|
+
|
|
42
|
+
// File should be deleted after processing
|
|
43
|
+
expect(fs.existsSync(testFile)).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('should emit event for SEND messages', async () => {
|
|
47
|
+
// Mock test to document expected behavior
|
|
48
|
+
const expectedEvent = {
|
|
49
|
+
type: 'ipc:message',
|
|
50
|
+
data: {
|
|
51
|
+
from: 'Terminal 1',
|
|
52
|
+
to: 'Terminal 2',
|
|
53
|
+
message: 'Hello from Terminal 1',
|
|
54
|
+
messageType: 'send'
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// This documents what the main process should emit
|
|
59
|
+
expect(expectedEvent.type).toBe('ipc:message');
|
|
60
|
+
expect(expectedEvent.data.messageType).toBe('send');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('should emit event for BROADCAST messages', async () => {
|
|
64
|
+
// Mock test to document expected behavior
|
|
65
|
+
const expectedEvent = {
|
|
66
|
+
type: 'ipc:message',
|
|
67
|
+
data: {
|
|
68
|
+
from: 'Terminal 1',
|
|
69
|
+
to: 'all',
|
|
70
|
+
message: 'Broadcast to all terminals',
|
|
71
|
+
messageType: 'broadcast'
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// This documents what the main process should emit
|
|
76
|
+
expect(expectedEvent.type).toBe('ipc:message');
|
|
77
|
+
expect(expectedEvent.data.messageType).toBe('broadcast');
|
|
78
|
+
expect(expectedEvent.data.to).toBe('all');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('should handle multiple message formats', () => {
|
|
82
|
+
const testCases = [
|
|
83
|
+
{
|
|
84
|
+
content: 'Terminal1:IPC:SEND:Terminal2:Hello',
|
|
85
|
+
expected: { from: 'Terminal1', to: 'Terminal2', message: 'Hello', type: 'send' }
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
content: 'TestLead:IPC:BROADCAST:Team update',
|
|
89
|
+
expected: { from: 'TestLead', to: 'all', message: 'Team update', type: 'broadcast' }
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
content: 'Frontend:IPC:LIST',
|
|
93
|
+
expected: { from: 'Frontend', command: 'list' }
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
testCases.forEach(testCase => {
|
|
98
|
+
// This documents the expected parsing behavior
|
|
99
|
+
expect(testCase.content).toContain('IPC:');
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('renderer should receive IPC message events', () => {
|
|
104
|
+
// Document expected renderer behavior
|
|
105
|
+
const mockIpcRenderer = {
|
|
106
|
+
on: (channel, callback) => {
|
|
107
|
+
expect(channel).toBe('ipc:message');
|
|
108
|
+
|
|
109
|
+
// Simulate receiving a message
|
|
110
|
+
const mockData = {
|
|
111
|
+
from: 'Terminal 1',
|
|
112
|
+
to: 'Terminal 2',
|
|
113
|
+
message: 'Test message',
|
|
114
|
+
messageType: 'send'
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Callback should update the message display
|
|
118
|
+
expect(typeof callback).toBe('function');
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Test the expected API
|
|
123
|
+
mockIpcRenderer.on('ipc:message', (event, data) => {
|
|
124
|
+
expect(data).toHaveProperty('from');
|
|
125
|
+
expect(data).toHaveProperty('to');
|
|
126
|
+
expect(data).toHaveProperty('message');
|
|
127
|
+
expect(data).toHaveProperty('messageType');
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|