ohbaby-cli 0.1.2 → 0.1.3
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/bin.js +32 -5
- package/dist/bin.js.map +1 -1
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/tui/app.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -69,8 +69,8 @@ function createRunCommand(runtime) {
|
|
|
69
69
|
// src/cli/commands/serve.ts
|
|
70
70
|
function normalizePort(port, runtime) {
|
|
71
71
|
const value = port ?? 4096;
|
|
72
|
-
if (!Number.isInteger(value) || value
|
|
73
|
-
runtime.failUsage("--port must be a TCP port between
|
|
72
|
+
if (!Number.isInteger(value) || value < 0 || value > 65535) {
|
|
73
|
+
runtime.failUsage("--port must be a TCP port between 0 and 65535");
|
|
74
74
|
}
|
|
75
75
|
return value;
|
|
76
76
|
}
|
|
@@ -4900,6 +4900,7 @@ function OhbabyTerminalApp({
|
|
|
4900
4900
|
const catalogRequestSequenceRef = useRef(0);
|
|
4901
4901
|
const contextRefreshSequenceRef = useRef(0);
|
|
4902
4902
|
const contextNoticeSequenceRef = useRef(0);
|
|
4903
|
+
const snapshotRefreshSequenceRef = useRef(0);
|
|
4903
4904
|
const didClearOnStartRef = useRef(false);
|
|
4904
4905
|
const disposedRef = useRef(false);
|
|
4905
4906
|
const [screenGeneration, setScreenGeneration] = useState(0);
|
|
@@ -5198,11 +5199,24 @@ function OhbabyTerminalApp({
|
|
|
5198
5199
|
return;
|
|
5199
5200
|
}
|
|
5200
5201
|
eventDispatcher.dispatch(tuiEvent);
|
|
5201
|
-
|
|
5202
|
+
const isNewSessionSelection = isNewSessionSelectionEvent(tuiEvent);
|
|
5203
|
+
if (isNewSessionSelection) {
|
|
5204
|
+
snapshotRefreshSequenceRef.current += 1;
|
|
5202
5205
|
writeStdout(NEW_SESSION_CLEAR_SEQUENCE);
|
|
5203
5206
|
setScreenGeneration((current) => current + 1);
|
|
5204
5207
|
setActiveCommandPanel(null);
|
|
5205
5208
|
}
|
|
5209
|
+
const selectedExistingSessionId = selectedExistingSessionIdFromEvent(tuiEvent);
|
|
5210
|
+
if (selectedExistingSessionId !== void 0) {
|
|
5211
|
+
const requestSequence2 = snapshotRefreshSequenceRef.current + 1;
|
|
5212
|
+
snapshotRefreshSequenceRef.current = requestSequence2;
|
|
5213
|
+
void client.getSnapshot().then((snapshot) => {
|
|
5214
|
+
if (disposedRef.current || requestSequence2 !== snapshotRefreshSequenceRef.current || snapshot.activeSessionId !== selectedExistingSessionId) {
|
|
5215
|
+
return;
|
|
5216
|
+
}
|
|
5217
|
+
store.replaceSnapshot(snapshot);
|
|
5218
|
+
}).catch(() => void 0);
|
|
5219
|
+
}
|
|
5206
5220
|
if (tuiEvent.type === "command.result.delivered" && tuiEvent.action?.kind === "app.exit") {
|
|
5207
5221
|
exit();
|
|
5208
5222
|
}
|
|
@@ -5210,12 +5224,14 @@ function OhbabyTerminalApp({
|
|
|
5210
5224
|
void loadCatalog().catch(() => void 0);
|
|
5211
5225
|
}
|
|
5212
5226
|
});
|
|
5227
|
+
const requestSequence = snapshotRefreshSequenceRef.current + 1;
|
|
5228
|
+
snapshotRefreshSequenceRef.current = requestSequence;
|
|
5213
5229
|
void client.getSnapshot().then((snapshot) => {
|
|
5214
|
-
if (!disposedRef.current) {
|
|
5230
|
+
if (!disposedRef.current && requestSequence === snapshotRefreshSequenceRef.current) {
|
|
5215
5231
|
store.replaceSnapshot(snapshot);
|
|
5216
5232
|
}
|
|
5217
5233
|
}).catch((caught) => {
|
|
5218
|
-
if (!disposedRef.current) {
|
|
5234
|
+
if (!disposedRef.current && requestSequence === snapshotRefreshSequenceRef.current) {
|
|
5219
5235
|
store.dispatch({
|
|
5220
5236
|
status: {
|
|
5221
5237
|
kind: "error",
|
|
@@ -5396,6 +5412,17 @@ function isNewSessionSelectionEvent(tuiEvent) {
|
|
|
5396
5412
|
const data = tuiEvent.action.data;
|
|
5397
5413
|
return isStringRecord(data) && data.source === "new";
|
|
5398
5414
|
}
|
|
5415
|
+
function selectedExistingSessionIdFromEvent(tuiEvent) {
|
|
5416
|
+
if (tuiEvent.type !== "command.result.delivered" || tuiEvent.action?.kind !== "session.selected") {
|
|
5417
|
+
return void 0;
|
|
5418
|
+
}
|
|
5419
|
+
const data = tuiEvent.action.data;
|
|
5420
|
+
if (!isStringRecord(data) || data.source === "new") {
|
|
5421
|
+
return void 0;
|
|
5422
|
+
}
|
|
5423
|
+
const choiceId = data.choiceId;
|
|
5424
|
+
return typeof choiceId === "string" && choiceId.length > 0 ? choiceId : void 0;
|
|
5425
|
+
}
|
|
5399
5426
|
function isStringRecord(value) {
|
|
5400
5427
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5401
5428
|
}
|