Skip to content

Commit 75624fa

Browse files
committed
rename startSession to newSession
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent 1af54d5 commit 75624fa

6 files changed

Lines changed: 25 additions & 17 deletions

File tree

docs/PROTOCOL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ All messages are JSON with a `type` field indicating the message type:
177177

178178
### Interactive Session (PTY)
179179

180-
#### StartSession
180+
#### NewSession
181181
**Direction**: Agent → Daemon
182182
**Purpose**: Start an interactive session
183183

184184
```json
185185
{
186-
"type": "start_session",
186+
"type": "new_session",
187187
"session_id": "550e8400-e29b-41d4-a716-446655440001",
188188
"rows": 24,
189189
"cols": 80,
@@ -390,7 +390,7 @@ All messages are JSON with a `type` field indicating the message type:
390390

391391
1. Agent generates unique `session_id`
392392
2. Agent registers mpsc channel for this session
393-
3. Agent sends `StartSession` message
393+
3. Agent sends `NewSession` message
394394
4. Daemon starts PTY and begins streaming output
395395
5. Agent sends `SessionInput` as user types
396396
6. Daemon sends `SessionOutput` continuously

sandd/src/main.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,14 @@ async fn connect_and_serve(
209209
};
210210

211211
// Handle message inline
212-
if let Err(e) = handle_message(message, ws_tx_clone.clone(), executor.clone(), session_manager.clone()).await {
212+
if let Err(e) = handle_message(
213+
message,
214+
ws_tx_clone.clone(),
215+
executor.clone(),
216+
session_manager.clone(),
217+
)
218+
.await
219+
{
213220
error!("Error handling message: {}", e);
214221
}
215222
}
@@ -293,7 +300,7 @@ where
293300
}
294301
}
295302

296-
Message::StartSession {
303+
Message::NewSession {
297304
session_id,
298305
rows,
299306
cols,
@@ -303,7 +310,7 @@ where
303310

304311
let mut manager = session_manager.lock().await;
305312
let result = manager
306-
.start_session(session_id.clone(), rows, cols, &term, ws_tx.clone())
313+
.new_session(session_id.clone(), rows, cols, &term, ws_tx.clone())
307314
.await;
308315

309316
let response = match result {
@@ -326,11 +333,12 @@ where
326333
.map_err(|e| anyhow::anyhow!("{}", e))?;
327334
}
328335

329-
Message::SessionInput {
330-
session_id,
331-
data,
332-
} => {
333-
debug!("Session input: {} bytes for session {}", data.len(), session_id);
336+
Message::SessionInput { session_id, data } => {
337+
debug!(
338+
"Session input: {} bytes for session {}",
339+
data.len(),
340+
session_id
341+
);
334342
let manager = session_manager.lock().await;
335343
if let Err(e) = manager.send_input(&session_id, &data).await {
336344
error!("Failed to send input to session {}: {}", session_id, e);

sandd/src/protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub enum Message {
3737
request_id: String,
3838
error: String,
3939
},
40-
StartSession {
40+
NewSession {
4141
session_id: String,
4242
rows: u16,
4343
cols: u16,

sandd/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl SessionManager {
2929
}
3030
}
3131

32-
pub async fn start_session<T>(
32+
pub async fn new_session<T>(
3333
&mut self,
3434
session_id: String,
3535
rows: u16,

server/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl Server {
133133
let session_id = Uuid::new_v4().to_string();
134134
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
135135

136-
let msg = Message::StartSession {
136+
let msg = Message::NewSession {
137137
session_id: session_id.clone(),
138138
rows,
139139
cols,

server/src/protocol.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub enum Message {
4040
},
4141

4242
// Interactive session (PTY mode)
43-
StartSession {
43+
NewSession {
4444
session_id: String,
4545
rows: u16,
4646
cols: u16,
@@ -259,7 +259,7 @@ mod tests {
259259

260260
#[test]
261261
fn test_session_messages() {
262-
let start = Message::StartSession {
262+
let start = Message::NewSession {
263263
session_id: "session-1".to_string(),
264264
rows: 24,
265265
cols: 80,
@@ -270,7 +270,7 @@ mod tests {
270270
let parsed: Message = serde_json::from_str(&json).unwrap();
271271

272272
match parsed {
273-
Message::StartSession {
273+
Message::NewSession {
274274
session_id,
275275
rows,
276276
cols,

0 commit comments

Comments
 (0)