dsh-ris-ide 1.8.0 → 1.8.2

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 (52) hide show
  1. package/README.md +5 -3
  2. package/bin/risd.mjs +14 -17
  3. package/lib/client.js +400 -93
  4. package/lib/debug/vendor/README.md +14 -0
  5. package/lib/debug/vendor/jdwp/client.js +9 -4
  6. package/lib/debug/vendor/src/jdwp/client.ts +12 -5
  7. package/lib/index.js +794 -48
  8. package/lib/proxybridge-bundle.js +1 -1
  9. package/lib/proxybridge-health.js +206 -0
  10. package/lib/redirector.js +1181 -90
  11. package/lib/risd/lifecycle.js +9 -3
  12. package/lib/risd/server.js +762 -26
  13. package/lib/risd/ui.js +419 -98
  14. package/lib/risd-client.js +4 -1
  15. package/lib/startup.js +27 -7
  16. package/package.json +2 -2
  17. package/test/client-viewer.test.mjs +299 -120
  18. package/test/clipboard.test.mjs +259 -0
  19. package/test/debug-engine.test.mjs +3 -1
  20. package/test/dsh-origin.test.mjs +4 -11
  21. package/test/dsh-window-refresh.test.mjs +166 -1
  22. package/test/harness.test.mjs +1 -1
  23. package/test/helpers/cmd.mjs +29 -0
  24. package/test/helpers/tgz.mjs +71 -0
  25. package/test/host-search.test.mjs +18 -11
  26. package/test/host-tail.test.mjs +119 -24
  27. package/test/proxy-route.test.mjs +61 -0
  28. package/test/proxy-window.test.mjs +5 -0
  29. package/test/proxy.test.mjs +13 -1
  30. package/test/proxybridge-bundle.test.mjs +1 -59
  31. package/test/proxybridge-health.test.mjs +116 -0
  32. package/test/redirector-bundle.test.mjs +21 -67
  33. package/test/redirector.test.mjs +395 -5
  34. package/test/risd-api.test.mjs +114 -17
  35. package/test/risd-bridge-degrade.test.mjs +3 -29
  36. package/test/risd-engine.test.mjs +13 -50
  37. package/test/risd-entry.test.mjs +0 -37
  38. package/test/risd-follow-start.test.mjs +101 -0
  39. package/test/risd-git.test.mjs +7 -5
  40. package/test/risd-handoff.test.mjs +6 -50
  41. package/test/risd-helpers.mjs +150 -3
  42. package/test/risd-host-p2.test.mjs +2 -30
  43. package/test/risd-lifecycle.test.mjs +25 -0
  44. package/test/risd-programs.test.mjs +4 -34
  45. package/test/risd-restart.test.mjs +104 -0
  46. package/test/risd-review-p2.test.mjs +0 -13
  47. package/test/risd-shutdown.test.mjs +5 -38
  48. package/test/risd-teardown.test.mjs +8 -27
  49. package/test/risd-ui.test.mjs +322 -4
  50. package/test/risd-write.test.mjs +2 -1
  51. package/test/startup-reconcile.test.mjs +44 -8
  52. package/test/proxy-restart.test.mjs +0 -37
