abmux 0.0.3 → 0.0.4
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/dist/cli/index.js +40 -19
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -178,6 +178,15 @@ var PANE_KIND = {
|
|
|
178
178
|
busy: "busy"
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
+
// src/utils/PathUtils.ts
|
|
182
|
+
var formatCwd = (cwd) => {
|
|
183
|
+
const home = process.env["HOME"] ?? "";
|
|
184
|
+
if (home && cwd.startsWith(home)) {
|
|
185
|
+
return `~${cwd.slice(home.length)}`;
|
|
186
|
+
}
|
|
187
|
+
return cwd;
|
|
188
|
+
};
|
|
189
|
+
|
|
181
190
|
// src/services/session-detection-service.ts
|
|
182
191
|
var BUSY_TITLES = /* @__PURE__ */ new Set([
|
|
183
192
|
"nvim",
|
|
@@ -228,13 +237,6 @@ var detectStatusFromText = (paneText) => {
|
|
|
228
237
|
}
|
|
229
238
|
return SESSION_STATUS.idle;
|
|
230
239
|
};
|
|
231
|
-
var formatCwd = (cwd) => {
|
|
232
|
-
const home = process.env["HOME"] ?? "";
|
|
233
|
-
if (home && cwd.startsWith(home)) {
|
|
234
|
-
return `~${cwd.slice(home.length)}`;
|
|
235
|
-
}
|
|
236
|
-
return cwd;
|
|
237
|
-
};
|
|
238
240
|
var toUnifiedPane = (pane) => {
|
|
239
241
|
const kind = classifyPane(pane);
|
|
240
242
|
if (kind === PANE_KIND.claude) {
|
|
@@ -505,7 +507,7 @@ var createUsecases = (context) => ({
|
|
|
505
507
|
// package.json
|
|
506
508
|
var package_default = {
|
|
507
509
|
name: "abmux",
|
|
508
|
-
version: "0.0.
|
|
510
|
+
version: "0.0.4",
|
|
509
511
|
repository: {
|
|
510
512
|
type: "git",
|
|
511
513
|
url: "https://github.com/cut0/abmux.git"
|
|
@@ -576,7 +578,7 @@ import { createElement } from "react";
|
|
|
576
578
|
// src/components/ManagerView.tsx
|
|
577
579
|
import { basename as basename2 } from "node:path";
|
|
578
580
|
import { Box as Box10, Text as Text10 } from "ink";
|
|
579
|
-
import { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo5,
|
|
581
|
+
import { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo5, useState as useState5 } from "react";
|
|
580
582
|
|
|
581
583
|
// src/components/shared/Header.tsx
|
|
582
584
|
import { Box, Text } from "ink";
|
|
@@ -626,6 +628,7 @@ var sortSessionGroups = (groups, currentSession) => {
|
|
|
626
628
|
var SessionListPanel = ({
|
|
627
629
|
sessionGroups,
|
|
628
630
|
currentSession,
|
|
631
|
+
sessionPathMap,
|
|
629
632
|
isFocused,
|
|
630
633
|
availableRows,
|
|
631
634
|
onSelect,
|
|
@@ -706,9 +709,10 @@ var SessionListPanel = ({
|
|
|
706
709
|
const globalIndex = scrollOffset + i;
|
|
707
710
|
const isHighlighted = globalIndex === clampedCursor;
|
|
708
711
|
const isCurrent = name === currentSession;
|
|
712
|
+
const path = sessionPathMap.get(name);
|
|
709
713
|
return /* @__PURE__ */ jsxs(Box3, { paddingLeft: 1, gap: 1, children: [
|
|
710
714
|
/* @__PURE__ */ jsx3(Text3, { color: isHighlighted ? "green" : void 0, children: isHighlighted ? "\u25B6" : " " }),
|
|
711
|
-
/* @__PURE__ */ jsx3(Text3, { color: isHighlighted ? "green" : "cyan", bold: isHighlighted, wrap: "truncate", children: name }),
|
|
715
|
+
/* @__PURE__ */ jsx3(Text3, { color: isHighlighted ? "green" : "cyan", bold: isHighlighted, wrap: "truncate", children: path ? formatCwd(path) : name }),
|
|
712
716
|
isCurrent && /* @__PURE__ */ jsx3(Text3, { color: "yellow", children: "(cwd)" })
|
|
713
717
|
] }, name);
|
|
714
718
|
}) })
|
|
@@ -1120,6 +1124,7 @@ var ManagerView = ({
|
|
|
1120
1124
|
currentSession,
|
|
1121
1125
|
currentCwd,
|
|
1122
1126
|
directories,
|
|
1127
|
+
sessionCwdMap,
|
|
1123
1128
|
restoredPrompt,
|
|
1124
1129
|
restoredSession
|
|
1125
1130
|
}) => {
|
|
@@ -1130,13 +1135,12 @@ var ManagerView = ({
|
|
|
1130
1135
|
const [selectedSession, setSelectedSession] = useState5(restoredSession);
|
|
1131
1136
|
const [pendingPrompt, setPendingPrompt] = useState5(restoredPrompt ?? "");
|
|
1132
1137
|
const [pendingDeleteSession, setPendingDeleteSession] = useState5(void 0);
|
|
1133
|
-
const sessionCwdMap = useRef2(/* @__PURE__ */ new Map());
|
|
1134
1138
|
const refresh = useCallback3(async () => {
|
|
1135
1139
|
try {
|
|
1136
1140
|
const groups = await actions.fetchSessions();
|
|
1137
1141
|
const knownNames = new Set(groups.map((g) => g.sessionName));
|
|
1138
1142
|
const missing = [];
|
|
1139
|
-
for (const name of sessionCwdMap.
|
|
1143
|
+
for (const name of sessionCwdMap.keys()) {
|
|
1140
1144
|
if (!knownNames.has(name)) {
|
|
1141
1145
|
missing.push({ sessionName: name, tabs: [] });
|
|
1142
1146
|
}
|
|
@@ -1160,13 +1164,23 @@ var ManagerView = ({
|
|
|
1160
1164
|
() => fetchState.data.find((g) => g.sessionName === resolvedSession),
|
|
1161
1165
|
[fetchState.data, resolvedSession]
|
|
1162
1166
|
);
|
|
1167
|
+
const sessionPathMap = useMemo5(() => {
|
|
1168
|
+
const map = /* @__PURE__ */ new Map();
|
|
1169
|
+
for (const group of fetchState.data) {
|
|
1170
|
+
const fromMap = sessionCwdMap.get(group.sessionName);
|
|
1171
|
+
const fromPane = group.tabs[0]?.panes[0]?.pane.cwd;
|
|
1172
|
+
const path = fromMap ?? fromPane;
|
|
1173
|
+
if (path) map.set(group.sessionName, path);
|
|
1174
|
+
}
|
|
1175
|
+
return map;
|
|
1176
|
+
}, [fetchState.data]);
|
|
1163
1177
|
const handleOpenAddSession = useCallback3(() => {
|
|
1164
1178
|
setMode(MODE.addSession);
|
|
1165
1179
|
}, []);
|
|
1166
1180
|
const handleAddSessionSelect = useCallback3(
|
|
1167
1181
|
(path) => {
|
|
1168
1182
|
const name = basename2(path);
|
|
1169
|
-
sessionCwdMap.
|
|
1183
|
+
sessionCwdMap.set(name, path);
|
|
1170
1184
|
const exists2 = fetchState.data.some((g) => g.sessionName === name);
|
|
1171
1185
|
if (!exists2) {
|
|
1172
1186
|
setFetchState((prev) => ({
|
|
@@ -1188,7 +1202,7 @@ var ManagerView = ({
|
|
|
1188
1202
|
}, []);
|
|
1189
1203
|
const handleConfirmDelete = useCallback3(() => {
|
|
1190
1204
|
if (!pendingDeleteSession) return;
|
|
1191
|
-
sessionCwdMap.
|
|
1205
|
+
sessionCwdMap.delete(pendingDeleteSession);
|
|
1192
1206
|
if (resolvedSession === pendingDeleteSession) {
|
|
1193
1207
|
setSelectedSession(void 0);
|
|
1194
1208
|
}
|
|
@@ -1208,11 +1222,12 @@ var ManagerView = ({
|
|
|
1208
1222
|
);
|
|
1209
1223
|
const handleConfirmNew = useCallback3(() => {
|
|
1210
1224
|
if (!resolvedSession) return;
|
|
1211
|
-
const
|
|
1225
|
+
const existingCwd = selectedGroup?.tabs[0]?.panes[0]?.pane.cwd;
|
|
1226
|
+
const cwd = sessionCwdMap.get(resolvedSession) ?? existingCwd ?? currentCwd;
|
|
1212
1227
|
void actions.createSession(resolvedSession, cwd, pendingPrompt).then(() => void refresh());
|
|
1213
1228
|
setPendingPrompt("");
|
|
1214
1229
|
setMode(MODE.split);
|
|
1215
|
-
}, [resolvedSession, currentCwd, pendingPrompt, actions, refresh]);
|
|
1230
|
+
}, [resolvedSession, selectedGroup, currentCwd, pendingPrompt, actions, refresh]);
|
|
1216
1231
|
const handleCancelConfirm = useCallback3(() => {
|
|
1217
1232
|
setPendingPrompt("");
|
|
1218
1233
|
setMode(MODE.split);
|
|
@@ -1226,7 +1241,7 @@ var ManagerView = ({
|
|
|
1226
1241
|
}, []);
|
|
1227
1242
|
const handleNavigate = useCallback3(
|
|
1228
1243
|
(up) => {
|
|
1229
|
-
actions.
|
|
1244
|
+
void actions.navigateToPane(up);
|
|
1230
1245
|
},
|
|
1231
1246
|
[actions]
|
|
1232
1247
|
);
|
|
@@ -1310,6 +1325,7 @@ var ManagerView = ({
|
|
|
1310
1325
|
{
|
|
1311
1326
|
sessionGroups: fetchState.data,
|
|
1312
1327
|
currentSession,
|
|
1328
|
+
sessionPathMap,
|
|
1313
1329
|
isFocused: focus === FOCUS.left,
|
|
1314
1330
|
availableRows: panelHeight,
|
|
1315
1331
|
onSelect: handleSessionSelect,
|
|
@@ -1352,6 +1368,7 @@ var ManagerView = ({
|
|
|
1352
1368
|
// src/cli/tui-command.ts
|
|
1353
1369
|
var createTuiCommand = ({ usecases, services, infra }) => async () => {
|
|
1354
1370
|
const directories = await services.directoryScan.scan();
|
|
1371
|
+
const sessionCwdMap = /* @__PURE__ */ new Map();
|
|
1355
1372
|
let instance;
|
|
1356
1373
|
let pendingPrompt;
|
|
1357
1374
|
let pendingSession;
|
|
@@ -1394,9 +1411,12 @@ var createTuiCommand = ({ usecases, services, infra }) => async () => {
|
|
|
1394
1411
|
instance = renderApp();
|
|
1395
1412
|
return prompt;
|
|
1396
1413
|
},
|
|
1397
|
-
|
|
1414
|
+
navigateToPane: async (up) => {
|
|
1415
|
+
const target = `${up.pane.sessionName}:${String(up.pane.windowIndex)}`;
|
|
1416
|
+
await infra.tmuxCli.selectWindow(target);
|
|
1417
|
+
await infra.tmuxCli.selectPane(up.pane.paneId);
|
|
1398
1418
|
instance.unmount();
|
|
1399
|
-
|
|
1419
|
+
await infra.tmuxCli.attachSession(up.pane.sessionName);
|
|
1400
1420
|
instance = renderApp();
|
|
1401
1421
|
}
|
|
1402
1422
|
};
|
|
@@ -1411,6 +1431,7 @@ var createTuiCommand = ({ usecases, services, infra }) => async () => {
|
|
|
1411
1431
|
currentSession: basename3(process.cwd()),
|
|
1412
1432
|
currentCwd: process.cwd(),
|
|
1413
1433
|
directories,
|
|
1434
|
+
sessionCwdMap,
|
|
1414
1435
|
restoredPrompt: prompt,
|
|
1415
1436
|
restoredSession: session
|
|
1416
1437
|
}),
|