Skip to content

Commit 9eab689

Browse files
committed
feat: Added terminal resize handler
1 parent 5b1432d commit 9eab689

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"deploy": "npm run pkg && npm run notarize && npm run upload",
145145
"prepublishOnly": "npm run build"
146146
},
147-
"version": "1.1.0-beta5",
147+
"version": "1.1.0-beta6",
148148
"bugs": "https://github.com/codifycli/codify/issues",
149149
"keywords": [
150150
"oclif",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Router } from 'express';
2+
import { SocketServer } from '../../socket-server.js';
3+
4+
export function resizeHandler(): Router {
5+
const router = Router({ mergeParams: true });
6+
7+
router.post('/:sessionId', (req, res) => {
8+
const { sessionId } = req.params;
9+
const { cols, rows } = req.body;
10+
11+
if (!cols || !rows) {
12+
return res.status(400).json({ error: 'cols and rows required' });
13+
}
14+
15+
const manager = SocketServer.get();
16+
const session = manager.getSession(sessionId);
17+
18+
if (!session) {
19+
return res.status(400).json({ error: 'SessionId does not exist' });
20+
}
21+
22+
if (!session.pty) {
23+
return res.status(304).json({ status: 'PTY not yet started' });
24+
}
25+
26+
session.pty.resize(cols, rows);
27+
28+
return res.status(204).json({});
29+
});
30+
31+
return router;
32+
}

src/connect/http-routes/router.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import defaultHandler from './handlers/index.js';
66
import { initHandler } from './handlers/init-handler.js';
77
import { planHandler } from './handlers/plan-handler.js';
88
import { refreshHandler } from './handlers/refresh-handler.js';
9+
import { resizeHandler } from './handlers/resize-handler.js';
910
import { terminalHandler } from './handlers/terminal-handler.js';
1011
import { testHandler } from './handlers/test-handler.js';
1112

@@ -16,6 +17,7 @@ router.use('/apply', applyHandler());
1617
router.use('/plan', planHandler())
1718
router.use('/import', importHandler());
1819
router.use('/refresh', refreshHandler());
20+
router.use('/resize', resizeHandler());
1921
router.use('/terminal', terminalHandler());
2022
router.use('/init', initHandler());
2123
router.use('/test', testHandler());

0 commit comments

Comments
 (0)