mbeditor 0.14.2 → 0.14.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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/app/assets/javascripts/mbeditor/application.js +5 -1
  4. data/app/assets/javascripts/mbeditor/collaboration_identity.js +4 -2
  5. data/app/assets/javascripts/mbeditor/collaboration_service.js +74 -2
  6. data/app/assets/javascripts/mbeditor/components/AiRoundTripModal.js +452 -0
  7. data/app/assets/javascripts/mbeditor/components/ChangelogView.js +1 -1
  8. data/app/assets/javascripts/mbeditor/components/CombinedFileView.js +3 -2
  9. data/app/assets/javascripts/mbeditor/components/EditorPanel.js +28 -27
  10. data/app/assets/javascripts/mbeditor/components/FileHistoryPanel.js +2 -7
  11. data/app/assets/javascripts/mbeditor/components/FileTree.js +144 -4
  12. data/app/assets/javascripts/mbeditor/components/GitPanel.js +1 -1
  13. data/app/assets/javascripts/mbeditor/components/ImportConflictModal.js +7 -68
  14. data/app/assets/javascripts/mbeditor/components/ImportDialog.js +2 -16
  15. data/app/assets/javascripts/mbeditor/components/MbeditorApp.js +340 -472
  16. data/app/assets/javascripts/mbeditor/components/ModalDialog.js +203 -0
  17. data/app/assets/javascripts/mbeditor/components/PastePlaceModal.js +1 -9
  18. data/app/assets/javascripts/mbeditor/components/Popover.js +88 -0
  19. data/app/assets/javascripts/mbeditor/components/PopupMenu.js +166 -0
  20. data/app/assets/javascripts/mbeditor/components/ProblemsPanel.js +8 -4
  21. data/app/assets/javascripts/mbeditor/components/QuickOpenDialog.js +5 -7
  22. data/app/assets/javascripts/mbeditor/components/SettingsModal.js +3 -14
  23. data/app/assets/javascripts/mbeditor/components/ShortcutHelp.js +4 -25
  24. data/app/assets/javascripts/mbeditor/components/TabBar.js +15 -32
  25. data/app/assets/javascripts/mbeditor/components/TestResultsPanel.js +2 -7
  26. data/app/assets/javascripts/mbeditor/editor_plugins.js +3 -23
  27. data/app/assets/javascripts/mbeditor/file_service.js +1 -1
  28. data/app/assets/javascripts/mbeditor/git_service.js +0 -7
  29. data/app/assets/javascripts/mbeditor/patch_select.js +156 -0
  30. data/app/assets/javascripts/mbeditor/tab_manager.js +19 -0
  31. data/app/assets/stylesheets/mbeditor/application.css +7 -110
  32. data/app/assets/stylesheets/mbeditor/editor.css +195 -192
  33. data/app/assets/stylesheets/mbeditor/glass.css +1 -1
  34. data/app/channels/mbeditor/collaboration_channel.rb +24 -5
  35. data/app/controllers/mbeditor/editors_controller.rb +75 -38
  36. data/app/controllers/mbeditor/git_controller.rb +1 -12
  37. data/app/services/mbeditor/ai_bundle_service.rb +181 -0
  38. data/app/services/mbeditor/archive_service.rb +43 -6
  39. data/app/services/mbeditor/availability_probe.rb +2 -2
  40. data/app/services/mbeditor/code_search_service.rb +1 -3
  41. data/app/services/mbeditor/collaboration_doc_store.rb +37 -1
  42. data/app/services/mbeditor/exclusion_matcher.rb +0 -4
  43. data/app/services/mbeditor/file_import_service.rb +4 -1
  44. data/app/services/mbeditor/file_operation_service.rb +3 -3
  45. data/app/services/mbeditor/git_service.rb +11 -45
  46. data/app/services/mbeditor/js_definition_service.rb +1 -0
  47. data/app/services/mbeditor/model_graph_service.rb +1 -0
  48. data/app/services/mbeditor/patch_apply_service.rb +185 -0
  49. data/app/services/mbeditor/rails_related_files_service.rb +1 -1
  50. data/app/services/mbeditor/redmine_config_error.rb +6 -0
  51. data/app/services/mbeditor/redmine_disabled_error.rb +10 -0
  52. data/app/services/mbeditor/redmine_service.rb +0 -8
  53. data/app/services/mbeditor/ruby_definition_service.rb +1 -0
  54. data/app/services/mbeditor/schema_service.rb +1 -0
  55. data/app/services/mbeditor/test_runner_service.rb +1 -1
  56. data/lib/mbeditor/rack/silence_ping_request.rb +14 -14
  57. data/lib/mbeditor/route_map.rb +5 -2
  58. data/lib/mbeditor/ruby_lsp_client.rb +7 -26
  59. data/lib/mbeditor/version.rb +1 -1
  60. data/public/monaco-editor/VERSIONS +2 -1
  61. data/public/monaco-editor/monaco.js +226 -226
  62. metadata +11 -4
  63. data/app/assets/javascripts/mbeditor/components/CommitGraph.js +0 -65
  64. data/app/services/mbeditor/git_commit_graph_service.rb +0 -62
@@ -64,8 +64,6 @@ var PRETTIER_PARSERS = {
64
64
  html: 'html', vue: 'vue',
65
65
  md: 'markdown', markdown: 'markdown'
66
66
  };
67
- var SUPPORTED_PRETTIER_EXTS = Object.keys(PRETTIER_PARSERS);
68
-
69
67
  function prettierParserFor(path) {
70
68
  return PRETTIER_PARSERS[String(path || '').split('.').pop().toLowerCase()] || null;
71
69
  }
@@ -438,22 +436,6 @@ var MbeditorApp = function MbeditorApp() {
438
436
  var historyPanelPath = _useState21[0];
439
437
  var setHistoryPanelPath = _useState21[1];
440
438
 
441
- var _useState23 = useState(false);
442
- var isNavigating = _useState23[0];
443
- var setIsNavigating = _useState23[1];
444
-
445
- var _useState25 = useState(false);
446
- var isReviewOpen = _useState25[0];
447
- var setIsReviewOpen = _useState25[1];
448
-
449
- var _useState27 = useState(null);
450
- var selectedCommit = _useState27[0];
451
- var setSelectedCommit = _useState27[1];
452
-
453
- var _useState29 = useState(null);
454
- var commitDetailFiles = _useState29[0];
455
- var setCommitDetailFiles = _useState29[1];
456
-
457
439
  var _useStateCFI = useState(0);
458
440
  var conflictFileIndex = _useStateCFI[0];
459
441
  var setConflictFileIndex = _useStateCFI[1];
@@ -633,6 +615,9 @@ var MbeditorApp = function MbeditorApp() {
633
615
  var setImportConflict = _useStateImportConflict[1];
634
616
 
635
617
  // { initialFolder } while the upload dialog is open, null otherwise.
618
+ var _useStateAiModal = useState(false);
619
+ var showAiModal = _useStateAiModal[0];
620
+ var setShowAiModal = _useStateAiModal[1];
636
621
  var _useStateImportDialog = useState(null);
637
622
  var importDialog = _useStateImportDialog[0];
638
623
  var setImportDialog = _useStateImportDialog[1];
@@ -1269,9 +1254,7 @@ var MbeditorApp = function MbeditorApp() {
1269
1254
  });
1270
1255
  };
1271
1256
 