package/lib/client.js CHANGED
@@ -296,6 +296,58 @@ window.__ModuleLoader__.load({
296
296
  return knownWorkspaceCwd()
297
297
  }
298
298
 
299
+ /** How the page answers "which (session, workspace) is on screen right now". */
300
+ var liveScopeResolver = null
301
+
302
+ /**
303
+ * Register (or clear) the page's freshest tree scope.
304
+ *
305
+ * The panel that OWNS the tree is the only one that can answer this: it re-reads
306
+ * the sidebar's live Session marker and the session store on every change. `fsOp`
307
+ * consults it once after the host refuses a mutation as `outside-workspace`.
308
+ * @param {Function|null} resolver - returns `{sessionId, cwd}`, or null to clear.
309
+ */
310
+ function setLiveScopeResolver(resolver) {
311
+ liveScopeResolver = typeof resolver === 'function' ? resolver : null
312
+ }
313
+
314
+ /** @returns {{sessionId?: string, cwd?: string}|undefined} the freshest scope. */
315
+ function liveScope() {
316
+ if (liveScopeResolver === null) return undefined
317
+ try {
318
+ var scope = liveScopeResolver()
319
+ return scope !== null && typeof scope === 'object' ? scope : undefined
320
+ } catch {
321
+ return undefined
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Which Session the host considers LIVE for the workspace a scope names.
327
+ *
328
+ * Read-only probe (`/windows?cwd=`); the host answers with `liveSessionFor(cwd)`,
329
+ * i.e. the Session whose header cwd owns that tree. A window that kept the
330
+ * Session it was booted on gets the right answer here after a workspace switch.
331
+ * @param {{sessionId?: string, cwd?: string}} scope - the scope that just failed.
332
+ * @returns {Promise<string|undefined>} a live session id, or undefined.
333
+ */
334
+ async function liveSessionOfScope(scope) {
335
+ var cwd = scopeCwd(scope)
336
+ if (typeof cwd !== 'string' || cwd === '') return undefined
337
+ try {
338
+ var url = routeUrl('dsh-ris-ide/windows')
339
+ url.searchParams.set('cwd', cwd)
340
+ var response = await fetch(url.href, { headers: { accept: 'application/json' } })
341
+ var parsed = await response.json().catch(function () { return null })
342
+ if (parsed === null || parsed === undefined || parsed.ok !== true) return undefined
343
+ var session = parsed.session
344
+ var id = session !== null && typeof session === 'object' ? session.id : undefined
345
+ return typeof id === 'string' && id !== '' ? id : undefined
346
+ } catch {
347
+ return undefined
348
+ }
349
+ }
350
+
299
351
  /**
300
352
  * The workspace of ONE session, read through the slot's standard `useSessions`
301
353
  * hook.
@@ -1211,7 +1263,12 @@ window.__ModuleLoader__.load({
1211
1263
  }
1212
1264
  }
1213
1265
 
1214
- /** Storage key + default height of the compact panel's log pane. */
1266
+ /**
1267
+ * Storage key + default height of the compact panel's log pane.
1268
+ * Deliberately NOT workspace-scoped (unlike the IDE tabs/recent list): the
1269
+ * compact layout is a preference of this machine, and two panes of the same
1270
+ * page should agree on how tall the log is (评审 20261109-2326 客户端 P2).
1271
+ */
1215
1272
  var COMPACT_UI_KEY = 'dsh-ris-ide:ui:compact'
1216
1273
  var COMPACT_PANE_DEFAULT = 240
1217
1274
 
@@ -1227,19 +1284,9 @@ window.__ModuleLoader__.load({
1227
1284
  return Math.min(Math.max(120, value), 720)
1228
1285
  }
1229
1286
 
1230
- /** Storage key of the compact panel's maximized section ('' | 'console' | 'log'). */
1231
- var COMPACT_MAX_KEY = 'dsh-ris-ide:ui:compact-max'
1232
-
1233
- /**
1234
- * Which compact section is maximized: 'console', 'log', or '' for the split
1235
- * view. A stale/garbage value degrades to the split view, never to a blank
1236
- * panel (same tolerance as the saved height).
1237
- * @returns {string}
1238
- */
1239
- function readCompactMax() {
1240
- var raw = readPref(COMPACT_MAX_KEY, '')
1241
- return raw === 'console' || raw === 'log' ? raw : ''
1242
- }
1287
+ // The compact panel's maximised section is NOT remembered (m00584): a ⤢ was
1288
+ // persisted machine-wide and every later panel open showed one section only,
1289
+ // with nothing on screen saying why the other one was gone.
1243
1290
 
1244
1291
  /** Clamp a font size read from storage into the supported range. */
1245
1292
  /** The IDE-wide content font size: 10–18px in 0.5 steps (A−/A+ control). */
@@ -5548,6 +5595,13 @@ window.__ModuleLoader__.load({
5548
5595
  try {
5549
5596
  var payload = await fsClipboardState(scope)
5550
5597
  if (payload === null || payload === undefined || payload.ok !== true) return null
5598
+ // The host re-checks the ORIGINALS of the last tree copies: a source that
5599
+ // vanished after Ctrl+C is reported here, with its still-intact staged copy.
5600
+ if (Array.isArray(payload.warnings)) {
5601
+ for (var warningIndex = 0; warningIndex < payload.warnings.length; warningIndex += 1) {
5602
+ if (typeof payload.warnings[warningIndex] === 'string') notify(payload.warnings[warningIndex])
5603
+ }
5604
+ }
5551
5605
  return {
5552
5606
  files: Array.isArray(payload.files) ? payload.files : [],
5553
5607
  text: typeof payload.text === 'string' ? payload.text : '',
@@ -6231,7 +6285,7 @@ window.__ModuleLoader__.load({
6231
6285
  var flyout = menuSub === null
6232
6286
  ? null
6233
6287
  : h('div', {
6234
- key: 'new-flyout', 'data-tree-submenu-panel': 'new',
6288
+ key: 'new-flyout', 'data-tree-submenu-panel': 'new', 'data-ris-ide-menu': '1',
6235
6289
  style: Object.assign({}, S.tabMenu, {
6236
6290
  position: 'absolute', left: menuSub.left, top: menuSub.top, zIndex: 901, minWidth: 150,
6237
6291
  maxHeight: 320, overflowY: 'auto',
@@ -6248,6 +6302,7 @@ window.__ModuleLoader__.load({
6248
6302
  return h('div', {
6249
6303
  style: Object.assign({}, S.tabMenu, { left: treeMenu.x, top: treeMenu.y, position: 'fixed', zIndex: 900, minWidth: 150 }),
6250
6304
  'data-tree-menu': '1',
6305
+ 'data-ris-ide-menu': '1',
6251
6306
  onMouseDown: function (event) { event.stopPropagation() },
6252
6307
  onMouseLeave: function () { setMenuSub(null) },
6253
6308
  }, items, flyout)
@@ -6665,33 +6720,67 @@ window.__ModuleLoader__.load({
6665
6720
  }
6666
6721
 
6667
6722
  /**
6668
- * The saved layout of one IDE tab: `{ui:{maximized,section}, sizes, font,
6669
- * theme, files, file}`. Persisted per tab under `dsh-ris-ide:ui:<key>`.
6723
+ * One stored IDE-tab blob, or null when it is absent/junk. Parsing is per key:
6724
+ * `dsh-ris-ide:ui:*` also holds non-JSON preferences (`…:compact-max` = 'log'),
6725
+ * and one of those used to abort the whole legacy scan (C review P2).
6726
+ * @param {string|null} raw - the localStorage value.
6727
+ * @returns {object|null} the parsed blob.
6728
+ */
6729
+ function parseSavedBlob(raw) {
6730
+ if (raw === null || raw === undefined) return null
6731
+ try {
6732
+ var blob = JSON.parse(raw)
6733
+ return blob !== null && typeof blob === 'object' ? blob : null
6734
+ } catch (error) {
6735
+ return null
6736
+ }
6737
+ }
6738
+
6739
+ /**
6740
+ * The saved layout of one IDE tab: `{ui:{collapsed,section}, sizes, font,
6741
+ * files, file}`. Persisted per tab + WORKSPACE under
6742
+ * `dsh-ris-ide:ui:<key>@<cwd>` (m13444).
6670
6743
  *
6671
- * The workspace tab used to be keyed per PROGRAM (the panel passed the first
6672
- * program's meta), so a user's maximised pane / colour scheme / font size could
6673
- * silently reset after that key became `…:workspace`. When the exact key has
6674
- * nothing saved, adopt the first other `dsh-ris-ide:ui:*` entry and let the
6675
- * normal persist effect copy it to the current key.
6744
+ * `ui.maximized` is deliberately NOT part of this shape any more (m00584): a
6745
+ * blob written by an older build may still carry it and is ignored on read.
6746
+ *
6747
+ * Pre-m13444 keys had no workspace suffix. Migration is one-shot: the tab's
6748
+ * own legacy key (`…:<key>` without `@…`) is adopted ONCE and deleted, so the
6749
+ * next workspace does not inherit the same open tabs again (C review P1-2).
6750
+ * Same-workspace tabs may still adopt each other (the old per-program key
6751
+ * behaviour); another workspace's blob is never adopted.
6676
6752
  * @param {string} storageKey - the current tab's key.
6753
+ * @param {string} [workspaceKey] - the workspace this tab belongs to.
6677
6754
  * @returns {object|null} the saved blob.
6678
6755
  */
6679
- function readSavedUi(storageKey) {
6756
+ function readSavedUi(storageKey, workspaceKey) {
6680
6757
  try {
6681
6758
  if (typeof localStorage === 'undefined') return null
6682
- var raw = localStorage.getItem(storageKey)
6683
- if (raw !== null) {
6684
- var own = JSON.parse(raw)
6685
- return own !== null && typeof own === 'object' ? own : null
6686
- }
6759
+ var own = parseSavedBlob(localStorage.getItem(storageKey))
6760
+ if (own !== null) return own
6687
6761
  if (typeof localStorage.key !== 'function') return null
6762
+ var scoped = typeof workspaceKey === 'string' && workspaceKey !== ''
6763
+ if (scoped === true) {
6764
+ var at = storageKey.lastIndexOf('@')
6765
+ var legacyKey = at > 0 ? storageKey.slice(0, at) : null
6766
+ if (legacyKey !== null) {
6767
+ var migrated = parseSavedBlob(localStorage.getItem(legacyKey))
6768
+ if (migrated !== null) {
6769
+ try { localStorage.removeItem(legacyKey) } catch (removeError) { /* private mode */ }
6770
+ return migrated
6771
+ }
6772
+ }
6773
+ }
6688
6774
  for (var index = 0; index < localStorage.length; index += 1) {
6689
6775
  var key = localStorage.key(index)
6690
6776
  if (typeof key !== 'string' || key.indexOf('dsh-ris-ide:ui:') !== 0 || key === storageKey) continue
6691
- var legacyRaw = localStorage.getItem(key)
6692
- if (legacyRaw === null) continue
6693
- var legacy = JSON.parse(legacyRaw)
6694
- if (legacy !== null && typeof legacy === 'object') return legacy
6777
+ // Only a tab of THIS workspace: split at the LAST `@`, so a cwd that
6778
+ // itself contains an `@` cannot match another workspace (C review P2).
6779
+ if (scoped !== true) continue
6780
+ var splitAt = key.lastIndexOf('@')
6781
+ if (splitAt <= 0 || key.slice(splitAt + 1) !== workspaceKey) continue
6782
+ var blob = parseSavedBlob(localStorage.getItem(key))
6783
+ if (blob !== null) return blob
6695
6784
  }
6696
6785
  return null
6697
6786
  } catch (error) {
@@ -6777,22 +6866,54 @@ window.__ModuleLoader__.load({
6777
6866
  }
6778
6867
 
6779
6868
  /**
6780
- * Per-notice dismissal state: a notice stays closed until its SIGNATURE changes
6781
- * (a new message, or the same one after the state moved on).
6869
+ * Which notice kinds the user closed, and at which signature: a notice stays
6870
+ * closed until its SIGNATURE changes (a new message, or the same one after the
6871
+ * state moved on).
6872
+ *
6873
+ * This lives at MODULE scope rather than in component state (m00388): the same
6874
+ * panel can be mounted more than once at the same moment — the DSH sidebar
6875
+ * keeps a hidden copy beside the visible one, and `keepMounted` keeps a copy
6876
+ * alive across tab switches — so a ✕ that only touched the clicked instance
6877
+ * left the other one rendering the notice again ("点 X 关不掉"). Every mounted
6878
+ * instance subscribes and re-renders together.
6879
+ */
6880
+ var NOTICE_DISMISSALS = {}
6881
+ var NOTICE_DISMISSAL_LISTENERS = []
6882
+ /**
6883
+ * Whether a notice of `kind` with `signature` should still be shown.
6884
+ * @param {string} kind - notice kind (also `data-notice`).
6885
+ * @param {string} signature - the message identity this kind currently carries.
6886
+ * @returns {boolean} true while the user has not closed exactly this one.
6887
+ */
6888
+ function noticeIsOpen(kind, signature) {
6889
+ return NOTICE_DISMISSALS[kind] !== signature
6890
+ }
6891
+ /**
6892
+ * Close one notice for EVERY mounted panel (and every later mount).
6893
+ * @param {string} kind - notice kind.
6894
+ * @param {string} signature - the message identity being closed.
6895
+ */
6896
+ function dismissNotice(kind, signature) {
6897
+ if (NOTICE_DISMISSALS[kind] === signature) return
6898
+ NOTICE_DISMISSALS[kind] = signature
6899
+ NOTICE_DISMISSAL_LISTENERS.slice().forEach(function (listener) { listener() })
6900
+ }
6901
+ /**
6902
+ * Subscribe one mounted panel to the shared dismissal table.
6782
6903
  * @returns {{isOpen: function(string, string): boolean, dismiss: function(string, string): void}}
6783
6904
  */
6784
6905
  function useDismissedNotices() {
6785
- var [dismissed, setDismissed] = useState(function () { return {} })
6906
+ var [, setVersion] = useState(0)
6907
+ useEffect(function () {
6908
+ var listener = function () { setVersion(function (value) { return value + 1 }) }
6909
+ NOTICE_DISMISSAL_LISTENERS.push(listener)
6910
+ return function () {
6911
+ NOTICE_DISMISSAL_LISTENERS = NOTICE_DISMISSAL_LISTENERS.filter(function (item) { return item !== listener })
6912
+ }
6913
+ }, [])
6786
6914
  return {
6787
- isOpen: function (kind, signature) { return dismissed[kind] !== signature },
6788
- dismiss: function (kind, signature) {
6789
- setDismissed(function (prev) {
6790
- if (prev[kind] === signature) return prev
6791
- var next = Object.assign({}, prev)
6792
- next[kind] = signature
6793
- return next
6794
- })
6795
- },
6915
+ isOpen: function (kind, signature) { return noticeIsOpen(kind, signature) },
6916
+ dismiss: function (kind, signature) { dismissNotice(kind, signature) },
6796
6917
  }
6797
6918
  }
6798
6919
 
@@ -6877,6 +6998,18 @@ window.__ModuleLoader__.load({
6877
6998
  // (Chromium < 111): without it the hover rule would be dropped entirely.
6878
6999
  + '{background:rgba(0,0,0,0.05);background:color-mix(in srgb, currentColor 7%, transparent)}'
6879
7000
 
7001
+ /**
7002
+ * Context-menu row hover: the same faint grey tint the tree rows use, under the
7003
+ * pointer over any menu this panel draws (file tree, tab strip, editor gutter).
7004
+ *
7005
+ * `!important` because `S.tabMenuItem` pins `background: transparent` as an
7006
+ * INLINE style — a stylesheet rule loses to inline without it. Disabled rows
7007
+ * (paste with an empty clipboard) keep their flat look.
7008
+ */
7009
+ var MENU_HOVER_CSS = '[data-workbench="ris-ide"] [data-ris-ide-menu] button:hover:not(:disabled)'
7010
+ // Same color-mix fallback ordering as the tree rows above.
7011
+ + '{background:rgba(0,0,0,0.05) !important;background:color-mix(in srgb, currentColor 7%, transparent) !important}'
7012
+
6880
7013
  /**
6881
7014
  * The editor's find panel, restyled to belong to the IDE (user口径: 美化一下
6882
7015
  * 编辑器的搜索面板,风格和整体不一致). CodeMirror ships a 2018-looking strip:
@@ -7386,6 +7519,13 @@ window.__ModuleLoader__.load({
7386
7519
  var meta = tab !== null && tab !== undefined && tab.meta !== null && typeof tab.meta === 'object' ? tab.meta : {}
7387
7520
  var sessionId = scope ? scope.sessionId : undefined
7388
7521
  var cwd = scope ? scope.cwd : undefined
7522
+ /**
7523
+ * Everything that remembers a WORKSPACE (open file tabs, recent history,
7524
+ * layout, search results) is scoped by this key: two workspaces are two
7525
+ * different file trees, so a tab or a `git grep` hit from one must never
7526
+ * appear in the other (m13444).
7527
+ */
7528
+ var workspaceKey = typeof cwd === 'string' && cwd !== '' ? cwd : 'default'
7389
7529
  var programs = Array.isArray(props.programs) ? props.programs : []
7390
7530
  var metaKind = typeof meta.kind === 'string' ? meta.kind : 'spring'
7391
7531
  var metaLogPath = typeof meta.logPath === 'string' ? meta.logPath : ''
@@ -7413,8 +7553,12 @@ window.__ModuleLoader__.load({
7413
7553
  * across suspends, so reading `dbg` from its closure would be stale. */
7414
7554
  var dbgRef = useRef(dbg)
7415
7555
  dbgRef.current = dbg
7416
- var storageKey = 'dsh-ris-ide:ui:' + (programKey !== '' ? programKey : (metaLogPath !== '' ? metaLogPath : 'workspace'))
7417
- var savedUi = readSavedUi(storageKey)
7556
+ var storageKey = 'dsh-ris-ide:ui:' + (programKey !== '' ? programKey : (metaLogPath !== '' ? metaLogPath : 'workspace')) + '@' + workspaceKey
7557
+ // Read the saved blob ONCE per mount (it only seeds useState initializers
7558
+ // below). The read also runs the one-shot legacy migration — readSavedUi
7559
+ // removes the key it adopted — so calling it per render would re-probe
7560
+ // localStorage on every keystroke (评审 20261109-2326 客户端 P2).
7561
+ var [savedUi] = useState(function () { return readSavedUi(storageKey, workspaceKey) })
7418
7562
 
7419
7563
  var [consoleBusy, setConsoleBusy] = useState('')
7420
7564
  /** Which action that row mask is running (`start|stop|restart|debug`). */
@@ -7423,14 +7567,16 @@ window.__ModuleLoader__.load({
7423
7567
  var [consoleBulk, setConsoleBulk] = useState(null)
7424
7568
  var consoleBulkRef = useRef(false)
7425
7569
  var [ui, setUi] = useState(function () {
7426
- // First ever open of an IDE tab (no saved layout, real browser): start with
7427
- // the SOURCE pane maximised so the editor gets the whole area, and let the
7428
- // normal persistence save that state — every later open restores whatever
7429
- // the user left (including "not maximised"). SSR has no localStorage, so
7430
- // tests/previews keep the plain 2x2 grid.
7431
- var firstOpen = savedUi === null && typeof localStorage !== 'undefined'
7432
- var base = { section: 'breakpoints', collapsed: false, threadId: undefined, frameIndex: 0, note: undefined, busy: false, maximized: firstOpen ? 'editor' : null }
7433
- return savedUi !== null && typeof savedUi.ui === 'object' ? Object.assign(base, savedUi.ui) : base
7570
+ // Every open starts on the plain 2x2 grid: maximise mode (⤢) is NEVER
7571
+ // persisted nor defaulted (m00584 — a remembered "editor" made the IDE
7572
+ // open looking like it had only an editor, with no hint that a pane was
7573
+ // maximised). Only the collapsed section is restored from the saved blob.
7574
+ var base = { section: 'breakpoints', collapsed: false, threadId: undefined, frameIndex: 0, note: undefined, busy: false, maximized: null }
7575
+ if (savedUi !== null && typeof savedUi.ui === 'object') {
7576
+ if (savedUi.ui.collapsed === true) base.collapsed = true
7577
+ if (typeof savedUi.ui.section === 'string' && savedUi.ui.section !== '') base.section = savedUi.ui.section
7578
+ }
7579
+ return base
7434
7580
  })
7435
7581
  /** The three user-draggable pane sizes (px). */
7436
7582
  var [sizes, setSizes] = useState(function () {
@@ -7482,6 +7628,19 @@ var [ui, setUi] = useState(function () {
7482
7628
  * query (or the `git grep` output) away, so the same row can be reopened.
7483
7629
  */
7484
7630
  var searchCacheRef = useRef(new Map())
7631
+ /**
7632
+ * Search cache key: `kind:workspace\0query`. The workspace MUST be part of
7633
+ * it — `git grep` runs against one tree, so replaying another tree's hits
7634
+ * (or dropping the new tree's entry when invalidating) would cross
7635
+ * workspaces (m13444).
7636
+ */
7637
+ function searchKey(kind, text) {
7638
+ return kind + ':' + workspaceKey + '\u0000' + text
7639
+ }
7640
+ /** A workspace switch replaces the tree under every cached payload. */
7641
+ useEffect(function () {
7642
+ searchCacheRef.current.clear()
7643
+ }, [workspaceKey])
7485
7644
  /**
7486
7645
  * Bumped when the cached results for the CURRENT query must be thrown away
7487
7646
  * (Ctrl+R, or a save in this window). `searchCacheRef` is keyed by query text
@@ -7740,6 +7899,8 @@ var [ui, setUi] = useState(function () {
7740
7899
  var forceEditPathsRef = useRef(new Set())
7741
7900
  var [savingPath, setSavingPath] = useState(undefined)
7742
7901
  var [pendingClose, setPendingClose] = useState(undefined)
7902
+ /** A "reload from disk" waiting for a decision when the tab is dirty. */
7903
+ var [pendingReload, setPendingReload] = useState(undefined)
7743
7904
  /** Bulk close waiting for a decision: `{keepActive, victims, dirty}`. */
7744
7905
  var [pendingBulk, setPendingBulk] = useState(undefined)
7745
7906
  /** Files opened recently (newest first), shown under the open tabs. */
@@ -8131,13 +8292,26 @@ var [ui, setUi] = useState(function () {
8131
8292
  setTimeout(function () { Object.keys(docsRef.current).forEach(function (path) { ensureDocRef.current(path) }) }, 0)
8132
8293
  })
8133
8294
 
8134
- /** Load one document (idempotent): media kinds need no read at all. */
8135
- function ensureDoc(path) {
8295
+ /**
8296
+ * Load one document (idempotent): media kinds need no read at all.
8297
+ * @param {string} path - absolute file path.
8298
+ * @param {boolean} [force] - re-read a path that is already loaded (the tab
8299
+ * strip's 重新加载 button); the CALLER drops the draft first, so a reload
8300
+ * never merges an unsaved buffer into what came back from disk.
8301
+ */
8302
+ function ensureDoc(path, force) {
8136
8303
  if (typeof path !== 'string' || path === '') return
8137
- if (docs[path] !== undefined) return
8304
+ if (force !== true && docs[path] !== undefined) return
8138
8305
  if (isPdfPath(path) || isImagePath(path)) {
8139
8306
  var kind = isPdfPath(path) ? 'pdf' : 'image'
8140
- setDocs(function (prev) { if (prev[path] !== undefined) return prev; var next = Object.assign({}, prev); next[path] = { kind: kind }; return next })
8307
+ // `at` makes the reassignment a real change, so the cache-busting media
8308
+ // URL is rebuilt and the browser reads the file again.
8309
+ setDocs(function (prev) {
8310
+ if (prev[path] !== undefined && force !== true) return prev
8311
+ var next = Object.assign({}, prev)
8312
+ next[path] = { kind: kind, at: force === true ? Date.now() : 0 }
8313
+ return next
8314
+ })
8141
8315
  return
8142
8316
  }
8143
8317
  var cancelled = { current: false }
@@ -8442,6 +8616,26 @@ var [ui, setUi] = useState(function () {
8442
8616
  if (isDirty(path)) setPendingClose(path)
8443
8617
  else closePath(path)
8444
8618
  }
8619
+ /**
8620
+ * Re-read ONE tab from disk (the tab strip's 重新加载 button, m00388).
8621
+ *
8622
+ * "Reload" means *what is on disk now*: the draft is dropped first, never
8623
+ * merged. Media tabs get a fresh cache-busting URL (`ensureDoc(…, true)`);
8624
+ * text tabs get a brand-new document, which the CodeMirror host applies
8625
+ * through its `props.text` effect.
8626
+ * @param {string} path - absolute file path.
8627
+ */
8628
+ function reloadPath(path) {
8629
+ if (typeof path !== 'string' || path === '') return
8630
+ forgetDoc(path)
8631
+ ensureDoc(path, true)
8632
+ }
8633
+ /** 重新加载: ask first when the tab holds unsaved edits. */
8634
+ function requestReload(path) {
8635
+ if (typeof path !== 'string' || path === '') return
8636
+ if (isDirty(path)) setPendingReload(path)
8637
+ else reloadPath(path)
8638
+ }
8445
8639
  /** Disk text for a document: restore the file's original line endings. */
8446
8640
  function docTextForDisk(doc) {
8447
8641
  if (doc === undefined || doc === null) return ''
@@ -9215,12 +9409,15 @@ var [ui, setUi] = useState(function () {
9215
9409
  ensureDoc(openFile)
9216
9410
  }, [openFile, sessionId, reloadTick])
9217
9411
 
9218
- /** Remember open files, the active one and the layout. */
9412
+ /** Remember open files, the active one and the layout (maximise mode never). */
9219
9413
  useEffect(function () {
9220
9414
  try {
9221
9415
  if (typeof localStorage === 'undefined') return
9222
9416
  localStorage.setItem(storageKey, JSON.stringify({
9223
- ui: { collapsed: ui.collapsed, maximized: ui.maximized, section: ui.section },
9417
+ // No `maximized`: which pane is full-screened is a transient view
9418
+ // state, not a preference (m00584) — a restored ⤢ hid three panes and
9419
+ // looked like the IDE only had an editor.
9420
+ ui: { collapsed: ui.collapsed, section: ui.section },
9224
9421
  files: openFiles,
9225
9422
  file: openFile,
9226
9423
  recent: recentFiles,
@@ -9228,7 +9425,7 @@ var [ui, setUi] = useState(function () {
9228
9425
  font: uiFont,
9229
9426
  }))
9230
9427
  } catch (error) { /* private mode / quota: layout memory is best-effort */ }
9231
- }, [ui.collapsed, ui.maximized, ui.section, openFiles, openFile, recentFiles, sizes.left, sizes.leftBottom, sizes.rightBottom, sizes.debugWidth, uiFont])
9428
+ }, [ui.collapsed, ui.section, openFiles, openFile, recentFiles, sizes.left, sizes.leftBottom, sizes.rightBottom, sizes.debugWidth, uiFont])
9232
9429
 
9233
9430
  /**
9234
9431
  * Ctrl/Cmd+W closes the active source tab (asking when dirty); Ctrl/Cmd+F4
@@ -9313,8 +9510,8 @@ var [ui, setUi] = useState(function () {
9313
9510
  var query = String(raw === undefined || raw === null ? '' : raw).trim()
9314
9511
  var dropped = false
9315
9512
  if (query !== '') {
9316
- dropped = searchCacheRef.current.delete('content:' + query) || dropped
9317
- dropped = searchCacheRef.current.delete('name:' + query) || dropped
9513
+ dropped = searchCacheRef.current.delete(searchKey('content', query)) || dropped
9514
+ dropped = searchCacheRef.current.delete(searchKey('name', query)) || dropped
9318
9515
  }
9319
9516
  // Nothing cached: whatever is on screen came from a run that is still
9320
9517
  // fresh (or is already in flight), so a second kick would only abort it.
@@ -9325,7 +9522,7 @@ var [ui, setUi] = useState(function () {
9325
9522
  useEffect(function () {
9326
9523
  var text = treeQuery.trim()
9327
9524
  if (text === '') { setSearchHits(null); setSearchBusy(false); return undefined }
9328
- var cached = searchCacheRef.current.get('name:' + text)
9525
+ var cached = searchCacheRef.current.get(searchKey('name', text))
9329
9526
  if (cached !== undefined && cached !== null) {
9330
9527
  setSearchHits(cached)
9331
9528
  setSearchBusy(false)
@@ -9348,7 +9545,7 @@ var [ui, setUi] = useState(function () {
9348
9545
  }, controller === null ? undefined : controller.signal).then(function () {
9349
9546
  if (cancelled) return
9350
9547
  var payload = searchHitPayload({ matches: matches.slice(), dirs: {} }, cwd)
9351
- rememberSearchEntry(searchCacheRef.current, 'name:' + text, payload)
9548
+ rememberSearchEntry(searchCacheRef.current, searchKey('name', text), payload)
9352
9549
  setSearchHits(payload)
9353
9550
  setSearchBusy(false)
9354
9551
  }).catch(function (problem) {
@@ -9373,7 +9570,7 @@ var [ui, setUi] = useState(function () {
9373
9570
  useEffect(function () {
9374
9571
  var text = treeQuery.trim()
9375
9572
  if (text.length < 2) { setContentHits([]); setContentBusy(false); return undefined }
9376
- var cached = searchCacheRef.current.get('content:' + text)
9573
+ var cached = searchCacheRef.current.get(searchKey('content', text))
9377
9574
  if (cached !== undefined && Array.isArray(cached)) {
9378
9575
  setContentHits(cached)
9379
9576
  setContentBusy(false)
@@ -9393,7 +9590,7 @@ var [ui, setUi] = useState(function () {
9393
9590
  }, controller === null ? undefined : controller.signal).then(function () {
9394
9591
  if (cancelled) return
9395
9592
  var payload = hits.slice()
9396
- rememberSearchEntry(searchCacheRef.current, 'content:' + text, payload)
9593
+ rememberSearchEntry(searchCacheRef.current, searchKey('content', text), payload)
9397
9594
  setContentHits(payload)
9398
9595
  setContentBusy(false)
9399
9596
  }).catch(function (problem) {
@@ -10183,12 +10380,27 @@ var [ui, setUi] = useState(function () {
10183
10380
  }, '×'))
10184
10381
  })),
10185
10382
  h('button', { type: 'button', style: S.tabPage, 'data-tab-page': 'next', title: '下一页页签', onClick: function () { pageTabs(1) } }, '▶'),
10186
- h('button', {
10187
- type: 'button', style: S.tabPage, 'data-action': 'diff',
10188
- title: openFile === '' ? '先打开一个文件' : '与磁盘版本对比:看这一版到底改了哪几行(有未保存修改时可用)',
10189
- disabled: openFile === '' || isDirty(openFile) !== true,
10190
- onClick: function () { setDiffPath(diffPath === openFile ? null : openFile) },
10191
- }, '±'),
10383
+ // ± (compare with disk) and ⟳ (reload from disk) ask the SAME question,
10384
+ // "how does my buffer relate to the file?", and only one of them is ever
10385
+ // useful: a dirty buffer can only be compared, a clean one can only be
10386
+ // reloaded (there is nothing left to throw away). So they swap, sharing
10387
+ // one slot in the strip (m00808) instead of leaving a dead ± behind.
10388
+ // `openFile` starts as `undefined` (not ''), so test for "a real path",
10389
+ // not for an empty string — otherwise ⟳ looks enabled with no tab open.
10390
+ isDirty(openFile) === true
10391
+ ? h('button', {
10392
+ type: 'button', style: S.tabPage, 'data-action': 'diff',
10393
+ title: '与磁盘版本对比:看这一版到底改了哪几行(' + fileBaseName(openFile) + ')',
10394
+ onClick: function () { setDiffPath(diffPath === openFile ? null : openFile) },
10395
+ }, '±')
10396
+ : h('button', {
10397
+ type: 'button', style: S.tabPage, 'data-action': 'reload-file',
10398
+ title: typeof openFile === 'string' && openFile !== ''
10399
+ ? '重新加载 ' + fileBaseName(openFile) + ':丢掉当前缓冲区,重新从磁盘读取(有未保存修改时这个位置变成 ± 对比)'
10400
+ : '先打开一个文件(缓冲区没有未保存修改时,这个位置是重新加载)',
10401
+ disabled: typeof openFile !== 'string' || openFile === '',
10402
+ onClick: function () { requestReload(openFile) },
10403
+ }, '⟳'),
10192
10404
  testRunTarget(openFile, cwd) === null
10193
10405
  ? null
10194
10406
  : h('button', {
@@ -10272,6 +10484,34 @@ var [ui, setUi] = useState(function () {
10272
10484
  onClick: function () { setPendingBulk(undefined) },
10273
10485
  }, '×'))
10274
10486
  : null
10487
+ var reloadPrompt = pendingReload !== undefined
10488
+ ? h('div', { style: Object.assign({}, S.notice, { display: 'flex', alignItems: 'center', gap: 6 }), 'data-reload-prompt': '1' },
10489
+ h('span', { style: { flex: '1 1 auto', minWidth: 0 } }, '「' + fileBaseName(pendingReload) + '」有未保存的修改,重新加载会丢掉它们:'),
10490
+ h('button', {
10491
+ type: 'button', style: S.button, 'data-action': 'save-reload', title: '保存当前修改,再从磁盘重新读取',
10492
+ onClick: function () {
10493
+ var target = pendingReload
10494
+ setPendingReload(undefined)
10495
+ void savePath(target).then(function (ok) { if (ok) reloadPath(target) })
10496
+ },
10497
+ }, '保存并重载'),
10498
+ h('button', {
10499
+ type: 'button', style: S.buttonOff, 'data-action': 'discard-reload', title: '丢掉未保存的修改,按磁盘上的版本重新加载',
10500
+ onClick: function () {
10501
+ var target = pendingReload
10502
+ setPendingReload(undefined)
10503
+ reloadPath(target)
10504
+ },
10505
+ }, '丢弃重载'),
10506
+ h('button', {
10507
+ type: 'button', style: S.buttonOff, 'data-action': 'cancel-reload', title: '保持当前缓冲区不动',
10508
+ onClick: function () { setPendingReload(undefined) },
10509
+ }, '取消'),
10510
+ h('button', {
10511
+ type: 'button', style: Object.assign({}, S.buttonOff, { padding: '0 4px' }), 'data-notice-close': 'reload-prompt', title: '关闭提示(保持当前缓冲区)',
10512
+ onClick: function () { setPendingReload(undefined) },
10513
+ }, '×'))
10514
+ : null
10275
10515
  var body = openFiles.length === 0
10276
10516
  ? h('div', { style: S.idePlaceholder, 'data-no-file': '1' }, '在左侧选择一个文件:打开即可编辑,Ctrl/Cmd+S 保存')
10277
10517
  : openFiles.map(filePane)
@@ -10284,6 +10524,7 @@ var [ui, setUi] = useState(function () {
10284
10524
  overflowY: 'auto', zIndex: 945,
10285
10525
  }),
10286
10526
  'data-tabs-menu': '1',
10527
+ 'data-ris-ide-menu': '1',
10287
10528
  onMouseDown: function (event) { event.stopPropagation() },
10288
10529
  },
10289
10530
  menuRows.length === 0 ? h('span', { style: Object.assign({}, S.meta, { display: 'block', padding: '4px 10px' }) }, '还没有打开过文件')
@@ -10394,6 +10635,7 @@ var [ui, setUi] = useState(function () {
10394
10635
  tabsMenu,
10395
10636
  prompt,
10396
10637
  bulkPrompt,
10638
+ reloadPrompt,
10397
10639
  h('div', { style: S.filePanes },
10398
10640
  // The editor is NEVER swapped out: hiding it behind an overlay keeps
10399
10641
  // the CodeMirror instance (and its undo history) alive, so closing the
@@ -10775,7 +11017,7 @@ var [ui, setUi] = useState(function () {
10775
11017
  if (paneConfig !== null && typeof paneConfig.generate === 'function') {
10776
11018
  consoleConfigActions.push(button('⚙', function () { paneConfig.generate() }, { key: 'config-generate', icon: true, height: 20, action: 'config-generate', title: paneConfig.exists === true ? '更新配置:按当前扫描结果同步 .dsh-ris-ide/config.json(保留你改过的字段)' : '生成配置:把扫描到的程序写成 .dsh-ris-ide/config.json' }))
10777
11019
  }
10778
- paneActions.push(button('⟲', resetLayout, { key: 'layout-reset', icon: true, height: 20, action: 'layout-reset', title: '还原布局尺寸:左列 300px、调试区 300px、两个下层 260px(不改变最大化状态)' }))
11020
+ paneActions.push(button('▦', resetLayout, { key: 'layout-reset', icon: true, height: 20, action: 'layout-reset', title: '还原布局尺寸:左列 300px、调试区 300px、两个下层 260px(不改变最大化状态;管尺寸不管内容)' }))
10779
11021
 
10780
11022
  /** Load the visual debug settings from the host (⚙ opens on a fresh read). */
10781
11023
  async function refreshDebugSettings() {
@@ -10890,7 +11132,7 @@ var [ui, setUi] = useState(function () {
10890
11132
  },
10891
11133
  // The sidebar's CodeMirror theme pins 13px, so the embedded viewer needs
10892
11134
  // this rule, not inheritance, to follow A−/A+.
10893
- h('style', { key: 'ide-font' }, viewerFontCss(uiFont) + viewerThemeCss(pageDark) + DEBUG_LINE_CSS + PREVIEW_CSS + SELECTION_CSS + SCROLLBAR_CSS + SEARCH_PANEL_CSS + TOAST_CSS + PROGRAM_LOADING_CSS + TREE_HOVER_CSS),
11135
+ h('style', { key: 'ide-font' }, viewerFontCss(uiFont) + viewerThemeCss(pageDark) + DEBUG_LINE_CSS + PREVIEW_CSS + SELECTION_CSS + SCROLLBAR_CSS + SEARCH_PANEL_CSS + TOAST_CSS + PROGRAM_LOADING_CSS + TREE_HOVER_CSS + MENU_HOVER_CSS),
10894
11136
  (function () {
10895
11137
  var panes = {
10896
11138
  tree: h(IdeTree, {
@@ -11247,6 +11489,7 @@ var [ui, setUi] = useState(function () {
11247
11489
  editorMenu === null ? null : h('div', {
11248
11490
  style: Object.assign({}, S.tabMenu, { left: editorMenu.x, top: editorMenu.y, position: 'fixed', zIndex: 950, minWidth: 200 }),
11249
11491
  'data-editor-menu': '1',
11492
+ 'data-ris-ide-menu': '1',
11250
11493
  onMouseDown: function (event) { event.stopPropagation() },
11251
11494
  }, (editorMenu.items || []).map(function (item, index) {
11252
11495
  if (item.separator === true) {
@@ -11336,6 +11579,7 @@ var [ui, setUi] = useState(function () {
11336
11579
  tabMenu === null ? null : h('div', {
11337
11580
  style: Object.assign({}, S.tabMenu, { left: tabMenu.x, top: tabMenu.y }),
11338
11581
  'data-tab-menu': tabMenu.kind,
11582
+ 'data-ris-ide-menu': '1',
11339
11583
  onMouseDown: function (event) { event.stopPropagation() },
11340
11584
  },
11341
11585
  h('button', { type: 'button', style: S.tabMenuItem, 'data-action': 'ctx-close-others', onClick: function () { closeOtherTabsOf(); closeTabMenu() } }, '关闭其他'),
@@ -12548,22 +12792,57 @@ var [ui, setUi] = useState(function () {
12548
12792
  */
12549
12793
  async function fsOp(action, scope, payload) {
12550
12794
  var url = routeUrl('dsh-ris-ide/fs/' + action)
12551
- var response = await fetch(url.href, {
12552
- method: 'POST',
12553
- headers: { 'content-type': 'application/json' },
12554
- body: JSON.stringify(Object.assign({
12555
- sessionId: scope.sessionId,
12556
- }, typeof scope.cwd === 'string' && scope.cwd !== '' ? { cwd: scope.cwd } : {}, payload)),
12557
- })
12558
- var parsed = await response.json().catch(function () { return null })
12559
- if (!response.ok || parsed === null || parsed.ok !== true) {
12795
+ /**
12796
+ * POST one body for one scope and normalize the host's answer: the payload on
12797
+ * success, an `Error` (carrying the host's machine `code`) on failure. A return
12798
+ * instead of a throw lets `fsOp` retry exactly once.
12799
+ * @param {{sessionId?: string, cwd?: string}} active - the scope to send.
12800
+ * @returns {Promise<object|Error>} host payload or the failure.
12801
+ */
12802
+ async function send(active) {
12803
+ var response = await fetch(url.href, {
12804
+ method: 'POST',
12805
+ headers: { 'content-type': 'application/json' },
12806
+ body: JSON.stringify(Object.assign({
12807
+ sessionId: active.sessionId,
12808
+ }, typeof active.cwd === 'string' && active.cwd !== '' ? { cwd: active.cwd } : {}, payload)),
12809
+ })
12810
+ var parsed = await response.json().catch(function () { return null })
12811
+ if (response.ok && parsed !== null && parsed.ok === true) return parsed
12560
12812
  var failure = new Error(parsed !== null && parsed.message !== undefined ? parsed.message : 'HTTP ' + response.status)
12561
12813
  // The paste flow branches on `exists` to offer 改名/覆盖: keep the host's
12562
12814
  // machine code on the error instead of flattening it into a message.
12563
12815
  failure.code = parsed !== null && typeof parsed.code === 'string' ? parsed.code : ''
12564
- throw failure
12816
+ return failure
12565
12817
  }
12566
- return parsed
12818
+ var first = await send(scope)
12819
+ if (!(first instanceof Error)) return first
12820
+ /**
12821
+ * `outside-workspace` is the ONE failure the page can heal without the user:
12822
+ * it means the host fenced this request against a different workspace than the
12823
+ * tree on screen. After a workspace switch the panel/window can still carry the
12824
+ * previous Session (the standalone window keeps the Session it booted on), and
12825
+ * every mutation then died with 「后台任务出错:不能对工作区之外的路径执行新建文件夹」
12826
+ * (m00220). Re-read the live pair once — the page's own live scope first, else
12827
+ * the host's live Session for this workspace — and retry silently.
12828
+ */
12829
+ if (first.code === 'outside-workspace') {
12830
+ var next = null
12831
+ var fresh = liveScope()
12832
+ if (fresh !== undefined && typeof fresh.sessionId === 'string' && fresh.sessionId !== '' && fresh.sessionId !== scope.sessionId) {
12833
+ next = { sessionId: fresh.sessionId, cwd: typeof fresh.cwd === 'string' && fresh.cwd !== '' ? fresh.cwd : scope.cwd }
12834
+ }
12835
+ if (next === null) {
12836
+ var alive = await liveSessionOfScope(scope)
12837
+ if (alive !== undefined && alive !== scope.sessionId) next = { sessionId: alive, cwd: scope.cwd }
12838
+ }
12839
+ if (next !== null) {
12840
+ var retried = await send(next)
12841
+ if (!(retried instanceof Error)) return retried
12842
+ throw retried
12843
+ }
12844
+ }
12845
+ throw first
12567
12846
  }
12568
12847
  function fsMkdir(scope, path) { return fsOp('mkdir', scope, { path: path }) }
12569
12848
  function fsCreateFile(scope, path, content) { return fsOp('create', scope, { path: path, content: content === undefined ? '' : content }) }
@@ -13726,6 +14005,22 @@ var [ui, setUi] = useState(function () {
13726
14005
  if (typeof storeCwd === 'string' && storeCwd !== '') cwd = storeCwd
13727
14006
  // A stale session id must not blank the panel: the host still accepts a cwd.
13728
14007
  if (typeof cwd !== 'string' || cwd === '') cwd = knownWorkspaceCwd()
14008
+ /**
14009
+ * Publish the freshest (Session, workspace) pair to `fsOp`'s one-shot retry.
14010
+ * A mutation refused as `outside-workspace` means the host fenced it against a
14011
+ * workspace other than the tree on screen; the retry asks THIS closure (which
14012
+ * re-reads the sidebar's live marker and the session store) instead of guessing.
14013
+ */
14014
+ useEffect(function () {
14015
+ setLiveScopeResolver(function () {
14016
+ var live = liveSidebarSessionId()
14017
+ var nextSessionId = typeof live === 'string' && live !== '' ? live : sessionId
14018
+ var nextCwd = sessionWorkspaceCwd(props ? props.useSessions : undefined, nextSessionId)
14019
+ if (typeof nextCwd !== 'string' || nextCwd === '') nextCwd = cwd
14020
+ return { sessionId: nextSessionId, cwd: nextCwd }
14021
+ })
14022
+ return function () { setLiveScopeResolver(null) }
14023
+ }, [sessionId, cwd])
13729
14024
  // Selections and the followed log belong to the workspace they were made in,
13730
14025
  // so a Session switch drops them instead of showing another project's log.
13731
14026
  var sessionIdentity = typeof sessionId === 'string' ? sessionId : ''
@@ -13759,7 +14054,8 @@ var [ui, setUi] = useState(function () {
13759
14054
  // Which of the two compact sections owns the panel ('' = split view). The
13760
14055
  // sidebar is too narrow for the IDE's 2x2 maximize, but "最大化这一段" is
13761
14056
  // still useful when reading a long log or a long program list.
13762
- var [compactMax, setCompactMax] = useState(readCompactMax)
14057
+ /** Which compact section is expanded ('console' | 'log' | ''): view state only, starts split. */
14058
+ var [compactMax, setCompactMax] = useState('')
13763
14059
  // The compact log pane's "follow the tail" switch. LogTail defaults to
13764
14060
  // following, but the sidebar view had no control for it — the IDE title bar
13765
14061
  // owned that button, so the compact header needs its own.
@@ -14183,11 +14479,11 @@ var [ui, setUi] = useState(function () {
14183
14479
  }
14184
14480
 
14185
14481
  /** Drag the hairline above the log pane; the height is remembered on release. */
14186
- /** Maximize one compact section (console | log); the other one is parked. */
14482
+ /** Maximize one compact section (console | log); the other one is parked.
14483
+ * Deliberately NOT written to storage: reopening the panel always shows
14484
+ * the split view (m00584). */
14187
14485
  function toggleCompactMax(section) {
14188
- var next = compactMax === section ? '' : section
14189
- writePref(COMPACT_MAX_KEY, next)
14190
- setCompactMax(next)
14486
+ setCompactMax(compactMax === section ? '' : section)
14191
14487
  }
14192
14488
 
14193
14489
  function dragLogPane(event) {
@@ -14520,7 +14816,12 @@ var [ui, setUi] = useState(function () {
14520
14816
 
14521
14817
  if (compact) return compactPanel()
14522
14818
 
14819
+ // key = workspaceKey: the tabs, recent list and layout of the workbench are
14820
+ // initialised from that workspace's own blob at mount, so a cwd change has to
14821
+ // remount instead of keeping the previous workspace's state (评审
14822
+ // 20261109-2326 客户端 P2).
14523
14823
  return h(ProgramWorkbench, {
14824
+ key: typeof cwd === 'string' && cwd !== '' ? cwd : 'default',
14524
14825
  scope: { sessionId: sessionId, cwd: cwd },
14525
14826
  visible: true,
14526
14827
  programs: state.programs,
@@ -14732,8 +15033,6 @@ var [ui, setUi] = useState(function () {
14732
15033
  COMPACT_PANE_DEFAULT: COMPACT_PANE_DEFAULT,
14733
15034
  COMPACT_UI_KEY: COMPACT_UI_KEY,
14734
15035
  CompactLogHead: CompactLogHead,
14735
- COMPACT_MAX_KEY: COMPACT_MAX_KEY,
14736
- readCompactMax: readCompactMax,
14737
15036
  readCompactPaneHeight: readCompactPaneHeight,
14738
15037
  requestDebug: requestDebug,
14739
15038
  requestDebugs: requestDebugs,
@@ -14785,6 +15084,14 @@ var [ui, setUi] = useState(function () {
14785
15084
  debugSnapshotSuspended: debugSnapshotSuspended,
14786
15085
  debugSuspendedThreadId: debugSuspendedThreadId,
14787
15086
  readSavedUi: readSavedUi,
15087
+ // Notice dismissals are shared module state (m00388): the ✕ has to stick for
15088
+ // every mounted copy of the panel, so the table itself is the test seam.
15089
+ noticeIsOpen: noticeIsOpen,
15090
+ dismissNotice: dismissNotice,
15091
+ __resetNoticeDismissals: function () {
15092
+ NOTICE_DISMISSALS = {}
15093
+ NOTICE_DISMISSAL_LISTENERS.forEach(function (listener) { listener() })
15094
+ },
14788
15095
  treeLabel: treeLabel,
14789
15096
  childEntryFor: childEntryFor,
14790
15097
  pathWithin: pathWithin,