git-watchtower 1.10.6 → 1.10.7
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/package.json +1 -1
- package/src/server/web-ui/js.js +98 -121
package/package.json
CHANGED
package/src/server/web-ui/js.js
CHANGED
|
@@ -1049,6 +1049,99 @@ ${pureFnBlock}
|
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
1051
|
// ── Keyboard ───────────────────────────────────────────────────
|
|
1052
|
+
|
|
1053
|
+
// Key-to-action mapping for normal mode.
|
|
1054
|
+
// Declarative — easy to test, extend, and share with TUI.
|
|
1055
|
+
const KEY_MAP = {
|
|
1056
|
+
'j': 'moveDown',
|
|
1057
|
+
'ArrowDown': 'moveDown',
|
|
1058
|
+
'k': 'moveUp',
|
|
1059
|
+
'ArrowUp': 'moveUp',
|
|
1060
|
+
'Enter': 'selectBranch',
|
|
1061
|
+
'/': 'search',
|
|
1062
|
+
'p': 'pull',
|
|
1063
|
+
'f': 'fetch',
|
|
1064
|
+
'r': 'reloadBrowsers',
|
|
1065
|
+
'R': 'restartServer',
|
|
1066
|
+
'c': 'toggleCasino',
|
|
1067
|
+
'o': 'openBrowser',
|
|
1068
|
+
'h': 'showHistory',
|
|
1069
|
+
'u': 'undo',
|
|
1070
|
+
's': 'toggleSound',
|
|
1071
|
+
'b': 'branchActions',
|
|
1072
|
+
'i': 'info',
|
|
1073
|
+
'l': 'logViewer',
|
|
1074
|
+
'S': 'stash',
|
|
1075
|
+
'd': 'cleanup',
|
|
1076
|
+
'Escape': 'escape',
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
// Action handlers for normal mode.
|
|
1080
|
+
// Each receives the KeyboardEvent for cases that need it.
|
|
1081
|
+
const KEY_ACTIONS = {
|
|
1082
|
+
moveDown() { moveSelection(1); },
|
|
1083
|
+
moveUp() { moveSelection(-1); },
|
|
1084
|
+
selectBranch() {
|
|
1085
|
+
const branches = getDisplayBranches();
|
|
1086
|
+
if (branches.length > 0 && ui.selectedIndex < branches.length) {
|
|
1087
|
+
const b = branches[ui.selectedIndex];
|
|
1088
|
+
if (b.isDeleted) {
|
|
1089
|
+
showToast('Cannot switch to a deleted branch', 'error');
|
|
1090
|
+
} else if (b.name === state.currentBranch) {
|
|
1091
|
+
showToast('Already on ' + b.name, 'info');
|
|
1092
|
+
} else {
|
|
1093
|
+
sendAction('switchBranch', { branch: b.name });
|
|
1094
|
+
showToast('Switching to ' + b.name + '...', 'info');
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
},
|
|
1098
|
+
search() {
|
|
1099
|
+
ui.searchMode = true;
|
|
1100
|
+
ui.searchQuery = '';
|
|
1101
|
+
ui.selectedIndex = 0;
|
|
1102
|
+
document.getElementById('search-bar').className = 'search-bar active';
|
|
1103
|
+
const input = document.getElementById('search-input');
|
|
1104
|
+
input.value = '';
|
|
1105
|
+
input.focus();
|
|
1106
|
+
},
|
|
1107
|
+
pull() { sendAction('pull'); showToast('Pulling current branch...', 'info'); },
|
|
1108
|
+
fetch() { sendAction('fetch'); showToast('Fetching all branches...', 'info'); },
|
|
1109
|
+
reloadBrowsers() {
|
|
1110
|
+
if (state && state.serverMode === 'static') {
|
|
1111
|
+
sendAction('reloadBrowsers');
|
|
1112
|
+
showToast('Reloading browsers...', 'info');
|
|
1113
|
+
}
|
|
1114
|
+
},
|
|
1115
|
+
restartServer() {
|
|
1116
|
+
if (state && state.serverMode === 'command') {
|
|
1117
|
+
showConfirm('Restart Server', 'Restart the dev server process?', () => {
|
|
1118
|
+
sendAction('restartServer');
|
|
1119
|
+
showToast('Restarting server...', 'info');
|
|
1120
|
+
}, { label: 'Restart' });
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
toggleCasino() { sendAction('toggleCasino'); },
|
|
1124
|
+
openBrowser() { sendAction('openBrowser'); showToast('Opening in browser...', 'info'); },
|
|
1125
|
+
showHistory() {
|
|
1126
|
+
if (state && state.switchHistory && state.switchHistory.length > 0) {
|
|
1127
|
+
const last = state.switchHistory[0];
|
|
1128
|
+
let histMsg = 'Last: ' + last.from + ' \\u2192 ' + last.to;
|
|
1129
|
+
if (state.switchHistory.length > 1) histMsg += ' (+' + (state.switchHistory.length - 1) + ' more)';
|
|
1130
|
+
showToast(histMsg, 'info');
|
|
1131
|
+
} else {
|
|
1132
|
+
showToast('No switch history yet', 'info');
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
undo() { sendAction('undo'); showToast('Undoing last switch...', 'info'); },
|
|
1136
|
+
toggleSound() { sendAction('toggleSound'); showToast(state && state.soundEnabled ? 'Sound off' : 'Sound on', 'info'); },
|
|
1137
|
+
branchActions() { showBranchActions(); },
|
|
1138
|
+
info() { showInfo(); },
|
|
1139
|
+
logViewer() { showLogViewer(); },
|
|
1140
|
+
stash() { showStashDialog(null); },
|
|
1141
|
+
cleanup() { showCleanup(); },
|
|
1142
|
+
escape() { /* no-op in normal mode */ },
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1052
1145
|
document.addEventListener('keydown', (e) => {
|
|
1053
1146
|
// Ignore when typing in input fields (other than search)
|
|
1054
1147
|
if (e.target.tagName === 'INPUT' && e.target.id !== 'search-input') return;
|
|
@@ -1139,127 +1232,11 @@ ${pureFnBlock}
|
|
|
1139
1232
|
return;
|
|
1140
1233
|
}
|
|
1141
1234
|
|
|
1142
|
-
// Normal mode
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
moveSelection(1);
|
|
1148
|
-
break;
|
|
1149
|
-
case 'k':
|
|
1150
|
-
case 'ArrowUp':
|
|
1151
|
-
e.preventDefault();
|
|
1152
|
-
moveSelection(-1);
|
|
1153
|
-
break;
|
|
1154
|
-
case 'Enter':
|
|
1155
|
-
e.preventDefault();
|
|
1156
|
-
const branches = getDisplayBranches();
|
|
1157
|
-
if (branches.length > 0 && ui.selectedIndex < branches.length) {
|
|
1158
|
-
const b = branches[ui.selectedIndex];
|
|
1159
|
-
if (b.isDeleted) {
|
|
1160
|
-
showToast('Cannot switch to a deleted branch', 'error');
|
|
1161
|
-
} else if (b.name === state.currentBranch) {
|
|
1162
|
-
showToast('Already on ' + b.name, 'info');
|
|
1163
|
-
} else {
|
|
1164
|
-
sendAction('switchBranch', { branch: b.name });
|
|
1165
|
-
showToast('Switching to ' + b.name + '...', 'info');
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
break;
|
|
1169
|
-
case '/':
|
|
1170
|
-
e.preventDefault();
|
|
1171
|
-
ui.searchMode = true;
|
|
1172
|
-
ui.searchQuery = '';
|
|
1173
|
-
ui.selectedIndex = 0;
|
|
1174
|
-
document.getElementById('search-bar').className = 'search-bar active';
|
|
1175
|
-
const input = document.getElementById('search-input');
|
|
1176
|
-
input.value = '';
|
|
1177
|
-
input.focus();
|
|
1178
|
-
break;
|
|
1179
|
-
case 'p':
|
|
1180
|
-
e.preventDefault();
|
|
1181
|
-
sendAction('pull');
|
|
1182
|
-
showToast('Pulling current branch...', 'info');
|
|
1183
|
-
break;
|
|
1184
|
-
case 'f':
|
|
1185
|
-
e.preventDefault();
|
|
1186
|
-
sendAction('fetch');
|
|
1187
|
-
showToast('Fetching all branches...', 'info');
|
|
1188
|
-
break;
|
|
1189
|
-
case 'r':
|
|
1190
|
-
e.preventDefault();
|
|
1191
|
-
if (state && state.serverMode === 'static') {
|
|
1192
|
-
sendAction('reloadBrowsers');
|
|
1193
|
-
showToast('Reloading browsers...', 'info');
|
|
1194
|
-
}
|
|
1195
|
-
break;
|
|
1196
|
-
case 'R':
|
|
1197
|
-
e.preventDefault();
|
|
1198
|
-
if (state && state.serverMode === 'command') {
|
|
1199
|
-
showConfirm(
|
|
1200
|
-
'Restart Server',
|
|
1201
|
-
'Restart the dev server process?',
|
|
1202
|
-
() => {
|
|
1203
|
-
sendAction('restartServer');
|
|
1204
|
-
showToast('Restarting server...', 'info');
|
|
1205
|
-
},
|
|
1206
|
-
{ label: 'Restart' }
|
|
1207
|
-
);
|
|
1208
|
-
}
|
|
1209
|
-
break;
|
|
1210
|
-
case 'c':
|
|
1211
|
-
e.preventDefault();
|
|
1212
|
-
sendAction('toggleCasino');
|
|
1213
|
-
break;
|
|
1214
|
-
case 'o':
|
|
1215
|
-
e.preventDefault();
|
|
1216
|
-
sendAction('openBrowser');
|
|
1217
|
-
showToast('Opening in browser...', 'info');
|
|
1218
|
-
break;
|
|
1219
|
-
case 'h':
|
|
1220
|
-
e.preventDefault();
|
|
1221
|
-
if (state && state.switchHistory && state.switchHistory.length > 0) {
|
|
1222
|
-
const last = state.switchHistory[0];
|
|
1223
|
-
const histMsg = 'Last: ' + last.from + ' \\u2192 ' + last.to;
|
|
1224
|
-
if (state.switchHistory.length > 1) histMsg += ' (+' + (state.switchHistory.length - 1) + ' more)';
|
|
1225
|
-
showToast(histMsg, 'info');
|
|
1226
|
-
} else {
|
|
1227
|
-
showToast('No switch history yet', 'info');
|
|
1228
|
-
}
|
|
1229
|
-
break;
|
|
1230
|
-
case 'u':
|
|
1231
|
-
e.preventDefault();
|
|
1232
|
-
sendAction('undo');
|
|
1233
|
-
showToast('Undoing last switch...', 'info');
|
|
1234
|
-
break;
|
|
1235
|
-
case 's':
|
|
1236
|
-
e.preventDefault();
|
|
1237
|
-
sendAction('toggleSound');
|
|
1238
|
-
showToast(state && state.soundEnabled ? 'Sound off' : 'Sound on', 'info');
|
|
1239
|
-
break;
|
|
1240
|
-
case 'b':
|
|
1241
|
-
e.preventDefault();
|
|
1242
|
-
showBranchActions();
|
|
1243
|
-
break;
|
|
1244
|
-
case 'i':
|
|
1245
|
-
e.preventDefault();
|
|
1246
|
-
showInfo();
|
|
1247
|
-
break;
|
|
1248
|
-
case 'l':
|
|
1249
|
-
e.preventDefault();
|
|
1250
|
-
showLogViewer();
|
|
1251
|
-
break;
|
|
1252
|
-
case 'S':
|
|
1253
|
-
e.preventDefault();
|
|
1254
|
-
showStashDialog(null);
|
|
1255
|
-
break;
|
|
1256
|
-
case 'd':
|
|
1257
|
-
e.preventDefault();
|
|
1258
|
-
showCleanup();
|
|
1259
|
-
break;
|
|
1260
|
-
case 'Escape':
|
|
1261
|
-
e.preventDefault();
|
|
1262
|
-
break;
|
|
1235
|
+
// Normal mode — look up action from key map
|
|
1236
|
+
const action = KEY_MAP[e.key];
|
|
1237
|
+
if (action && KEY_ACTIONS[action]) {
|
|
1238
|
+
e.preventDefault();
|
|
1239
|
+
KEY_ACTIONS[action](e);
|
|
1263
1240
|
}
|
|
1264
1241
|
});
|
|
1265
1242
|
|