claude-opencode-viewer 2.6.21 → 2.6.22

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +4 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-opencode-viewer",
3
- "version": "2.6.21",
3
+ "version": "2.6.22",
4
4
  "description": "A unified terminal viewer for Claude Code and OpenCode with seamless switching",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -16,7 +16,7 @@ process.title = 'claude-opencode-viewer';
16
16
 
17
17
  const __dirname = dirname(fileURLToPath(import.meta.url));
18
18
  const IS_PC = process.argv.includes('--pc');
19
- let PORT = parseInt(process.argv[2]) || (IS_PC ? 19200 : 7008);
19
+ const PORT = parseInt(process.argv[2]) || 7008;
20
20
  const USE_HTTPS = process.argv.includes('--https');
21
21
  const JSON_OUTPUT = process.argv.includes('--json');
22
22
 
@@ -948,12 +948,7 @@ function cleanupAndExit() {
948
948
  process.on('SIGINT', cleanupAndExit);
949
949
  process.on('SIGTERM', cleanupAndExit);
950
950
 
951
- // 端口范围,用于端口冲突重试
952
- const PORT_MIN = IS_PC ? 19200 : 7008;
953
- const PORT_MAX = IS_PC ? 19220 : 7028;
954
- const MAX_PORT_RETRIES = 20;
955
-
956
- function startServer(retries = 0) {
951
+ function startServer() {
957
952
  server.listen(PORT, '0.0.0.0', async () => {
958
953
  const ip = getLocalIp();
959
954
  const proto = USE_HTTPS ? 'https' : 'http';
@@ -991,15 +986,8 @@ function startServer(retries = 0) {
991
986
  });
992
987
 
993
988
  server.on('error', (err) => {
994
- if (err.code === 'EADDRINUSE' && retries < MAX_PORT_RETRIES) {
995
- const oldPort = PORT;
996
- PORT = PORT >= PORT_MAX ? PORT_MIN : PORT + 1;
997
- console.error(`[port] ${oldPort} 已占用,尝试 ${PORT} (${retries + 1}/${MAX_PORT_RETRIES})`);
998
- createServerAndWss();
999
- startServer(retries + 1);
1000
- } else {
1001
- console.error(`启动失败: ${err.message}`);
1002
- process.exit(1);
989
+ console.error(`启动失败: ${err.message}`);
990
+ process.exit(1);
1003
991
  }
1004
992
  });
1005
993
  }