1272
- var runRubyLint = function runRubyLint(tab, paneId) {
1273
- var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
1274
-
1257
+ var runRubyLint = function runRubyLint(tab) {
1275
1258
  if (!tab || (!isRubyPath(tab.path) && !tab.path.endsWith('.haml'))) return Promise.resolve(null);
1276
1259
 
1277
1260
  // An empty buffer has no offenses, and answering that here rather than over
@@ -1284,19 +1267,9 @@ var MbeditorApp = function MbeditorApp() {
1284
1267
  // its squiggles.
1285
1268
  if (!String(tab.content || '').trim()) {
1286
1269
  applyMarkersForTab(tab.id, []);
1287
- if (options.showStatus) EditorStore.setStatus('No RuboCop offenses!', 'success');
1288
1270
  return Promise.resolve({ markers: [] });
1289
1271
  }
1290
1272
 
1291
- if (options.showLoading) {
1292
- setLoading(function (prev) {
1293
- return _extends({}, prev, { lint: true });
1294
- });
1295
- }
1296
- if (options.showStatus) {
1297
- EditorStore.setStatus('Linting...', 'info');
1298
- }
1299
-
1300
1273
  var startedAt = Date.now();
1301
1274
 
1302
1275
  // ruby-lsp answers diagnostics for Ruby files when it's available: same
@@ -1325,35 +1298,21 @@ var MbeditorApp = function MbeditorApp() {
1325
1298
  if (audit) audit.rec(audit.EV.LINT, _auditExt(tab.path), Date.now() - startedAt, nextMarkers.length);
1326
1299
  applyMarkersForTab(tab.id, nextMarkers);
1327
1300
 
1328
- if (options.showStatus) {
1329
- var count = res.summary && res.summary.offense_count || 0;
1330
- EditorStore.setStatus(count === 0 ? 'No RuboCop offenses!' : "Found " + count + " offenses", count === 0 ? 'success' : 'warning');
1331
- }
1332
-
1333
1301
  return res;
1334
- })["catch"](function (err) {
1302
+ })["catch"](function () {
1335
1303
  _recErr('LINT');
1336
- if (options.showStatus) {
1337
- EditorStore.setStatus('Lint failed: ' + err.message, 'error');
1338
- }
1339
1304
  return null;
1340
- })["finally"](function () {
1341
- if (options.showLoading) {
1342
- setLoading(function (prev) {
1343
- return _extends({}, prev, { lint: false });
1344
- });
1345
- }
1346
1305
  });
1347
1306
  };
1348
1307
 
1349
- var _debouncedAutoLint = useRef(window._.debounce(function (tab, paneId) {
1308
+ var _debouncedAutoLint = useRef(window._.debounce(function (tab) {
1350
1309
  if (!tab) return;
1351
1310
  if (isRubyPath(tab.path)) {
1352
- runRubyLint(tab, paneId);
1311
+ runRubyLint(tab);
1353
1312
  return;
1354
1313
  }
1355
1314
  if (tab.path.endsWith('.haml')) {
1356
- runRubyLint(tab, paneId);
1315
+ runRubyLint(tab);
1357
1316
  return;
1358
1317
  }
1359
1318
 
@@ -1696,10 +1655,12 @@ var MbeditorApp = function MbeditorApp() {
1696
1655
  setShowLogPanel(function (prev) { return !prev; });
1697
1656
  }
1698
1657
  // Ctrl+Shift+Z is handled in capture phase below so Monaco cannot swallow it.
1658
+ // The context menu closes itself on Esc now (popover light dismiss).
1659
+ // setCollabOverflowOpen, called here before, never existed: every Esc
1660
+ // threw a ReferenceError after the setters above had run.
1699
1661
  if (e.key === 'Escape') {
1700
- setContextMenu(null);
1701
1662
  setShowHelp(false);
1702
- setCollabOverflowOpen(false);
1663
+ setCollabOverflowAnchor(null);
1703
1664
  }
1704
1665
  };
1705
1666
 
@@ -1846,7 +1807,7 @@ var MbeditorApp = function MbeditorApp() {
1846
1807
  // Already in a Monaco editor — let Monaco's own binding handle it.
1847
1808
  if (ae.closest('.monaco-editor')) return;
1848
1809
  // Don't hijack Find while typing in another input region.
1849
- if (ae.closest('.ide-sidebar, .git-panel, .quick-open-overlay, .schema-modal, input, textarea, [contenteditable="true"]')) return;
1810
+ if (ae.closest('.ide-sidebar, .git-panel, dialog, input, textarea, [contenteditable="true"]')) return;
1850
1811
  }
1851
1812
  e.preventDefault();
1852
1813
  e.stopPropagation();
@@ -2089,40 +2050,53 @@ var MbeditorApp = function MbeditorApp() {
2089
2050
  // still deferring, or degraded to local, holds its own buffer — a peer save
2090
2051
  // is an external change for it, handled by the files_changed path.
2091
2052
  if (typeof CollaborationService === 'undefined' || !CollaborationService.isAttached(path)) return;
2092
-
2093
- var st = EditorStore.getState();
2094
- var changed = false;
2095
- var newPanes = st.panes.map(function (p) {
2096
- return Object.assign({}, p, {
2097
- tabs: p.tabs.map(function (t) {
2098
- if (t.path !== path || !t.dirty) return t;
2099
- changed = true;
2100
- return Object.assign({}, t, { dirty: false, cleanContent: t.content });
2101
- })
2102
- });
2103
- });
2104
- if (changed) EditorStore.setState({ panes: newPanes });
2105
-
2106
- // The CRDT kept our buffer identical to what the peer just wrote, so the
2107
- // buffer is the new on-disk truth — refresh the external-change baseline.
2108
- var _savedTab = null;
2109
- newPanes.forEach(function (p) {
2110
- p.tabs.forEach(function (t) { if (t.path === path) _savedTab = t; });
2111
- });
2112
- if (_savedTab && typeof _savedTab.content === 'string') {
2113
- lastDiskContentRef.current[path] = _savedTab.content.replace(/\r\n/g, '\n');
2114
- }
2115
-
2116
- // Reset the AVI clean baseline so undo past this peer's save shows dirty correctly.
2117
- var _modelEntry = window.__mbeditorModels && window.__mbeditorModels[path];
2118
- if (_modelEntry && _modelEntry.model && !_modelEntry.model.isDisposed()) {
2119
- _modelEntry.cleanVersionId = _modelEntry.model.getAlternativeVersionId();
2120
- }
2053
+ markCollabTabsClean(path);
2121
2054
  }
2122
2055
  WebSocketService.onFileSaved(handleFileSaved);
2123
2056
  return function () { WebSocketService.offFileSaved(handleFileSaved); };
2124
2057
  }, []);
2125
2058
 
2059
+ // An attached tab's buffer now equals disk (a peer saved it, or an external
2060
+ // write converged through the shared doc): clear dirty, rebaseline. content,
2061
+ // when given, is the new disk text and replaces tab.content, which lags the
2062
+ // model by the 250 ms content sync and is never synced for a background tab.
2063
+ function markCollabTabsClean(path, content) {
2064
+ var st = EditorStore.getState();
2065
+ var changed = false;
2066
+ var newPanes = st.panes.map(function (p) {
2067
+ return Object.assign({}, p, {
2068
+ tabs: p.tabs.map(function (t) {
2069
+ if (t.path !== path) return t;
2070
+ var next = typeof content === 'string' ? content : t.content;
2071
+ if (!t.dirty && t.content === next) return t;
2072
+ changed = true;
2073
+ return Object.assign({}, t, { dirty: false, content: next, cleanContent: next });
2074
+ })
2075
+ });
2076
+ });
2077
+ // The banner asked about disk content the buffer now holds.
2078
+ var reloads = st.pendingReloads || [];
2079
+ var keptReloads = reloads.filter(function (r) { return r.path !== path; });
2080
+ var update = {};
2081
+ if (changed) update.panes = newPanes;
2082
+ if (keptReloads.length !== reloads.length) update.pendingReloads = keptReloads;
2083
+ if (update.panes || update.pendingReloads) EditorStore.setState(update);
2084
+
2085
+ var _savedTab = null;
2086
+ newPanes.forEach(function (p) {
2087
+ p.tabs.forEach(function (t) { if (t.path === path) _savedTab = t; });
2088
+ });
2089
+ if (_savedTab && typeof _savedTab.content === 'string') {
2090
+ lastDiskContentRef.current[path] = _savedTab.content.replace(/\r\n/g, '\n');
2091
+ }
2092
+
2093
+ // Reset the AVI clean baseline so undo past this point shows dirty correctly.
2094
+ var _modelEntry = window.__mbeditorModels && window.__mbeditorModels[path];
2095
+ if (_modelEntry && _modelEntry.model && !_modelEntry.model.isDisposed()) {
2096
+ _modelEntry.cleanVersionId = _modelEntry.model.getAlternativeVersionId();
2097
+ }
2098
+ }
2099
+
2126
2100
  // onlyPaths: when the trigger names the files that changed (the
2127
2101
  // files_changed push always does — it only ever announces mbeditor's own
2128
2102
  // writes), restrict the check to open tabs on those paths. The old
@@ -2157,16 +2131,6 @@ var MbeditorApp = function MbeditorApp() {
2157
2131
  fileTabs.forEach(function (pt) {
2158
2132
  var savedAt = recentSavesRef.current[pt.tab.path];
2159
2133
  if (savedAt && Date.now() - savedAt < 3000) return;
2160
- // A collaboratively-bound file's live buffer is the shared CRDT, kept
2161
- // converged across peers and reconciled with disk on save (file_saved).
2162
- // Re-applying an external on-disk snapshot over it would silently clobber
2163
- // everyone's shared state, so skip detection here — the CRDT is authoritative
2164
- // while peers are editing. Intentional local edits (Format/Load) still flow
2165
- // through the binding and are unaffected.
2166
- if (typeof CollaborationService !== 'undefined' &&
2167
- CollaborationService.isAttached(pt.tab.path)) {
2168
- return;
2169
- }
2170
2134
  FileService.getFile(pt.tab.path, { allowMissing: true }).then(function (data) {
2171
2135
  if (!data || typeof data.content !== 'string') return;
2172
2136
  // Re-read the tab: the snapshot above predates the fetch, and edits or
@@ -2180,7 +2144,18 @@ var MbeditorApp = function MbeditorApp() {
2180
2144
  if (savedAgain && Date.now() - savedAgain < 3000) return;
2181
2145
  pt = { paneId: pt.paneId, tab: liveTab };
2182
2146
  var serverNorm = data.content.replace(/\r\n/g, '\n');
2183
- var tabNorm = (pt.tab.content || '').replace(/\r\n/g, '\n');
2147
+ // An attached tab's buffer is the shared doc, which a peer may have
2148
+ // changed without this tab's content catching up; read the model.
2149
+ var attached = typeof CollaborationService !== 'undefined' &&
2150
+ CollaborationService.isAttached(pt.tab.path);
2151
+ var _m = attached && window.__mbeditorModels && window.__mbeditorModels[pt.tab.path];
2152
+ var liveText = _m && _m.model && !_m.model.isDisposed() ? _m.model.getValue() : pt.tab.content;
2153
+ var tabNorm = (liveText || '').replace(/\r\n/g, '\n');
2154
+ if (attached && serverNorm === tabNorm) {
2155
+ // The shared doc already carries the write (another client applied it).
2156
+ markCollabTabsClean(pt.tab.path, data.content);
2157
+ return;
2158
+ }
2184
2159
 
2185
2160
  // Did the file on disk actually change? Compare disk against the last
2186
2161
  // disk content we saw, never against the buffer — a dirty buffer
@@ -2192,11 +2167,27 @@ var MbeditorApp = function MbeditorApp() {
2192
2167
  var prevDisk = lastDiskContentRef.current[pt.tab.path];
2193
2168
  lastDiskContentRef.current[pt.tab.path] = serverNorm;
2194
2169
  if (serverNorm === tabNorm) return;
2195
- if (prevDisk === undefined && pt.tab.dirty) return;
2170
+ // An attached tab's dirty flag only moves while its editor is mounted,
2171
+ // so peer edits to a background tab leave it "clean". Unsaved shared
2172
+ // edits are the text differing from the last disk content we know.
2173
+ var dirty = pt.tab.dirty;
2174
+ if (attached && !dirty) {
2175
+ dirty = tabNorm !== (prevDisk !== undefined ? prevDisk : (pt.tab.content || '').replace(/\r\n/g, '\n'));
2176
+ }
2177
+ if (prevDisk === undefined && dirty && !attached) return;
2196
2178
  if (prevDisk === undefined) prevDisk = tabNorm;
2197
2179
  if (serverNorm === prevDisk) return;
2198
2180
 
2199
- if (!pt.tab.dirty) {
2181
+ if (!dirty && attached) {
2182
+ // Never set the tab content here: EditorPanel would push the whole
2183
+ // file through the binding on every client and duplicate it. The
2184
+ // baseline only advances once the shared doc converges, so a write
2185
+ // that never lands is retried by the next check.
2186
+ lastDiskContentRef.current[pt.tab.path] = prevDisk;
2187
+ CollaborationService.applyDiskContent(pt.tab.path, data.content, function () {
2188
+ markCollabTabsClean(pt.tab.path, data.content);
2189
+ });
2190
+ } else if (!dirty) {
2200
2191
  EditorStore.setState({
2201
2192
  panes: EditorStore.getState().panes.map(function (p) {
2202
2193
  if (p.id !== pt.paneId) return p;
@@ -2237,6 +2228,11 @@ var MbeditorApp = function MbeditorApp() {
2237
2228
  serverContent: data.content
2238
2229
  }])
2239
2230
  });
2231
+ if (attached) {
2232
+ CollaborationService.whenContentMatches(pt.tab.path, data.content, function () {
2233
+ markCollabTabsClean(pt.tab.path, data.content);
2234
+ });
2235
+ }
2240
2236
  }
2241
2237
  }
2242
2238
  })["catch"](function () {});
@@ -2292,7 +2288,13 @@ var MbeditorApp = function MbeditorApp() {
2292
2288
  GitService.fetchStatus()["catch"](function () {});
2293
2289
  };
2294
2290
  var intervalId = setInterval(refresh, 5000);
2295
- var onVisible = function () { if (!document.hidden) fullRefresh(); };
2291
+ // files_changed pushes are dropped while hidden, so catch the open tabs up
2292
+ // here. The check writes state only for a tab whose disk content moved.
2293
+ var onVisible = function () {
2294
+ if (document.hidden) return;
2295
+ fullRefresh();
2296
+ checkOpenTabsForExternalChanges();
2297
+ };
2296
2298
  document.addEventListener('visibilitychange', onVisible);
2297
2299
  window.addEventListener('focus', fullRefresh);
2298
2300
  return function () {
@@ -2474,10 +2476,15 @@ var MbeditorApp = function MbeditorApp() {
2474
2476
  return tab.dirty;
2475
2477
  }).length;
2476
2478
 
2477
- if (dirtyCount === 0) return true;
2479
+ if (dirtyCount === 0) return Promise.resolve(true);
2478
2480
 
2479
2481
  var dirtyLabel = dirtyCount === 1 ? "1 unsaved editor has changes." : dirtyCount + " unsaved editors have changes.";
2480
- return window.confirm(dirtyLabel + " Close " + scopeLabel + " without saving?");
2482
+ return window.MbeditorDialogs.confirm({
2483
+ title: "Close " + scopeLabel + "?",
2484
+ message: dirtyLabel + " Their changes will be lost.",
2485
+ confirmLabel: "Close without saving",
2486
+ danger: true
2487
+ });
2481
2488
  };
2482
2489
 
2483
2490
  var handleCloseAllEditors = function handleCloseAllEditors() {
@@ -2485,13 +2492,14 @@ var MbeditorApp = function MbeditorApp() {
2485
2492
  return pane.tabs;
2486
2493
  });
2487
2494
  if (allTabs.length === 0) return;
2488
- if (!confirmBulkClose(allTabs, "all editors")) return;
2489
-
2490
- TabManager.closeAllTabs();
2491
- forgetClosedTabs();
2492
- setClosingTabId(null);
2493
- setClosingPaneId(null);
2494
- EditorStore.setStatus("Closed " + allTabs.length + " editor" + (allTabs.length === 1 ? "" : "s"), "info");
2495
+ confirmBulkClose(allTabs, "all editors").then(function (ok) {
2496
+ if (!ok) return;
2497
+ TabManager.closeAllTabs();
2498
+ forgetClosedTabs();
2499
+ setClosingTabId(null);
2500
+ setClosingPaneId(null);
2501
+ EditorStore.setStatus("Closed " + allTabs.length + " editor" + (allTabs.length === 1 ? "" : "s"), "info");
2502
+ });
2495
2503
  };
2496
2504
 
2497
2505
  var handleCloseEditorsInGroup = function handleCloseEditorsInGroup(paneId) {
@@ -2499,13 +2507,14 @@ var MbeditorApp = function MbeditorApp() {
2499
2507
  return p.id === paneId;
2500
2508
  });
2501
2509
  if (!pane || pane.tabs.length === 0) return;
2502
- if (!confirmBulkClose(pane.tabs, "all editors in Group " + paneId)) return;
2503
-
2504
- TabManager.closeAllTabsInPane(paneId);
2505
- forgetClosedTabs();
2506
- setClosingTabId(null);
2507
- setClosingPaneId(null);
2508
- EditorStore.setStatus("Closed " + pane.tabs.length + " editor" + (pane.tabs.length === 1 ? "" : "s") + " in Group " + paneId, "info");
2510
+ confirmBulkClose(pane.tabs, "all editors in Group " + paneId).then(function (ok) {
2511
+ if (!ok) return;
2512
+ TabManager.closeAllTabsInPane(paneId);
2513
+ forgetClosedTabs();
2514
+ setClosingTabId(null);
2515
+ setClosingPaneId(null);
2516
+ EditorStore.setStatus("Closed " + pane.tabs.length + " editor" + (pane.tabs.length === 1 ? "" : "s") + " in Group " + paneId, "info");
2517
+ });
2509
2518
  };
2510
2519
 
2511
2520
  var handleCloseOtherTabs = function handleCloseOtherTabs(paneId, keepId) {
@@ -2513,10 +2522,12 @@ var MbeditorApp = function MbeditorApp() {
2513
2522
  if (!pane) return;
2514
2523
  var others = pane.tabs.filter(function (t) { return t.id !== keepId; });
2515
2524
  if (others.length === 0) return;
2516
- if (!confirmBulkClose(others, "other editors")) return;
2517
- TabManager.closeOtherTabsInPane(paneId, keepId);
2518
- forgetClosedTabs();
2519
- EditorStore.setStatus("Closed " + others.length + " editor" + (others.length === 1 ? "" : "s"), "info");
2525
+ confirmBulkClose(others, "other editors").then(function (ok) {
2526
+ if (!ok) return;
2527
+ TabManager.closeOtherTabsInPane(paneId, keepId);
2528
+ forgetClosedTabs();
2529
+ EditorStore.setStatus("Closed " + others.length + " editor" + (others.length === 1 ? "" : "s"), "info");
2530
+ });
2520
2531
  };
2521
2532
 
2522
2533
  var handleCloseSavedTabs = function handleCloseSavedTabs(paneId) {
@@ -2534,9 +2545,18 @@ var MbeditorApp = function MbeditorApp() {
2534
2545
  // Returns a promise that rejects with {cancelled: true} when the user backs
2535
2546
  // out, so close-flows can abort instead of discarding.
2536
2547
  var saveUntitledTab = function saveUntitledTab(paneId, tab, opts) {
2537
- var input = window.prompt('Save as (path relative to workspace root):', tab.name + '.txt');
2538
- if (!input || !input.trim()) return Promise.reject({ cancelled: true });
2539
- var newPath = input.trim().replace(/^\/+/, '');
2548
+ return window.MbeditorDialogs.prompt({
2549
+ title: 'Save as',
2550
+ message: 'Path relative to the workspace root:',
2551
+ value: tab.name + '.txt',
2552
+ confirmLabel: 'Save'
2553
+ }).then(function (input) {
2554
+ if (!input || !input.trim()) return Promise.reject({ cancelled: true });
2555
+ return writeUntitledTab(paneId, tab, opts, input.trim().replace(/^\/+/, ''));
2556
+ });
2557
+ };
2558
+
2559
+ var writeUntitledTab = function writeUntitledTab(paneId, tab, opts, newPath) {
2540
2560
  var startedAt = Date.now();
2541
2561
  return FileService.saveFile(newPath, tab.content).then(function () {
2542
2562
  var audit = window.MbeditorAudit;
@@ -2710,6 +2730,7 @@ var MbeditorApp = function MbeditorApp() {
2710
2730
  };
2711
2731
 
2712
2732
  var RAILS_MAX_RESOURCES = 10;
2733
+ var RAILS_CONVENTION_PATH = /^(app\/(controllers|models|views|helpers)|test|spec)\//;
2713
2734
 
2714
2735
  // Map resource label → representative path (capped at RAILS_MAX_RESOURCES, focused pane first)
2715
2736
  // Memoised: all three of these walk every tab in every pane and were rebuilt
@@ -2725,15 +2746,21 @@ var MbeditorApp = function MbeditorApp() {
2725
2746
  return a.id === p.activeTabId ? -1 : b.id === p.activeTabId ? 1 : 0;
2726
2747
  });
2727
2748
  tabs.forEach(function(t) {
2728
- if (Object.keys(deps).length >= RAILS_MAX_RESOURCES) return;
2729
2749
  if (!t.path || t.path.startsWith('mbeditor://')) return;
2730
2750
  var label = resourceLabelFromPath(t.path);
2731
- if (label && !deps[label]) deps[label] = t.path;
2751
+ if (!label) return;
2752
+ if (!deps[label]) {
2753
+ if (Object.keys(deps).length < RAILS_MAX_RESOURCES) deps[label] = t.path;
2754
+ } else if (!RAILS_CONVENTION_PATH.test(deps[label]) && RAILS_CONVENTION_PATH.test(t.path)) {
2755
+ // A custom-path file's lookup returns only its custom group; a
2756
+ // conventional file's returns controller, model, views and custom.
2757
+ deps[label] = t.path;
2758
+ }
2732
2759
  });
2733
2760
  });
2734
2761
  return deps;
2735
2762
  }, [state.panes, state.focusedPaneId, customPaths]);
2736
- var railsResourceDepStr = Object.keys(railsResourceDeps).sort().join('|');
2763
+ var railsResourceDepStr = Object.keys(railsResourceDeps).sort().map(function(k) { return k + '=' + railsResourceDeps[k]; }).join('|');
2737
2764
 
2738
2765
  var railsOverflow = useMemo(function() {
2739
2766
  var all = {};
@@ -2757,6 +2784,14 @@ var MbeditorApp = function MbeditorApp() {
2757
2784
  return set;
2758
2785
  }, [state.panes]);
2759
2786
 
2787
+ var openPaths = useMemo(function() {
2788
+ var set = {};
2789
+ state.panes.forEach(function(p) {
2790
+ p.tabs.forEach(function(t) { if (t.path) set[t.path] = true; });
2791
+ });
2792
+ return set;
2793
+ }, [state.panes]);
2794
+
2760
2795
  useEffect(function() {
2761
2796
  if (activeSidebarTab !== 'rails') return;
2762
2797
  var labels = Object.keys(railsResourceDeps);
@@ -2804,7 +2839,7 @@ var MbeditorApp = function MbeditorApp() {
2804
2839
  var _presenceFileFor = function (tab) {
2805
2840
  if (!tab || !tab.path) return null;
2806
2841
  var p = tab.path;
2807
- if (tab.isDiff || tab.isCombinedDiff || tab.isCommitGraph || tab.isPreview || tab.isChangelog || tab.isCombinedView) return null;
2842
+ if (tab.isDiff || tab.isCombinedDiff || tab.isPreview || tab.isChangelog || tab.isCombinedView) return null;
2808
2843
  if (p.indexOf('diff://') === 0 || p.indexOf('combined-diff://') === 0 || p.indexOf('mbeditor://') === 0) return null;
2809
2844
  if (p.indexOf('::preview') !== -1) return null;
2810
2845
  return p;
@@ -3096,9 +3131,9 @@ var MbeditorApp = function MbeditorApp() {
3096
3131
  // the popover — so the close is delayed and cancelled by either one's
3097
3132
  // onMouseEnter. Click still toggles it directly, which is what makes it
3098
3133
  // reachable without a mouse at all.
3099
- // The anchor, not a boolean: the popover renders at the root next to the
3100
- // hovercard, because an absolutely-positioned child of the title bar is
3101
- // painted under the editor whatever its z-index.
3134
+ // The anchor, not a boolean: it is positioned from the button's rect. It
3135
+ // renders as a manual popover (top layer) — as an ordinary child of the
3136
+ // title bar it was painted under the editor whatever its z-index.
3102
3137
  var _useStateOverflow = useState(null);
3103
3138
  var collabOverflowAnchor = _useStateOverflow[0];
3104
3139
  var setCollabOverflowAnchor = _useStateOverflow[1];
@@ -3130,7 +3165,7 @@ var MbeditorApp = function MbeditorApp() {
3130
3165
  var setActiveEOL = _useState31e[1];
3131
3166
 
3132
3167
  useEffect(function () {
3133
- if (!gitAvailable || !activeTab || activeTab.isDiff || activeTab.isCombinedDiff || activeTab.isCombinedView || activeTab.isCommitGraph || !activeTab.path || activeTab.path.indexOf('://') >= 0) {
3168
+ if (!gitAvailable || !activeTab || activeTab.isDiff || activeTab.isCombinedDiff || activeTab.isCombinedView || !activeTab.path || activeTab.path.indexOf('://') >= 0) {
3134
3169
  setActiveFileCommit(null);
3135
3170
  return;
3136
3171
  }
@@ -3152,7 +3187,7 @@ var MbeditorApp = function MbeditorApp() {
3152
3187
  // buffer for '\r' there was pure waste — typing cannot change the line ending.
3153
3188
  useEffect(function () {
3154
3189
  if (!activeTab || typeof activeTab.content !== 'string' ||
3155
- activeTab.isDiff || activeTab.isCombinedDiff || activeTab.isCombinedView || activeTab.isCommitGraph || activeTab.isPreview) {
3190
+ activeTab.isDiff || activeTab.isCombinedDiff || activeTab.isCombinedView || activeTab.isPreview) {
3156
3191
  setActiveEOL(null);
3157
3192
  return;
3158
3193
  }
@@ -3167,7 +3202,7 @@ var MbeditorApp = function MbeditorApp() {
3167
3202
 
3168
3203
  useEffect(function () {
3169
3204
  if (!activeTab || typeof activeTab.content !== 'string') return;
3170
- if (activeTab.isDiff || activeTab.isCombinedDiff || activeTab.isCombinedView || activeTab.isCommitGraph) return;
3205
+ if (activeTab.isDiff || activeTab.isCombinedDiff || activeTab.isCombinedView) return;
3171
3206
  if (isRubyPath(activeTab.path) && !rubocopAvailable) return;
3172
3207
  if (activeTab.path.endsWith('.haml') && !hamlLintAvailable) return;
3173
3208
 
@@ -3177,63 +3212,13 @@ var MbeditorApp = function MbeditorApp() {
3177
3212
  return;
3178
3213
  }
3179
3214
 
3180
- _debouncedAutoLint(activeTab, focusedPane ? focusedPane.id : null);
3215
+ _debouncedAutoLint(activeTab);
3181
3216
 
3182
3217
  return function () {
3183
3218
  _debouncedAutoLint.cancel();
3184
3219
  };
3185
3220
  }, [focusedPane ? focusedPane.id : null, activeTab ? activeTab.id : null, activeTab ? activeTab.content : null, rubocopAvailable, hamlLintAvailable, editorPrefs.rubocopLintEnabled]);
3186
3221
 
3187
- var handleOpenCommitGraph = function handleOpenCommitGraph() {
3188
- var paneId = state.focusedPaneId || 1;
3189
- var tabId = 'mbeditor://commit-graph';
3190
-
3191
- var pane = state.panes.find(function(p) { return p.id === paneId; });
3192
- var existing = pane && pane.tabs.find(function(t) { return t.id === tabId; });
3193
- if (existing) {
3194
- TabManager.switchTab(paneId, tabId);
3195
- return;
3196
- }
3197
-
3198
- var newTab = {
3199
- id: tabId,
3200
- path: tabId,
3201
- name: 'Commit Graph',
3202
- dirty: false,
3203
- content: '', // not used
3204
- isCommitGraph: true
3205
- };
3206
-
3207
- var newPanes = state.panes.map(function(p) {
3208
- if (p.id === paneId) {
3209
- return Object.assign({}, p, { tabs: p.tabs.concat(newTab), activeTabId: tabId });
3210
- }
3211
- return p;
3212
- });
3213
-
3214
- EditorStore.setState({ panes: newPanes, focusedPaneId: paneId, activeTabId: tabId });
3215
-
3216
- // Fetch data asynchronously
3217
- GitService.fetchCommitGraph().then(function(data) {
3218
- var s = EditorStore.getState();
3219
- var p = s.panes.find(function(p) { return p.id === paneId; });
3220
- if (!p) return;
3221
- var t = p.tabs.find(function(t) { return t.id === tabId; });
3222
- if (t) {
3223
- var newPanes2 = s.panes.map(function(p2) {
3224
- if (p2.id === paneId) {
3225
- var newTabs = p2.tabs.map(function(t2) {
3226
- return t2.id === tabId ? Object.assign({}, t2, { commits: data.commits }) : t2;
3227
- });
3228
- return Object.assign({}, p2, { tabs: newTabs });
3229
- }
3230
- return p2;
3231
- });
3232
- EditorStore.setState({ panes: newPanes2 });
3233
- }
3234
- });
3235
- };
3236
-
3237
3222
  // Format-on-save helper: returns a Promise resolving to the formatted
3238
3223
  // content, or null when no formatter applies / formatting fails (the save
3239
3224
  // then proceeds with the original content — saving must never be blocked
@@ -3451,6 +3436,14 @@ var MbeditorApp = function MbeditorApp() {
3451
3436
  }
3452
3437
 
3453
3438
  function handleDiscardAndReload(reload) {
3439
+ // Every peer sees this banner; see applyDiskContent for why only one may write.
3440
+ if (typeof CollaborationService !== 'undefined' && CollaborationService.applyDiskContent(
3441
+ reload.path, reload.serverContent,
3442
+ function () { markCollabTabsClean(reload.path, reload.serverContent); }
3443
+ )) {
3444
+ dismissPendingReload(reload);
3445
+ return;
3446
+ }
3454
3447
  EditorStore.setState({
3455
3448
  panes: EditorStore.getState().panes.map(function (p) {
3456
3449
  if (p.id !== reload.paneId) return p;
@@ -3507,7 +3500,7 @@ var MbeditorApp = function MbeditorApp() {
3507
3500
  });
3508
3501
  });
3509
3502
  Promise.allSettled(promises).then(function (results) {
3510
- var saved = dirtyTabs.filter(function (tab, i) { return results[i].status === "fulfilled"; });
3503
+ var saved = dirtyTabs.filter(function (_tab, i) { return results[i].status === "fulfilled"; });
3511
3504
  // Object.create(null): these keys are file paths, and a file called
3512
3505
  // "constructor" would otherwise test as present against Object.prototype
3513
3506
  // and have its tab marked clean without ever being written.
@@ -3607,7 +3600,7 @@ var MbeditorApp = function MbeditorApp() {
3607
3600
  setTreeData(_treeUpdater(data || []));
3608
3601
  checkOpenTabsForExternalChanges();
3609
3602
  EditorStore.setStatus("Workspace refreshed", "success");
3610
- })["catch"](function (err) {
3603
+ })["catch"](function () {
3611
3604
  EditorStore.setStatus("Failed to refresh workspace", "error");
3612
3605
  })["finally"](function () {
3613
3606
  setLoading(function (prev) {
@@ -3988,11 +3981,6 @@ var MbeditorApp = function MbeditorApp() {
3988
3981
  EditorStore.setState({ searchResults: [], searchHasMore: false });
3989
3982
  };
3990
3983
 
3991
- var execSearch = function execSearch(e) {
3992
- e.preventDefault();
3993
- _debouncedSearch(searchQuery);
3994
- };
3995
-
3996
3984
  var handleReplaceAll = function handleReplaceAll() {
3997
3985
  if (!searchQuery.trim()) {
3998
3986
  EditorStore.setStatus("Enter a search query first", "error");
@@ -4003,7 +3991,11 @@ var MbeditorApp = function MbeditorApp() {
4003
3991
  if (matchCount > 0) {
4004
3992
  confirmMsg += " (" + matchCount + (searchHasMore ? "+" : "") + " match" + (matchCount !== 1 ? "es" : "") + " across files)";
4005
3993
  }
4006
- if (!window.confirm(confirmMsg)) return;
3994
+ window.MbeditorDialogs.confirm({ title: "Replace all", message: confirmMsg, confirmLabel: "Replace all", danger: true })
3995
+ .then(function (ok) { if (ok) runReplaceAll(); });
3996
+ };
3997
+
3998
+ var runReplaceAll = function runReplaceAll() {
4007
3999
 
4008
4000
  setReplaceLoading(true);
4009
4001
  EditorStore.setStatus("Replacing…", "info");
@@ -4105,16 +4097,6 @@ var MbeditorApp = function MbeditorApp() {
4105
4097
  document.body.style.userSelect = 'none';
4106
4098
  };
4107
4099
 
4108
- var handleSelectCommit = function handleSelectCommit(commit) {
4109
- setSelectedCommit(commit);
4110
- setCommitDetailFiles(null);
4111
- GitService.fetchCommitDetail(commit.hash).then(function (data) {
4112
- setCommitDetailFiles(data.files || []);
4113
- }).catch(function () {
4114
- setCommitDetailFiles([]);
4115
- });
4116
- };
4117
-
4118
4100
  var handleToggleSection = function handleToggleSection(sectionKey, isCollapsed) {
4119
4101
  setCollapsedSections(function (prev) {
4120
4102
  return _extends({}, prev, _defineProperty({}, sectionKey, isCollapsed));
@@ -4332,7 +4314,7 @@ var MbeditorApp = function MbeditorApp() {
4332
4314
  var files = [];
4333
4315
  EditorStore.getState().panes.forEach(function (p) {
4334
4316
  p.tabs.forEach(function (t) {
4335
- if (!t.path || t.isSettings || t.isUntitled || t.isImage || t.isDiff || t.isCombinedDiff || t.isCombinedView || t.isChangelog || t.isPreview || t.isCommitGraph) return;
4317
+ if (!t.path || t.isSettings || t.isUntitled || t.isImage || t.isDiff || t.isCombinedDiff || t.isCombinedView || t.isChangelog || t.isPreview) return;
4336
4318
  if (t.path.indexOf('://') !== -1 || /::preview$/.test(t.path) || seen[t.path]) return;
4337
4319
  seen[t.path] = true;
4338
4320
  files.push(t.path);
@@ -4414,7 +4396,9 @@ var MbeditorApp = function MbeditorApp() {
4414
4396
  };
4415
4397
 
4416
4398
  var openContextMenu = function openContextMenu(e, node) {
4417
- setContextMenu({ x: e.clientX, y: e.clientY, node: node });
4399
+ // e.keyboard: opened by Shift+F10 / the menu key (FileTree), so focus
4400
+ // starts on the first item instead of the menu itself.
4401
+ setContextMenu({ x: e.clientX, y: e.clientY, node: node, keyboard: !!e.keyboard });
4418
4402
  if (!actsOnSelection(node)) handleNodeSelect(node);
4419
4403
  };
4420
4404
 
@@ -4844,8 +4828,15 @@ var MbeditorApp = function MbeditorApp() {
4844
4828
  });
4845
4829
 
4846
4830
  var label = pathsToDelete.length === 1 ? pathsToDelete[0] : pathsToDelete.length + ' items';
4847
- var confirmed = window.confirm('Delete ' + label + '? This cannot be undone.');
4848
- if (!confirmed) return;
4831
+ window.MbeditorDialogs.confirm({
4832
+ title: 'Delete ' + label + '?',
4833
+ message: 'This cannot be undone.',
4834
+ confirmLabel: 'Delete',
4835
+ danger: true
4836
+ }).then(function (ok) { if (ok) runDelete(pathsToDelete, label); });
4837
+ };
4838
+
4839
+ var runDelete = function runDelete(pathsToDelete, label) {
4849
4840
 
4850
4841
  // Computed against the pre-delete tree, since the deleted paths' siblings
4851
4842
  // are only known before the tree is refreshed.
@@ -4880,10 +4871,6 @@ var MbeditorApp = function MbeditorApp() {
4880
4871
 
4881
4872
  var projectSectionTitle = deriveProjectRootName().toUpperCase();
4882
4873
  var selectedTreePath = selectedTreeNode ? selectedTreeNode.path : null;
4883
- var isRuby = activeTab && isRubyPath(activeTab.path);
4884
- var isHaml = activeTab && activeTab.path.endsWith('.haml');
4885
- var isPrettierable = activeTab && SUPPORTED_PRETTIER_EXTS.includes(activeTab.path.split('.').pop().toLowerCase());
4886
- var rubocopLintOn = editorPrefs.rubocopLintEnabled !== false;
4887
4874
  var canLintAndFormat = !!activeTab;
4888
4875
  var hasGitBranch = !!(state.gitBranch && state.gitBranch.trim());
4889
4876
 
@@ -5240,6 +5227,13 @@ var MbeditorApp = function MbeditorApp() {
5240
5227
  )
5241
5228
  ),
5242
5229
  React.createElement("div", { className: "statusbar-sep" }),
5230
+ React.createElement(
5231
+ "button",
5232
+ { type: "button", className: "statusbar-btn", onClick: function () { return setShowAiModal(true); }, title: "Export project for AI / apply an AI diff" },
5233
+ React.createElement("i", { className: "fas fa-robot" }),
5234
+ !toolbarIconOnly && " AI"
5235
+ ),
5236
+ React.createElement("div", { className: "statusbar-sep" }),
5243
5237
  React.createElement(
5244
5238
  "button",
5245
5239
  { type: "button", className: "statusbar-btn", onClick: function () { return setShowHelp(true); }, title: "Keyboard shortcuts & help" },
@@ -5268,8 +5262,9 @@ var MbeditorApp = function MbeditorApp() {
5268
5262
  )
5269
5263
  ),
5270
5264
  collabOverflowOpen && React.createElement(
5271
- "div",
5265
+ window.Popover,
5272
5266
  {
5267
+ mode: "manual",
5273
5268
  className: "collab-overflow-popover",
5274
5269
  style: { top: collabOverflowAnchor.top + 'px', right: collabOverflowAnchor.right + 'px' },
5275
5270
  onMouseEnter: cancelOverflowClose,
@@ -5307,8 +5302,8 @@ var MbeditorApp = function MbeditorApp() {
5307
5302
  var idle = typeof stats.idle === 'number' ? stats.idle : null;
5308
5303
 
5309
5304
  return React.createElement(
5310
- 'div',
5311
- { className: 'collab-hovercard', style: { top: collabHover.top + 'px', right: collabHover.right + 'px' } },
5305
+ window.Popover,
5306
+ { mode: 'manual', className: 'collab-hovercard', style: { top: collabHover.top + 'px', right: collabHover.right + 'px' } },
5312
5307
  React.createElement(
5313
5308
  'div',
5314
5309
  { className: 'collab-hovercard-name' },
@@ -5342,12 +5337,14 @@ var MbeditorApp = function MbeditorApp() {
5342
5337
  collabDiagOpen && (function () {
5343
5338
  var d = CollaborationService.diagnostics();
5344
5339
  return React.createElement(
5345
- 'div',
5346
- { className: 'mbeditor-modal-backdrop', onClick: function () { setCollabDiagOpen(false); } },
5347
- React.createElement(
5348
- 'div',
5349
- { className: 'mbeditor-collab-diag', onClick: function (e) { e.stopPropagation(); } },
5350
- React.createElement('div', { className: 'mbeditor-collab-diag-title' }, 'Pair programming status'),
5340
+ window.ModalDialog,
5341
+ {
5342
+ className: 'mbeditor-collab-diag',
5343
+ dialogClassName: 'mb-dialog-light',
5344
+ labelledBy: 'mb-collab-diag-title',
5345
+ onDismiss: function () { setCollabDiagOpen(false); }
5346
+ },
5347
+ React.createElement('div', { className: 'mbeditor-collab-diag-title', id: 'mb-collab-diag-title' }, 'Pair programming status'),
5351
5348
  React.createElement(
5352
5349
  'ul',
5353
5350
  { className: 'mbeditor-collab-diag-list' },
@@ -5376,7 +5373,6 @@ var MbeditorApp = function MbeditorApp() {
5376
5373
  type: 'button', className: 'ide-model-graph-btn',
5377
5374
  onClick: function () { setCollabDiagOpen(false); }
5378
5375
  }, 'Close')
5379
- )
5380
5376
  );
5381
5377
  })(),
5382
5378
  showHelp && React.createElement(ShortcutHelp, { onClose: function () { return setShowHelp(false); } }),
@@ -5978,6 +5974,19 @@ var MbeditorApp = function MbeditorApp() {
5978
5974
  });
5979
5975
  }
5980
5976
  if (allFiles.length === 0) return null;
5977
+ var openAllBtn = React.createElement(
5978
+ 'button',
5979
+ {
5980
+ className: 'rails-schema-btn',
5981
+ title: 'Open all ' + label + ' files',
5982
+ onClick: (function(files) { return function(e) {
5983
+ e.stopPropagation();
5984
+ setShowModelGraphView(false);
5985
+ files.forEach(function(f) { TabManager.openTab(f.path, f.name, null, null, false); });
5986
+ }; })(allFiles)
5987
+ },
5988
+ React.createElement('i', { className: 'fas fa-folder-open' })
5989
+ );
5981
5990
  var schemaBtn = React.createElement(
5982
5991
  'button',
5983
5992
  {
@@ -6000,7 +6009,7 @@ var MbeditorApp = function MbeditorApp() {
6000
6009
  key: label,
6001
6010
  title: label.toUpperCase(),
6002
6011
  isCollapsed: !!railsGroupsCollapsed[label],
6003
- actions: schemaBtn,
6012
+ actions: React.createElement(React.Fragment, null, openAllBtn, schemaBtn),
6004
6013
  onToggle: (function(captured) { return function(isCollapsed) {
6005
6014
  setRailsGroupsCollapsed(function(prev) {
6006
6015
  var next = Object.assign({}, prev);
@@ -6016,7 +6025,7 @@ var MbeditorApp = function MbeditorApp() {
6016
6025
  return React.createElement(
6017
6026
  "div", {
6018
6027
  key: f.path,
6019
- className: "rails-group-item",
6028
+ className: "rails-group-item" + (openPaths[f.path] ? " rails-group-item-open" : ""),
6020
6029
  onClick: (function(file) { return function() { handleSelectFile(file.path, file.name); }; })(f),
6021
6030
  title: f.path
6022
6031
  },
@@ -6157,12 +6166,7 @@ var MbeditorApp = function MbeditorApp() {
6157
6166
  )
6158
6167
  );
6159
6168
  } else if (pActiveTab) {
6160
- if (pActiveTab.isCommitGraph) {
6161
- content = React.createElement(window.CommitGraph || CommitGraph, {
6162
- commits: pActiveTab.commits || [],
6163
- onSelectCommit: handleSelectCommit
6164
- });
6165
- } else if (pActiveTab.isChangelog) {
6169
+ if (pActiveTab.isChangelog) {
6166
6170
  content = React.createElement(ChangelogView, {
6167
6171
  changelogState: changelogState,
6168
6172
  onLoad: function() {
@@ -6199,7 +6203,6 @@ var MbeditorApp = function MbeditorApp() {
6199
6203
  paneId: pane.id,
6200
6204
  markers: markers[pActiveTab.id] || [],
6201
6205
  gitAvailable: gitAvailable,
6202
- treeData: treeData,
6203
6206
  testResult: testResult,
6204
6207
  testPanelFile: testPanelFile,
6205
6208
  testInlineVisible: testInlineVisible,
@@ -6243,7 +6246,7 @@ var MbeditorApp = function MbeditorApp() {
6243
6246
  // Mousedown, not click: focusing re-renders the app, and doing that
6244
6247
  // during a click's capture phase reverts a checkbox before React
6245
6248
  // sees it change, so its onChange never fires.
6246
- onMouseDownCapture: function (e) {
6249
+ onMouseDownCapture: function () {
6247
6250
  return TabManager.focusPane(pane.id);
6248
6251
  },
6249
6252
  onDragOver: function (e) {
@@ -6443,8 +6446,7 @@ var MbeditorApp = function MbeditorApp() {
6443
6446
  onClose: function () { return setShowGitPanel(false); },
6444
6447
  onOpenFile: openFileFromGitPanel,
6445
6448
  onOpenDiff: TabManager.openDiffTab,
6446
- onOpenAllChanges: function(scope, label) { TabManager.openCombinedDiffTab(scope, label); },
6447
- onSelectCommit: handleSelectCommit
6449
+ onOpenAllChanges: function(scope, label) { TabManager.openCombinedDiffTab(scope, label); }
6448
6450
  })
6449
6451
  ),
6450
6452
  ),
@@ -6594,21 +6596,13 @@ var MbeditorApp = function MbeditorApp() {
6594
6596
  ),
6595
6597
 
6596
6598
  // File History Panel overlay
6597
- historyPanelPath && React.createElement(
6598
- React.Fragment,
6599
- null,
6600
- React.createElement("div", {
6601
- style: { position: 'fixed', inset: 0, zIndex: 9800, background: 'rgba(0,0,0,0.55)' },
6602
- onClick: function() { setHistoryPanelPath(null); }
6603
- }),
6604
- React.createElement(window.FileHistoryPanel || FileHistoryPanel, {
6599
+ historyPanelPath && React.createElement(window.FileHistoryPanel || FileHistoryPanel, {
6605
6600
  path: historyPanelPath,
6606
6601
  onClose: function () { return setHistoryPanelPath(null); },
6607
6602
  onSelectCommit: function (hash, path) {
6608
6603
  TabManager.openDiffTab(path, path.split('/').pop(), hash + '^', hash, null);
6609
6604
  }
6610
- })
6611
- ),
6605
+ }),
6612
6606
 
6613
6607
  // Test Results Panel overlay — closing hides the dialog but keeps testResult for inline markers
6614
6608
  (testPanelOpen || testLoading) && React.createElement(window.TestResultsPanel || TestResultsPanel, {
@@ -6626,98 +6620,25 @@ var MbeditorApp = function MbeditorApp() {
6626
6620
  } : null
6627
6621
  }),
6628
6622
 
6629
- // Commit Detail overlay (shown when a commit row is clicked in CommitGraph)
6630
- selectedCommit && React.createElement(
6631
- React.Fragment,
6632
- null,
6633
- React.createElement("div", {
6634
- style: { position: 'fixed', inset: 0, zIndex: 9000, background: 'rgba(0,0,0,0.45)' },
6635
- onClick: function() { setSelectedCommit(null); setCommitDetailFiles(null); }
6636
- }),
6637
- React.createElement(
6638
- "div",
6639
- { className: "ide-commit-detail-panel" },
6640
- React.createElement(
6641
- "div",
6642
- { className: "ide-commit-detail-header" },
6643
- React.createElement(
6644
- "div",
6645
- null,
6646
- React.createElement("div", { className: "ide-commit-detail-title" }, selectedCommit.title),
6647
- React.createElement(
6648
- "div",
6649
- { className: "ide-commit-detail-meta" },
6650
- React.createElement("span", { className: "commit-hash" }, selectedCommit.hash.slice(0, 7)),
6651
- " \xB7 ",
6652
- selectedCommit.author,
6653
- " \xB7 ",
6654
- selectedCommit.date ? new Date(selectedCommit.date).toLocaleString() : ""
6655
- )
6656
- ),
6657
- React.createElement(
6658
- "button",
6659
- { className: "git-header-btn", onClick: function() { setSelectedCommit(null); setCommitDetailFiles(null); }, title: "Close" },
6660
- React.createElement("i", { className: "fas fa-times" })
6661
- )
6662
- ),
6663
- commitDetailFiles === null
6664
- ? React.createElement("div", { className: "git-empty", 'aria-busy': 'true' }, "Loading…")
6665
- : commitDetailFiles.length === 0
6666
- ? React.createElement("div", { className: "git-empty" }, "No file changes found.")
6667
- : React.createElement(
6668
- "div",
6669
- { className: "git-list" },
6670
- commitDetailFiles.map(function(f, i) {
6671
- var name = (f.path || '').split('/').pop() || f.path;
6672
- return React.createElement(
6673
- "div",
6674
- { key: i, className: "git-file-item" },
6675
- React.createElement(
6676
- "div",
6677
- { className: "git-file-info", onClick: function() { openFileFromGitPanel(f.path, name); } },
6678
- React.createElement("span", { className: "git-status-badge git-" + (f.status || 'M'), title: f.status }, f.status),
6679
- React.createElement("span", { className: "git-file-path", title: f.path }, f.path)
6680
- ),
6681
- React.createElement(
6682
- "div",
6683
- { className: "git-file-actions" },
6684
- React.createElement(
6685
- "button",
6686
- {
6687
- className: "git-action-btn",
6688
- title: "View Diff",
6689
- onClick: function(e) {
6690
- e.stopPropagation();
6691
- TabManager.openDiffTab(f.path, name, selectedCommit.hash + '^', selectedCommit.hash, null);
6692
- }
6693
- },
6694
- React.createElement("i", { className: "fas fa-exchange-alt" })
6695
- )
6696
- )
6697
- );
6698
- })
6699
- )
6700
- )
6701
- ),
6702
-
6703
6623
  // Modals & Panels
6704
6624
  state.isQuickOpenVisible && React.createElement(window.QuickOpenDialog || QuickOpenDialog, {
6705
- onSelect: handleSelectFile,
6625
+ // Focus the opened file's editor. A line jump does that itself
6626
+ // (gotoLine); without one, closing Quick Open would leave focus on
6627
+ // <body>. Only here: handleSelectFile also serves follow mode, which must
6628
+ // not pull focus out of whatever the user is typing in.
6629
+ onSelect: function (path, name, line, col, endCol) {
6630
+ handleSelectFile(path, name, line, col, endCol);
6631
+ if (!line) TabManager.requestFocus(path);
6632
+ },
6706
6633
  showFolders: !!(editorPrefs.quickOpenShowFolders),
6707
6634
  onSelectFolder: handleOpenFolderInExplorer,
6708
6635
  onClose: function () { return setQuickOpen(false); }
6709
6636
  }),
6637
+ // No onDismiss: neither Esc nor the backdrop may silently pick one of
6638
+ // restore/discard, so this dialog closes only through its buttons.
6710
6639
  draftRestoreOffer && React.createElement(
6711
- "div",
6712
- {
6713
- className: "ide-draft-restore-overlay",
6714
- role: "dialog",
6715
- "aria-modal": "true",
6716
- "aria-label": "Restore unsaved drafts"
6717
- },
6718
- React.createElement(
6719
- "div",
6720
- { className: "ide-draft-restore-dialog" },
6640
+ window.ModalDialog,
6641
+ { className: "ide-draft-restore-dialog", label: "Restore unsaved drafts" },
6721
6642
  React.createElement("div", { className: "ide-draft-restore-title" },
6722
6643
  React.createElement("i", { className: "fas fa-save", style: { marginRight: 8 } }),
6723
6644
  "Unsaved drafts found"
@@ -6762,119 +6683,82 @@ var MbeditorApp = function MbeditorApp() {
6762
6683
  "Discard drafts"
6763
6684
  )
6764
6685
  )
6765
- )
6766
6686
  ),
6687
+ // A PopupMenu: a popover, so outside clicks and Esc close it natively
6688
+ // (onDismiss) where a full-screen click-catcher div used to, with buttons
6689
+ // that arrow keys move between. Keyed by position so a second right-click
6690
+ // mounts a fresh menu rather than moving the open one.
6767
6691
  contextMenu && React.createElement(
6768
- React.Fragment,
6769
- null,
6770
- React.createElement("div", {
6771
- style: { position: 'fixed', inset: 0, zIndex: 9998 },
6772
- onClick: closeContextMenu,
6773
- onContextMenu: function (e) {
6774
- e.preventDefault();closeContextMenu();
6775
- }
6776
- }),
6777
- React.createElement(
6778
- "div",
6779
- {
6780
- className: "context-menu",
6781
- ref: contextMenuRef,
6782
- style: { left: contextMenu.x, top: contextMenu.y },
6783
- onClick: function (e) {
6784
- return e.stopPropagation();
6785
- }
6786
- },
6787
- contextMenu.node && contextMenu.node.type === 'file' && React.createElement(
6788
- "div",
6789
- { className: "context-menu-item", onClick: function () {
6790
- return handleContextMenuAction('open');
6791
- } },
6792
- React.createElement("i", { className: "far fa-file-code context-menu-icon" }),
6793
- " Open"
6794
- ),
6795
- React.createElement(
6796
- "div",
6797
- { className: "context-menu-item", onClick: function () {
6798
- return handleContextMenuAction('newFile');
6799
- } },
6800
- React.createElement("i", { className: "far fa-file context-menu-icon" }),
6801
- " New File"
6802
- ),
6803
- React.createElement(
6804
- "div",
6805
- { className: "context-menu-item", onClick: function () {
6806
- return handleContextMenuAction('newFolder');
6807
- } },
6808
- React.createElement("i", { className: "far fa-folder context-menu-icon" }),
6809
- " New Folder"
6810
- ),
6811
- React.createElement("div", { className: "context-menu-divider" }),
6812
- React.createElement(
6813
- "div",
6814
- { className: "context-menu-item", onClick: function () {
6815
- return handleContextMenuAction('rename');
6816
- } },
6817
- React.createElement("i", { className: "fas fa-pen context-menu-icon" }),
6818
- " Rename"
6819
- ),
6820
- React.createElement(
6821
- "div",
6822
- { className: "context-menu-item context-menu-item-danger", onClick: function () {
6823
- return handleContextMenuAction('delete');
6824
- } },
6825
- React.createElement("i", { className: "far fa-trash-alt context-menu-icon" }),
6826
- " " + deleteMenuLabel(contextMenu.node)
6827
- ),
6828
- React.createElement("div", { className: "context-menu-divider" }),
6829
- contextMenu.node && (actsOnSelection(contextMenu.node) || contextMenu.node.type === 'folder') && React.createElement(
6830
- "div",
6831
- { className: "context-menu-item", onClick: function () {
6832
- return handleContextMenuAction('combinedView');
6833
- } },
6834
- React.createElement("i", { className: "fas fa-layer-group context-menu-icon" }),
6835
- " Open in Combined View"
6836
- ),
6837
- contextMenu.node && React.createElement(
6838
- "div",
6839
- { className: "context-menu-item", onClick: function () {
6840
- return handleContextMenuAction('download');
6841
- } },
6842
- React.createElement("i", { className: "fas fa-download context-menu-icon" }),
6843
- " " + downloadMenuLabel(contextMenu.node)
6844
- ),
6845
- React.createElement(
6846
- "div",
6847
- { className: "context-menu-item", onClick: function () {
6848
- return handleContextMenuAction('upload');
6849
- } },
6850
- React.createElement("i", { className: "fas fa-upload context-menu-icon" }),
6851
- " Upload Files Here..."
6852
- ),
6853
- React.createElement("div", { className: "context-menu-divider" }),
6854
- React.createElement(
6855
- "div",
6856
- { className: "context-menu-item", onClick: function () {
6857
- return handleContextMenuAction('copyPath');
6858
- } },
6859
- React.createElement("i", { className: "fas fa-copy context-menu-icon" }),
6860
- " Copy Path"
6861
- )
6862
- )
6692
+ window.PopupMenu,
6693
+ {
6694
+ key: contextMenu.x + ',' + contextMenu.y,
6695
+ label: contextMenu.node ? contextMenu.node.name : 'Explorer',
6696
+ keyboard: contextMenu.keyboard,
6697
+ className: "context-menu",
6698
+ popoverRef: contextMenuRef,
6699
+ style: { left: contextMenu.x, top: contextMenu.y },
6700
+ onDismiss: closeContextMenu,
6701
+ onClick: function (e) { e.stopPropagation(); },
6702
+ onContextMenu: function (e) { e.preventDefault(); }
6703
+ },
6704
+ contextMenu.node && contextMenu.node.type === 'file' && React.createElement(window.MenuItem, {
6705
+ icon: "far fa-file-code", label: "Open",
6706
+ onClick: function () { return handleContextMenuAction('open'); }
6707
+ }),
6708
+ React.createElement(window.MenuItem, {
6709
+ icon: "far fa-file", label: "New File",
6710
+ onClick: function () { return handleContextMenuAction('newFile'); }
6711
+ }),
6712
+ React.createElement(window.MenuItem, {
6713
+ icon: "far fa-folder", label: "New Folder",
6714
+ onClick: function () { return handleContextMenuAction('newFolder'); }
6715
+ }),
6716
+ React.createElement(window.MenuSeparator),
6717
+ React.createElement(window.MenuItem, {
6718
+ icon: "fas fa-pen", label: "Rename",
6719
+ onClick: function () { return handleContextMenuAction('rename'); }
6720
+ }),
6721
+ React.createElement(window.MenuItem, {
6722
+ icon: "far fa-trash-alt", label: deleteMenuLabel(contextMenu.node), danger: true,
6723
+ onClick: function () { return handleContextMenuAction('delete'); }
6724
+ }),
6725
+ React.createElement(window.MenuSeparator),
6726
+ contextMenu.node && (actsOnSelection(contextMenu.node) || contextMenu.node.type === 'folder') && React.createElement(window.MenuItem, {
6727
+ icon: "fas fa-layer-group", label: "Open in Combined View",
6728
+ onClick: function () { return handleContextMenuAction('combinedView'); }
6729
+ }),
6730
+ contextMenu.node && React.createElement(window.MenuItem, {
6731
+ icon: "fas fa-download", label: downloadMenuLabel(contextMenu.node),
6732
+ onClick: function () { return handleContextMenuAction('download'); }
6733
+ }),
6734
+ React.createElement(window.MenuItem, {
6735
+ icon: "fas fa-upload", label: "Upload Files Here...",
6736
+ onClick: function () { return handleContextMenuAction('upload'); }
6737
+ }),
6738
+ React.createElement(window.MenuSeparator),
6739
+ React.createElement(window.MenuItem, {
6740
+ icon: "fas fa-copy", label: "Copy Path",
6741
+ onClick: function () { return handleContextMenuAction('copyPath'); }
6742
+ })
6863
6743
  ),
6744
+ // Esc and the backdrop mean Cancel: the tab stays open with its edits.
6745
+ // Save on an untitled tab opens the Save As prompt on top of this one;
6746
+ // both are modal <dialog>s, and the top layer stacks the later one above.
6864
6747
  closingTabId && React.createElement(
6865
- "div",
6866
- { className: "quick-open-overlay", style: { zIndex: 10001 } },
6748
+ window.ModalDialog,
6749
+ {
6750
+ className: "schema-modal mb-confirm",
6751
+ labelledBy: "mb-unsaved-title",
6752
+ onDismiss: function () { setClosingTabId(null); setClosingPaneId(null); }
6753
+ },
6867
6754
  React.createElement(
6868
- "div",
6869
- { className: "quick-open-box", style: { width: '400px', padding: '20px', background: '#252526', border: '1px solid #454545' } },
6870
- React.createElement(
6871
- "h3",
6872
- { style: { marginTop: 0, fontSize: '14px', color: '#fff' } },
6873
- "Unsaved Changes"
6874
- ),
6755
+ "div", { className: "schema-modal-header" },
6756
+ React.createElement("div", { className: "schema-modal-title", id: "mb-unsaved-title" }, "Unsaved changes")
6757
+ ),
6758
+ React.createElement(
6759
+ "div", { className: "schema-modal-body" },
6875
6760
  React.createElement(
6876
- "p",
6877
- { style: { color: '#ccc', margin: '16px 0', fontSize: '13px' } },
6761
+ "p", { className: "mb-confirm-message" },
6878
6762
  "Do you want to save the changes you made to ",
6879
6763
  React.createElement(
6880
6764
  "strong",
@@ -6885,47 +6769,37 @@ var MbeditorApp = function MbeditorApp() {
6885
6769
  return t.id === closingTabId;
6886
6770
  }) || {}).name
6887
6771
  ),
6888
- "?"
6772
+ "? Your changes will be lost if you don't save them."
6773
+ )
6774
+ ),
6775
+ React.createElement(
6776
+ "div", { className: "import-conflict-actions" },
6777
+ React.createElement(
6778
+ "button",
6779
+ { type: "button", className: "import-conflict-btn",
6780
+ onClick: function () { setClosingTabId(null); setClosingPaneId(null); } },
6781
+ "Cancel"
6889
6782
  ),
6890
6783
  React.createElement(
6891
- "p",
6892
- { style: { color: '#888', marginBottom: '24px', fontSize: '12px' } },
6893
- "Your changes will be lost if you don't save them."
6784
+ "button",
6785
+ { type: "button", className: "import-conflict-btn import-conflict-btn-danger",
6786
+ onClick: function () { return confirmCloseTab(false); } },
6787
+ "Don't Save"
6894
6788
  ),
6895
6789
  React.createElement(
6896
- "div",
6897
- { style: { display: 'flex', gap: '8px', justifyContent: 'flex-end' } },
6898
- React.createElement(
6899
- "button",
6900
- {
6901
- onClick: function () {
6902
- return confirmCloseTab(true);
6903
- },
6904
- style: { padding: '6px 16px', background: '#0e639c', color: '#fff', border: 'none', borderRadius: '4px', cursor: 'pointer' } },
6905
- "Save"
6906
- ),
6907
- React.createElement(
6908
- "button",
6909
- {
6910
- onClick: function () {
6911
- return confirmCloseTab(false);
6912
- },
6913
- style: { padding: '6px 16px', background: 'transparent', color: '#ccc', border: '1px solid #666', borderRadius: '4px', cursor: 'pointer' } },
6914
- "Don't Save"
6915
- ),
6916
- React.createElement(
6917
- "button",
6918
- {
6919
- onClick: function () {
6920
- return setClosingTabId(null);
6921
- },
6922
- style: { padding: '6px 16px', background: 'transparent', color: '#888', border: 'none', cursor: 'pointer' } },
6923
- "Cancel"
6924
- )
6790
+ "button",
6791
+ { type: "button", className: "import-conflict-btn import-conflict-btn-primary", "data-autofocus": true,
6792
+ onClick: function () { return confirmCloseTab(true); } },
6793
+ "Save"
6925
6794
  )
6926
6795
  )
6927
6796
  ),
6928
6797
 
6798
+ showAiModal && React.createElement(AiRoundTripModal, {
6799
+ treeData: treeData,
6800
+ onClose: function () { setShowAiModal(false); }
6801
+ }),
6802
+
6929
6803
  /* ── Upload dialog ─────────────────────────────────────────────────── */
6930
6804
  importDialog && React.createElement(ImportDialog, {
6931
6805
  initialFolder: importDialog.initialFolder,
@@ -6954,17 +6828,12 @@ var MbeditorApp = function MbeditorApp() {
6954
6828
 
6955
6829
  /* ── Schema modal ──────────────────────────────────────────────────── */
6956
6830
  schemaModal && React.createElement(
6957
- 'div',
6831
+ window.ModalDialog,
6958
6832
  {
6959
- className: 'schema-modal-overlay',
6960
- onClick: function() { setSchemaModal(null); }
6833
+ className: 'schema-modal',
6834
+ label: 'Schema for ' + schemaModal.label,
6835
+ onDismiss: function() { setSchemaModal(null); }
6961
6836
  },
6962
- React.createElement(
6963
- 'div',
6964
- {
6965
- className: 'schema-modal',
6966
- onClick: function(e) { e.stopPropagation(); }
6967
- },
6968
6837
  /* Header */
6969
6838
  React.createElement(
6970
6839
  'div', { className: 'schema-modal-header' },
@@ -7039,7 +6908,6 @@ var MbeditorApp = function MbeditorApp() {
7039
6908
  )
7040
6909
  ]
7041
6910
  )
7042
- )
7043
6911
  )
7044
6912
  );
7045
6913
  };