dsh-remote-vs 0.19.1 → 0.20.1
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/README.en.md +5 -5
- package/README.md +5 -5
- package/lib/client.js +784 -103
- package/lib/index.js +234 -36
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/vsc/editor-keymap.d.ts +45 -0
- package/lib/types/client/vsc/file-icons.d.ts +83 -0
- package/lib/types/client/vsc/kit.d.ts +25 -5
- package/lib/types/preset-switch.d.ts +89 -0
- package/lib/{worlds-Be1YE2Ot.js → worlds-DSzyajOB.js} +1 -1
- package/package.json +1 -1
- package/src/client/CodeEditor.tsx +24 -62
- package/src/client/RemoteExplorer.tsx +10 -6
- package/src/client/i18n.ts +6 -6
- package/src/client/index.tsx +5 -3
- package/src/client/vsc/editor-keymap.ts +97 -0
- package/src/client/vsc/file-icons.tsx +379 -0
- package/src/client/vsc/kit.tsx +35 -5
- package/src/index.ts +115 -52
- package/src/preset-switch.ts +143 -0
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as keysDir, S as ensurePrivateDir, _ as clampExecTimeout, a as probe, b as aliasRoot, c as RemoteFiles, d as DEFAULT_GIT_TIMEOUT_MS, f as DEFAULT_READ_TIMEOUT_MS, g as MIN_TIMEOUT_MS, h as MAX_TIMEOUT_MS, i as helperAvailability, l as WriteConflictError, m as DeadlineError, n as TombstonedError, o as pushPipeline, p as DEFAULT_TIMEOUTS, s as seedHelperCache, t as RemoteWorlds, u as attachmentHeader, v as resolveTimeouts, w as storePath, x as dshHome, y as require_lib } from "./worlds-DSzyajOB.js";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, statSync, writeSync } from "node:fs";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -4661,6 +4661,130 @@ function makeRoutes(deps) {
|
|
|
4661
4661
|
};
|
|
4662
4662
|
}
|
|
4663
4663
|
//#endregion
|
|
4664
|
+
//#region src/preset-switch.ts
|
|
4665
|
+
/**
|
|
4666
|
+
* Auto-switch decision for a new session born in a remote workspace.
|
|
4667
|
+
*
|
|
4668
|
+
* Why this module is pure
|
|
4669
|
+
* -----------------------
|
|
4670
|
+
* The 2026-11-10 bug was "sometimes no preset switch about 3 s after creating a
|
|
4671
|
+
* session". Two independent causes had to be found by reading the Host:
|
|
4672
|
+
*
|
|
4673
|
+
* 1. **The switch only listened to `source === 'startup'`.** The Web client does
|
|
4674
|
+
* not always mint a session: `session.create` accepts a named BLANK session
|
|
4675
|
+
* and reuses it (`createInWorkspace` passes the first listed blank id), which
|
|
4676
|
+
* the Host answers through `agents.resume` → `agent/created` with source
|
|
4677
|
+
* `'resume'`. Those sessions never even armed the timer.
|
|
4678
|
+
* 2. **A single 2.5 s shot lost every transient state.** At fire time the preset
|
|
4679
|
+
* may not be composed yet, the working directory may be unreadable, or the
|
|
4680
|
+
* workspace binding may not be listed; each guard returned silently, and the
|
|
4681
|
+
* one chance was spent.
|
|
4682
|
+
*
|
|
4683
|
+
* The fix keeps the "never block session creation" contract and turns the
|
|
4684
|
+
* decision into a pure function plus a bounded retry loop, so every branch is
|
|
4685
|
+
* covered by a gate instead of being inferred from a silent return.
|
|
4686
|
+
*
|
|
4687
|
+
* Blankness — no turn started — is the real precondition (`presets.select`
|
|
4688
|
+
* enforces exactly that), and it is also what excludes resumed sessions with
|
|
4689
|
+
* history. The event source only told us how the session came to be.
|
|
4690
|
+
*/
|
|
4691
|
+
/** Preset id this plugin switches remote sessions to (see `cordis.patch.yml`). */
|
|
4692
|
+
const REMOTE_PRESET_ID = "remote";
|
|
4693
|
+
/** Delay before each attempt, in order. The first attempt keeps the old 2.5 s. */
|
|
4694
|
+
const PRESET_SWITCH_DELAYS_MS = [
|
|
4695
|
+
2500,
|
|
4696
|
+
1e3,
|
|
4697
|
+
1500,
|
|
4698
|
+
2e3,
|
|
4699
|
+
3e3
|
|
4700
|
+
];
|
|
4701
|
+
/**
|
|
4702
|
+
* Decide one attempt.
|
|
4703
|
+
*
|
|
4704
|
+
* Order matters: the terminal reasons come first (config, history, user choice),
|
|
4705
|
+
* then the transient ones (composed preset, cwd, route), then the switch.
|
|
4706
|
+
*/
|
|
4707
|
+
function decidePresetSwitch(facts) {
|
|
4708
|
+
if (facts.mode !== "enforce") return {
|
|
4709
|
+
action: "stop",
|
|
4710
|
+
reason: "routing-off"
|
|
4711
|
+
};
|
|
4712
|
+
if (!facts.hasPresets) return {
|
|
4713
|
+
action: "stop",
|
|
4714
|
+
reason: "presets-absent"
|
|
4715
|
+
};
|
|
4716
|
+
if (!facts.blank) return {
|
|
4717
|
+
action: "stop",
|
|
4718
|
+
reason: "not-blank"
|
|
4719
|
+
};
|
|
4720
|
+
if (facts.currentPreset === "remote") return {
|
|
4721
|
+
action: "stop",
|
|
4722
|
+
reason: "already-remote"
|
|
4723
|
+
};
|
|
4724
|
+
if (facts.currentPreset === void 0) return {
|
|
4725
|
+
action: "retry",
|
|
4726
|
+
reason: "preset-unbound"
|
|
4727
|
+
};
|
|
4728
|
+
if (facts.currentPreset !== facts.defaultPreset) return {
|
|
4729
|
+
action: "stop",
|
|
4730
|
+
reason: "custom-preset"
|
|
4731
|
+
};
|
|
4732
|
+
if (facts.cwd.trim() === "") return {
|
|
4733
|
+
action: "retry",
|
|
4734
|
+
reason: "cwd-unavailable"
|
|
4735
|
+
};
|
|
4736
|
+
if (facts.tombstoned) return {
|
|
4737
|
+
action: "stop",
|
|
4738
|
+
reason: "tombstoned"
|
|
4739
|
+
};
|
|
4740
|
+
if (facts.remote === void 0) return {
|
|
4741
|
+
action: "retry",
|
|
4742
|
+
reason: "route-unknown"
|
|
4743
|
+
};
|
|
4744
|
+
if (!facts.remote) return {
|
|
4745
|
+
action: "stop",
|
|
4746
|
+
reason: "local-session"
|
|
4747
|
+
};
|
|
4748
|
+
return { action: "switch" };
|
|
4749
|
+
}
|
|
4750
|
+
/** Wait for `ms`, unref'd so a pending switch never keeps the Host alive. */
|
|
4751
|
+
function defaultSleep(ms) {
|
|
4752
|
+
return new Promise((resolve) => {
|
|
4753
|
+
setTimeout(resolve, ms).unref?.();
|
|
4754
|
+
});
|
|
4755
|
+
}
|
|
4756
|
+
/**
|
|
4757
|
+
* Run attempts with the given delays until one stops or switches.
|
|
4758
|
+
*
|
|
4759
|
+
* A retry is only worth spending for the transient reasons the planner names;
|
|
4760
|
+
* the loop itself does not re-classify, so a future terminal reason added to the
|
|
4761
|
+
* planner stays terminal automatically.
|
|
4762
|
+
*
|
|
4763
|
+
* @returns the last attempt and how many attempts were used (1-based).
|
|
4764
|
+
*/
|
|
4765
|
+
async function runPresetSwitchAttempts(attempt, sleep = defaultSleep, delays = PRESET_SWITCH_DELAYS_MS) {
|
|
4766
|
+
let last;
|
|
4767
|
+
let attempts = 0;
|
|
4768
|
+
for (const delay of delays) {
|
|
4769
|
+
attempts += 1;
|
|
4770
|
+
await sleep(delay);
|
|
4771
|
+
last = await attempt();
|
|
4772
|
+
if (last.step.action !== "retry") return {
|
|
4773
|
+
step: last.step,
|
|
4774
|
+
facts: last.facts,
|
|
4775
|
+
attempts
|
|
4776
|
+
};
|
|
4777
|
+
}
|
|
4778
|
+
return {
|
|
4779
|
+
step: last === void 0 ? {
|
|
4780
|
+
action: "stop",
|
|
4781
|
+
reason: "services-absent"
|
|
4782
|
+
} : last.step,
|
|
4783
|
+
facts: last?.facts,
|
|
4784
|
+
attempts
|
|
4785
|
+
};
|
|
4786
|
+
}
|
|
4787
|
+
//#endregion
|
|
4664
4788
|
//#region src/changes/status.ts
|
|
4665
4789
|
/** Exit statuses of the read commands (git's own statuses pass through as-is). */
|
|
4666
4790
|
const READ_EXIT = {
|
|
@@ -6817,43 +6941,117 @@ function apply(ctx, config) {
|
|
|
6817
6941
|
ctx.on("loader/volatile-update", () => {
|
|
6818
6942
|
sync();
|
|
6819
6943
|
});
|
|
6944
|
+
/**
|
|
6945
|
+
* Preset auto-switch for a new session born in a remote workspace (Phase 4b).
|
|
6946
|
+
*
|
|
6947
|
+
* 2026-11-10, bug "sometimes no Remote preset ~3 s after creating a session":
|
|
6948
|
+
*
|
|
6949
|
+
* - The Web client does not always MINT a session. `createInWorkspace` reuses
|
|
6950
|
+
* the first listed BLANK session of the workspace by passing its id, and the
|
|
6951
|
+
* Host answers that through `agents.resume` → `agent/created` with source
|
|
6952
|
+
* `'resume'`. The old `source !== 'startup'` guard silently skipped exactly
|
|
6953
|
+
* those sessions. Blankness (no turn started) is the precondition the preset
|
|
6954
|
+
* registry itself enforces, so it is what we check now — a resumed session
|
|
6955
|
+
* with history is excluded by it.
|
|
6956
|
+
* - One 2.5 s shot also lost every transient state: the preset may not be
|
|
6957
|
+
* composed yet, the working directory may be unreadable, or the workspace
|
|
6958
|
+
* binding may not be listed. `runPresetSwitchAttempts` retries those for a
|
|
6959
|
+
* bounded time and stops on terminal reasons (routing off, history, user's
|
|
6960
|
+
* own preset, local directory).
|
|
6961
|
+
*
|
|
6962
|
+
* The listener still DETACHES: it returns immediately, so session creation
|
|
6963
|
+
* never waits for a switch (the original 2026-10-13 race: selecting during
|
|
6964
|
+
* creation while both preset trees register tools could kill the session).
|
|
6965
|
+
* Failure modes are logged, never thrown; manual selection stays the fallback.
|
|
6966
|
+
*/
|
|
6967
|
+
const attemptPresetSwitch = async (agent) => {
|
|
6968
|
+
const presets = ctx.get("agentPresets");
|
|
6969
|
+
const agents = ctx.get("agents");
|
|
6970
|
+
const workingDirectory = ctx.get("workingDirectory");
|
|
6971
|
+
let boundary;
|
|
6972
|
+
try {
|
|
6973
|
+
boundary = agents?.turnBoundaryOf?.(agent.session);
|
|
6974
|
+
} catch {
|
|
6975
|
+
boundary = void 0;
|
|
6976
|
+
}
|
|
6977
|
+
let cwd = "";
|
|
6978
|
+
try {
|
|
6979
|
+
const current = workingDirectory?.get?.(agent.session);
|
|
6980
|
+
if (typeof current === "string") cwd = current;
|
|
6981
|
+
} catch {}
|
|
6982
|
+
let remote;
|
|
6983
|
+
let tombstoned = false;
|
|
6984
|
+
if (cwd !== "") try {
|
|
6985
|
+
remote = worlds.routeDir(cwd).kind === "remote";
|
|
6986
|
+
} catch (error) {
|
|
6987
|
+
if (error instanceof TombstonedError) tombstoned = true;
|
|
6988
|
+
}
|
|
6989
|
+
let currentPreset;
|
|
6990
|
+
let defaultPreset;
|
|
6991
|
+
try {
|
|
6992
|
+
currentPreset = presets?.composedPreset(agent.ctx);
|
|
6993
|
+
defaultPreset = presets?.defaultId;
|
|
6994
|
+
} catch {
|
|
6995
|
+
currentPreset = void 0;
|
|
6996
|
+
defaultPreset = void 0;
|
|
6997
|
+
}
|
|
6998
|
+
const facts = {
|
|
6999
|
+
mode: worlds.mode,
|
|
7000
|
+
hasPresets: presets !== void 0,
|
|
7001
|
+
blank: boundary !== void 0 && boundary.openTurnStartSeq === null && boundary.lastTurn === 0,
|
|
7002
|
+
cwd,
|
|
7003
|
+
remote,
|
|
7004
|
+
tombstoned,
|
|
7005
|
+
currentPreset,
|
|
7006
|
+
defaultPreset
|
|
7007
|
+
};
|
|
7008
|
+
const step = decidePresetSwitch(facts);
|
|
7009
|
+
if (step.action !== "switch") return {
|
|
7010
|
+
step,
|
|
7011
|
+
facts
|
|
7012
|
+
};
|
|
7013
|
+
if (presets === void 0) return {
|
|
7014
|
+
step: {
|
|
7015
|
+
action: "stop",
|
|
7016
|
+
reason: "presets-absent"
|
|
7017
|
+
},
|
|
7018
|
+
facts
|
|
7019
|
+
};
|
|
7020
|
+
try {
|
|
7021
|
+
await presets.select(agent, REMOTE_PRESET_ID);
|
|
7022
|
+
return {
|
|
7023
|
+
step: {
|
|
7024
|
+
action: "stop",
|
|
7025
|
+
reason: "switched"
|
|
7026
|
+
},
|
|
7027
|
+
facts
|
|
7028
|
+
};
|
|
7029
|
+
} catch (error) {
|
|
7030
|
+
const locked = error instanceof Error && /locked|already started/i.test(error.message);
|
|
7031
|
+
return {
|
|
7032
|
+
step: {
|
|
7033
|
+
action: locked ? "stop" : "retry",
|
|
7034
|
+
reason: locked ? "locked" : "select-failed"
|
|
7035
|
+
},
|
|
7036
|
+
facts
|
|
7037
|
+
};
|
|
7038
|
+
}
|
|
7039
|
+
};
|
|
6820
7040
|
ctx.on("agent/created", (payload) => {
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
7041
|
+
(async () => {
|
|
7042
|
+
try {
|
|
7043
|
+
const { step, facts, attempts } = await runPresetSwitchAttempts(() => attemptPresetSwitch(payload.agent));
|
|
6824
7044
|
try {
|
|
6825
|
-
|
|
6826
|
-
if (
|
|
6827
|
-
if (
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
} catch {
|
|
6836
|
-
return;
|
|
6837
|
-
}
|
|
6838
|
-
let remote = false;
|
|
6839
|
-
try {
|
|
6840
|
-
remote = worlds.routeDir(cwd).kind === "remote";
|
|
6841
|
-
} catch {
|
|
6842
|
-
return;
|
|
6843
|
-
}
|
|
6844
|
-
if (!remote) return;
|
|
6845
|
-
await presets.select(payload.agent, "remote");
|
|
6846
|
-
try {
|
|
6847
|
-
ctx.logger.info(`[remote-vs] new remote session entered ${cwd}; preset switched to remote`);
|
|
6848
|
-
} catch {}
|
|
6849
|
-
} catch (error) {
|
|
6850
|
-
if (error instanceof Error && /locked|already started/i.test(error.message)) return;
|
|
6851
|
-
try {
|
|
6852
|
-
ctx.logger.warn(`[remote-vs] preset auto-switch skipped: ${error instanceof Error ? error.message : String(error)}`);
|
|
6853
|
-
} catch {}
|
|
6854
|
-
}
|
|
6855
|
-
})();
|
|
6856
|
-
}, 2500).unref?.();
|
|
7045
|
+
if (step.reason === "switched" && facts?.remote === true) ctx.logger.info(`[remote-vs] remote session ${facts.cwd}: preset switched to ${REMOTE_PRESET_ID} after ${attempts} attempt(s)`);
|
|
7046
|
+
else if (step.action === "retry") ctx.logger.warn(`[remote-vs] preset auto-switch gave up after ${attempts} attempt(s): ${step.reason}`);
|
|
7047
|
+
else if (facts?.remote === true) ctx.logger.info(`[remote-vs] preset auto-switch skipped for ${facts.cwd}: ${step.reason}`);
|
|
7048
|
+
} catch {}
|
|
7049
|
+
} catch (error) {
|
|
7050
|
+
try {
|
|
7051
|
+
ctx.logger.warn(`[remote-vs] preset auto-switch skipped: ${error instanceof Error ? error.message : String(error)}`);
|
|
7052
|
+
} catch {}
|
|
7053
|
+
}
|
|
7054
|
+
})();
|
|
6857
7055
|
});
|
|
6858
7056
|
sync();
|
|
6859
7057
|
}
|
package/lib/p2-router-fs.js
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor's key bindings, in one testable place.
|
|
3
|
+
*
|
|
4
|
+
* Why this module exists
|
|
5
|
+
* ----------------------
|
|
6
|
+
* Bug (2026-11-10, user report): "the remote editor cannot input Tab".
|
|
7
|
+
*
|
|
8
|
+
* CodeMirror 6's `defaultKeymap` deliberately does NOT bind Tab — the browser
|
|
9
|
+
* default (move focus) stays available for accessibility. Indentation is the
|
|
10
|
+
* opt-in `indentWithTab` binding, and this plugin never added it, so Tab fell
|
|
11
|
+
* through to the browser: the caret left the editor instead of indenting. The
|
|
12
|
+
* local sidebar editor binds it, which is why the same key worked there.
|
|
13
|
+
*
|
|
14
|
+
* The binding list used to live inline inside the CodeMirror mount effect, which
|
|
15
|
+
* meant the only way to test it was to render the whole component. It lives here
|
|
16
|
+
* so `scripts/check-editor-tab.mjs` can mount a real CodeMirror with the REAL
|
|
17
|
+
* binding list and dispatch real Tab/Shift-Tab presses.
|
|
18
|
+
*
|
|
19
|
+
* Handlers are injected (no React, no editor state): the component wires them to
|
|
20
|
+
* its refs/stores.
|
|
21
|
+
*/
|
|
22
|
+
import type { EditorView, KeyBinding } from '@codemirror/view';
|
|
23
|
+
/** The editor actions the key bindings dispatch into. */
|
|
24
|
+
export interface EditorKeyHandlers {
|
|
25
|
+
/** Ctrl/Cmd+S → the pane's save path. */
|
|
26
|
+
save(): void;
|
|
27
|
+
/** Ctrl/Cmd+F → seed our find widget from the selection and open it. */
|
|
28
|
+
openFindForSelection(view: EditorView): void;
|
|
29
|
+
/** F3 / Shift+F3 → step through matches. */
|
|
30
|
+
stepFind(view: EditorView, forward: boolean): void;
|
|
31
|
+
/** Jump to the previous/next change hunk; false when the panel is closed. */
|
|
32
|
+
stepHunk(delta: 1 | -1): boolean;
|
|
33
|
+
/** Escape → close the find widget; false when it was not open. */
|
|
34
|
+
closeFind(): boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Build the editor keymap.
|
|
38
|
+
*
|
|
39
|
+
* Order: the stock keymaps first, then the two additions that make this editor
|
|
40
|
+
* behave like VS Code — `indentWithTab` (Tab / Shift-Tab indent or dedent) and
|
|
41
|
+
* our own shortcuts. `indentWithTab` is deliberately NOT part of CodeMirror's
|
|
42
|
+
* defaults, which is exactly what shipped the "Tab does nothing" bug; a red
|
|
43
|
+
* proof in the gate removes it again.
|
|
44
|
+
*/
|
|
45
|
+
export declare function editorKeymap(handlers: EditorKeyHandlers): KeyBinding[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coloured file-type / folder icons for the remote DIRECTORY TREE
|
|
3
|
+
* (`RemoteExplorer`), so a remote folder looks like the local sidebar's folder.
|
|
4
|
+
*
|
|
5
|
+
* Scope: the tree only. Search hits, SCM rows, commit panes and download rows
|
|
6
|
+
* keep the neutral outline glyphs from `kit.tsx` — this set is deliberately not
|
|
7
|
+
* the fallback of `FileIcon` / `FolderIcon`.
|
|
8
|
+
*
|
|
9
|
+
* Provenance
|
|
10
|
+
* ----------
|
|
11
|
+
* These are a straight port of the icon set the local sidebar plugin draws
|
|
12
|
+
* (`FileTypeIcon` and its amber folder icon): one paper sheet whose colour and
|
|
13
|
+
* bottom-right mark carry the type — TS blue + `<>`, JS yellow + `<>`, Python
|
|
14
|
+
* blue with a yellow mark, Markdown blue + lines, images purple + a mountain,
|
|
15
|
+
* archives yellow + a zip, `.gitignore` orange + a commit graph.
|
|
16
|
+
*
|
|
17
|
+
* The copy exists on purpose: the client bundle may not import another plugin's
|
|
18
|
+
* values (tsdown's purity gate rejects cross-plugin imports), and that plugin
|
|
19
|
+
* publishes no `fileIcon` / `folderIcon` service that `kit.tsx` could call.
|
|
20
|
+
* `kit.tsx` still prefers such a service if a host ever provides one (the
|
|
21
|
+
* better-sidebar contract is where it would come from); this set is the
|
|
22
|
+
* fallback that paints a real, typed tree whenever that plugin is present.
|
|
23
|
+
*
|
|
24
|
+
* One deliberate difference from the source: the image mark used
|
|
25
|
+
* `fill="currentColor"`, which in a tree inherits the row's dim text colour —
|
|
26
|
+
* `.rvs-node-icon` sets `color: var(--rvs-fg3)` — so the mountain would render
|
|
27
|
+
* grey on the purple sheet. Here the mark group pins `color` to the type colour
|
|
28
|
+
* and the artwork stays the colour the palette intends.
|
|
29
|
+
*/
|
|
30
|
+
import type { ReactNode } from 'react';
|
|
31
|
+
/** The bottom-right mark that carries the category (drawn in the type colour). */
|
|
32
|
+
type FileMark = 'code' | 'markup' | 'style' | 'data' | 'doc' | 'image' | 'archive' | 'shell' | 'config' | 'git' | 'lock' | 'box' | 'table';
|
|
33
|
+
/** How one file type looks: sheet colour + category mark + optional mark colour. */
|
|
34
|
+
export interface FileLook {
|
|
35
|
+
color: string;
|
|
36
|
+
mark: FileMark;
|
|
37
|
+
/** Mark colour; defaults to the sheet colour (Python = blue sheet + yellow mark). */
|
|
38
|
+
markColor?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The extension / exact-name tables, exposed read-only for the gate's full-table
|
|
42
|
+
* snapshot: one changed hex or mark must turn `scripts/check-file-icons.mjs`
|
|
43
|
+
* red, instead of shipping a silently different palette.
|
|
44
|
+
*
|
|
45
|
+
* `baseName` stays private on purpose — `kit.tsx` already exports a `baseName`
|
|
46
|
+
* with different semantics (POSIX only, strips a trailing slash), and exporting
|
|
47
|
+
* both invites the wrong import.
|
|
48
|
+
*/
|
|
49
|
+
export declare const FILE_TYPE_LOOKS: Readonly<Record<string, FileLook>>;
|
|
50
|
+
export declare const FILE_NAME_LOOKS: Readonly<Record<string, FileLook>>;
|
|
51
|
+
/** Resolve a path's look from its name / extension. */
|
|
52
|
+
export declare function lookOf(path: string): FileLook;
|
|
53
|
+
/** Props for {@link FileTypeIcon} / {@link FolderGlyph}. */
|
|
54
|
+
export interface FileIconProps {
|
|
55
|
+
/** Workspace-relative path (any separator); only the basename is read. */
|
|
56
|
+
path: string;
|
|
57
|
+
/** Edge length in px, default 16. */
|
|
58
|
+
size?: number;
|
|
59
|
+
className?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Coloured file-type icon: sheet + top-right fold + bottom-right category mark.
|
|
63
|
+
*
|
|
64
|
+
* At 16 px this reads better than two-letter badges and does not depend on font
|
|
65
|
+
* rendering.
|
|
66
|
+
*/
|
|
67
|
+
export declare function FileTypeIcon(props: FileIconProps): ReactNode;
|
|
68
|
+
/** Every extension the file-type icon recognises (reporting / gate). */
|
|
69
|
+
export declare const FILE_TYPE_EXTENSIONS: readonly string[];
|
|
70
|
+
/** Props for the amber folder glyph. */
|
|
71
|
+
export interface FolderGlyphProps {
|
|
72
|
+
/** Expanded: the front flap drops down and reveals the inner sheet (VSCode-like). */
|
|
73
|
+
open?: boolean;
|
|
74
|
+
/** Edge length in px, default 16. */
|
|
75
|
+
size?: number;
|
|
76
|
+
className?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Amber folder icon. The folder colour is content colour, in the same scheme as
|
|
80
|
+
* the file types — it does not follow the skin.
|
|
81
|
+
*/
|
|
82
|
+
export declare function FolderGlyph(props: FolderGlyphProps): ReactNode;
|
|
83
|
+
export {};
|
|
@@ -5,11 +5,18 @@
|
|
|
5
5
|
* ships the same split, and the confirm dialogs are what guard destructive
|
|
6
6
|
* remote git verbs).
|
|
7
7
|
*
|
|
8
|
-
* Icon sourcing
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* Icon sourcing has two tiers. `FileIcon` / `FolderIcon` paint the plain glyphs
|
|
9
|
+
* below (search hits, SCM rows, commit panes, download rows — list chrome where
|
|
10
|
+
* one neutral outline reads best). `ExplorerFileIcon` / `ExplorerFolderIcon`
|
|
11
|
+
* paint the COLOURED type set ported from the local sidebar plugin in
|
|
12
|
+
* `./file-icons.tsx`, so the remote directory tree looks like the local
|
|
13
|
+
* sidebar's tree: one sheet whose colour and mark carry the file type, and an
|
|
14
|
+
* amber folder that opens.
|
|
15
|
+
*
|
|
16
|
+
* Every tier still prefers the host service when one is published (the
|
|
17
|
+
* better-sidebar contract's `fileIcon` / `folderIcon`: host classifier plus any
|
|
18
|
+
* registered icon theme). That plugin publishes none today, so with the local
|
|
19
|
+
* sidebar installed the SVG sets above are what actually render.
|
|
13
20
|
*/
|
|
14
21
|
import { type ReactNode } from 'react';
|
|
15
22
|
type IconProps = {
|
|
@@ -101,6 +108,19 @@ export declare function FolderIcon(props: {
|
|
|
101
108
|
size?: number;
|
|
102
109
|
className?: string;
|
|
103
110
|
}): ReactNode;
|
|
111
|
+
/** Explorer file row: host glyph when available, else the coloured type icon. */
|
|
112
|
+
export declare function ExplorerFileIcon(props: {
|
|
113
|
+
path: string;
|
|
114
|
+
size?: number;
|
|
115
|
+
className?: string;
|
|
116
|
+
}): ReactNode;
|
|
117
|
+
/** Explorer directory row: host glyph when available, else the amber folder. */
|
|
118
|
+
export declare function ExplorerFolderIcon(props: {
|
|
119
|
+
path: string;
|
|
120
|
+
open: boolean;
|
|
121
|
+
size?: number;
|
|
122
|
+
className?: string;
|
|
123
|
+
}): ReactNode;
|
|
104
124
|
export declare function isImageFile(path: string): boolean;
|
|
105
125
|
export declare function isMarkdownFile(path: string): boolean;
|
|
106
126
|
export declare function isHtmlFile(path: string): boolean;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-switch decision for a new session born in a remote workspace.
|
|
3
|
+
*
|
|
4
|
+
* Why this module is pure
|
|
5
|
+
* -----------------------
|
|
6
|
+
* The 2026-11-10 bug was "sometimes no preset switch about 3 s after creating a
|
|
7
|
+
* session". Two independent causes had to be found by reading the Host:
|
|
8
|
+
*
|
|
9
|
+
* 1. **The switch only listened to `source === 'startup'`.** The Web client does
|
|
10
|
+
* not always mint a session: `session.create` accepts a named BLANK session
|
|
11
|
+
* and reuses it (`createInWorkspace` passes the first listed blank id), which
|
|
12
|
+
* the Host answers through `agents.resume` → `agent/created` with source
|
|
13
|
+
* `'resume'`. Those sessions never even armed the timer.
|
|
14
|
+
* 2. **A single 2.5 s shot lost every transient state.** At fire time the preset
|
|
15
|
+
* may not be composed yet, the working directory may be unreadable, or the
|
|
16
|
+
* workspace binding may not be listed; each guard returned silently, and the
|
|
17
|
+
* one chance was spent.
|
|
18
|
+
*
|
|
19
|
+
* The fix keeps the "never block session creation" contract and turns the
|
|
20
|
+
* decision into a pure function plus a bounded retry loop, so every branch is
|
|
21
|
+
* covered by a gate instead of being inferred from a silent return.
|
|
22
|
+
*
|
|
23
|
+
* Blankness — no turn started — is the real precondition (`presets.select`
|
|
24
|
+
* enforces exactly that), and it is also what excludes resumed sessions with
|
|
25
|
+
* history. The event source only told us how the session came to be.
|
|
26
|
+
*/
|
|
27
|
+
/** Preset id this plugin switches remote sessions to (see `cordis.patch.yml`). */
|
|
28
|
+
export declare const REMOTE_PRESET_ID = "remote";
|
|
29
|
+
/** Delay before each attempt, in order. The first attempt keeps the old 2.5 s. */
|
|
30
|
+
export declare const PRESET_SWITCH_DELAYS_MS: readonly number[];
|
|
31
|
+
/** Why one attempt ended the way it did (logged, never thrown). */
|
|
32
|
+
export type PresetSwitchReason = 'switched' | 'already-remote' | 'custom-preset' | 'routing-off' | 'presets-absent' | 'services-absent' | 'not-blank' | 'preset-unbound' | 'cwd-unavailable' | 'route-unknown' | 'tombstoned' | 'local-session' | 'locked' | 'select-failed';
|
|
33
|
+
/** One attempt's outcome: switch now, try again later, or stop for good. */
|
|
34
|
+
export type PresetSwitchStep = {
|
|
35
|
+
action: 'switch';
|
|
36
|
+
} | {
|
|
37
|
+
action: 'retry';
|
|
38
|
+
reason: PresetSwitchReason;
|
|
39
|
+
} | {
|
|
40
|
+
action: 'stop';
|
|
41
|
+
reason: PresetSwitchReason;
|
|
42
|
+
};
|
|
43
|
+
/** A settled attempt (`switch` is reported as `stop/switched`). */
|
|
44
|
+
export type PresetSwitchSettled = Exclude<PresetSwitchStep, {
|
|
45
|
+
action: 'switch';
|
|
46
|
+
}>;
|
|
47
|
+
/** Everything the decision reads, resolved by the caller (no services here). */
|
|
48
|
+
export interface PresetSwitchFacts {
|
|
49
|
+
/** Routing mode from the plugin config: only `enforce` auto-switches. */
|
|
50
|
+
mode: string;
|
|
51
|
+
/** The preset registry service is mounted at all. */
|
|
52
|
+
hasPresets: boolean;
|
|
53
|
+
/** No turn has started yet (`turnBoundaryOf`): openTurnStartSeq null, lastTurn 0. */
|
|
54
|
+
blank: boolean;
|
|
55
|
+
/** The step also runs for local sessions; the caller decides what to log. */
|
|
56
|
+
cwd: string;
|
|
57
|
+
/** `undefined` when the route lookup threw (retried); false means local. */
|
|
58
|
+
remote: boolean | undefined;
|
|
59
|
+
/** The directory belongs to a retired binding: dead session, never switch. */
|
|
60
|
+
tombstoned: boolean;
|
|
61
|
+
currentPreset: string | undefined;
|
|
62
|
+
defaultPreset: string | undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Decide one attempt.
|
|
66
|
+
*
|
|
67
|
+
* Order matters: the terminal reasons come first (config, history, user choice),
|
|
68
|
+
* then the transient ones (composed preset, cwd, route), then the switch.
|
|
69
|
+
*/
|
|
70
|
+
export declare function decidePresetSwitch(facts: PresetSwitchFacts): PresetSwitchStep;
|
|
71
|
+
/** One attempt as the caller sees it: the step plus the facts it was made from. */
|
|
72
|
+
export interface PresetSwitchAttempt {
|
|
73
|
+
step: PresetSwitchSettled;
|
|
74
|
+
facts: PresetSwitchFacts;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Run attempts with the given delays until one stops or switches.
|
|
78
|
+
*
|
|
79
|
+
* A retry is only worth spending for the transient reasons the planner names;
|
|
80
|
+
* the loop itself does not re-classify, so a future terminal reason added to the
|
|
81
|
+
* planner stays terminal automatically.
|
|
82
|
+
*
|
|
83
|
+
* @returns the last attempt and how many attempts were used (1-based).
|
|
84
|
+
*/
|
|
85
|
+
export declare function runPresetSwitchAttempts(attempt: () => Promise<PresetSwitchAttempt> | PresetSwitchAttempt, sleep?: (ms: number) => Promise<void>, delays?: readonly number[]): Promise<{
|
|
86
|
+
step: PresetSwitchSettled;
|
|
87
|
+
facts: PresetSwitchFacts | undefined;
|
|
88
|
+
attempts: number;
|
|
89
|
+
}>;
|
|
@@ -19963,4 +19963,4 @@ var RemoteWorlds = class {
|
|
|
19963
19963
|
}
|
|
19964
19964
|
};
|
|
19965
19965
|
//#endregion
|
|
19966
|
-
export {
|
|
19966
|
+
export { keysDir as C, ensurePrivateDir as S, clampExecTimeout as _, probe as a, aliasRoot as b, RemoteFiles as c, DEFAULT_GIT_TIMEOUT_MS as d, DEFAULT_READ_TIMEOUT_MS as f, MIN_TIMEOUT_MS as g, MAX_TIMEOUT_MS as h, helperAvailability as i, WriteConflictError as l, DeadlineError as m, TombstonedError as n, pushPipeline as o, DEFAULT_TIMEOUTS as p, isWindowsAbsolute as r, seedHelperCache as s, RemoteWorlds as t, attachmentHeader as u, resolveTimeouts as v, storePath as w, dshHome as x, require_lib as y };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote-vs",
|
|
3
3
|
"description": "VSCode-style remote development for DSH: SSH host manager (key/password), helper deploy pipeline with version check, remote file explorer + editor + terminal in dsh-better-sidebar.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.1",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"dsh",
|