@leosdc/exploreio 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tui/app.js CHANGED
@@ -10,7 +10,8 @@ import { VimEngine } from '../editor/vimEngine.js';
10
10
  import { buildEditorFrame } from '../editor/vimView.js';
11
11
  import { getGitSummaryBadge, gitCheckoutBranch, gitCommit, gitCreateBranch, gitDiscardFile, gitFetch, gitPull, gitPush, gitStageAll, gitStageFile, gitStashPop, gitStashPush, gitUnstageAll, gitUnstageFile, loadCommitDetails, loadFileDiff, loadGitHubData, loadGitPanelSnapshot, } from '../git/gitService.js';
12
12
  import { buildGitHubListItems, buildGitPanelFrame, buildQuickActions, buildStatusListItems, formatGitHeaderBadge, } from '../git/gitView.js';
13
- import { createFileOrDir, createFileSafe, createFolderSafe, deleteEntry, duplicateEntrySafe, formatBytes, readDirectoryEntries, renameEntry, safeReadFilePreview, safeWriteTextFile, suggestDuplicateName, } from '../fs/explorer.js';
13
+ import { copyEntriesSafe, createFileOrDir, createFileSafe, createFolderSafe, deleteEntriesSafe, duplicateEntrySafe, formatBytes, moveEntriesSafe, readDirectoryEntries, renameEntrySafe, safeReadFilePreview, safeWriteTextFile, suggestDuplicateName, } from '../fs/explorer.js';
14
+ import { DirectoryWatcher, resolveExistingDirectory, resolveNextSelectedIndex, } from '../fs/watcher.js';
14
15
  import { collectAllCollapsiblePaths } from '../renderers/json.js';
15
16
  import { renderDirectoryPreview, renderDocument, } from '../renderers/index.js';
16
17
  import { bg, fg, getTheme, nextTheme } from '../themes/palette.js';
@@ -18,6 +19,7 @@ import { BOLD, DIM, ITALIC, RESET, fitAnsi, highlightSearch, stripUnsafeAnsi, tr
18
19
  import { copyTextToClipboard } from './clipboard.js';
19
20
  import { applyModalOverlay, createInitialModalState, cycleModalExtension, renderCreateEntryModalOverlay, resolveModalTargetName, } from './createEntryModal.js';
20
21
  import { openInFullscreenShell } from './fullscreenLauncher.js';
22
+ import { getDefaultHelpTabForView, getHelpTabByNumber, getNextHelpTab, renderHelpModalOverlay, } from './helpModal.js';
21
23
  import { parseInputChunk } from './input.js';
22
24
  import { KEYBINDS_TABS, buildKeybindsPanelFrame, getFilteredKeybindDefinitions, } from './keybindsView.js';
23
25
  import { ScreenBuffer } from './screen.js';
@@ -54,6 +56,7 @@ export class ExploreioApp {
54
56
  view = 'browser';
55
57
  showHidden;
56
58
  showHelp = false;
59
+ helpTab = 'browser';
57
60
  // Estado do navegador 3 painéis
58
61
  currentDir;
59
62
  parentEntries = [];
@@ -61,6 +64,10 @@ export class ExploreioApp {
61
64
  selectedIndex = 0;
62
65
  listScroll = 0;
63
66
  filterQuery = '';
67
+ // Seleção múltipla & Clipboard interno de arquivos (SPEC-009)
68
+ selectedPaths = new Set();
69
+ fsClipboard = null;
70
+ pendingDeletePaths = [];
64
71
  // Preview & Leitor Fullscreen
65
72
  previewLines = [];
66
73
  previewBadge = '';
@@ -119,12 +126,20 @@ export class ExploreioApp {
119
126
  createModal = null;
120
127
  toastMessage = '';
121
128
  running = false;
129
+ // Observador de arquivos em tempo real (SPEC-008)
130
+ dirWatcher;
131
+ externalRefreshRunning = false;
132
+ queuedExternalScopes = new Set();
133
+ deferredExternalScopes = new Set();
122
134
  constructor(options) {
123
135
  this.currentDir = path.resolve(options.startDir);
124
136
  this.initialMode = options.initialMode;
125
137
  this.singleFile = Boolean(options.singleFile);
126
138
  this.themeName = options.themeName ?? 'midnight';
127
139
  this.showHidden = Boolean(options.showHidden);
140
+ this.dirWatcher = new DirectoryWatcher({
141
+ onChange: (batch) => this.handleWatcherChange(batch),
142
+ });
128
143
  const loadedBinds = loadKeybindsRegistry(options.configPath);
129
144
  this.keybinds = loadedBinds.registry;
130
145
  this.configPath = loadedBinds.configPath;
@@ -143,6 +158,7 @@ export class ExploreioApp {
143
158
  this.screen.enter();
144
159
  const cleanup = () => {
145
160
  this.running = false;
161
+ this.dirWatcher.close();
146
162
  this.screen.leave();
147
163
  };
148
164
  process.once('SIGINT', () => {
@@ -173,6 +189,7 @@ export class ExploreioApp {
173
189
  }
174
190
  shutdown() {
175
191
  this.running = false;
192
+ this.dirWatcher.close();
176
193
  process.stdout.off('resize', this.onResize);
177
194
  process.stdin.off('data', this.onStdinData);
178
195
  this.screen.leave();
@@ -202,6 +219,34 @@ export class ExploreioApp {
202
219
  process.exit(0);
203
220
  }
204
221
  if (this.showHelp) {
222
+ if (ev.name === 'char' && ev.char) {
223
+ const numberedTab = getHelpTabByNumber(ev.char);
224
+ if (numberedTab) {
225
+ this.helpTab = numberedTab;
226
+ this.draw();
227
+ continue;
228
+ }
229
+ if (ev.char === 'h') {
230
+ this.helpTab = getNextHelpTab(this.helpTab, -1);
231
+ this.draw();
232
+ continue;
233
+ }
234
+ if (ev.char === 'l') {
235
+ this.helpTab = getNextHelpTab(this.helpTab, 1);
236
+ this.draw();
237
+ continue;
238
+ }
239
+ }
240
+ if (ev.name === 'left' || (ev.shift && ev.name === 'tab')) {
241
+ this.helpTab = getNextHelpTab(this.helpTab, -1);
242
+ this.draw();
243
+ continue;
244
+ }
245
+ if (ev.name === 'right' || ev.name === 'tab') {
246
+ this.helpTab = getNextHelpTab(this.helpTab, 1);
247
+ this.draw();
248
+ continue;
249
+ }
205
250
  if (this.keybinds.matches('global.openKeybinds', ev)) {
206
251
  this.showHelp = false;
207
252
  const ret = this.view === 'reader' || this.view === 'git' ? this.view : 'browser';
@@ -211,6 +256,7 @@ export class ExploreioApp {
211
256
  if (ev.name === 'escape' || this.keybinds.matches('global.help', ev) || this.keybinds.matches('global.quit', ev)) {
212
257
  this.showHelp = false;
213
258
  this.draw();
259
+ this.flushDeferredExternalRefresh();
214
260
  }
215
261
  continue;
216
262
  }
@@ -253,6 +299,7 @@ export class ExploreioApp {
253
299
  this.promptKind = null;
254
300
  this.promptInput = '';
255
301
  this.draw();
302
+ this.flushDeferredExternalRefresh();
256
303
  return;
257
304
  }
258
305
  if (ev.name === 'enter') {
@@ -303,9 +350,10 @@ export class ExploreioApp {
303
350
  const current = this.currentEntries[this.selectedIndex];
304
351
  if (current) {
305
352
  try {
306
- await renameEntry(current.fullPath, value);
307
- this.toastMessage = `Renomeado para: ${value.trim()}`;
308
- await this.reloadDirectory();
353
+ const res = await renameEntrySafe(current.fullPath, value);
354
+ this.syncRenamedPathReferences(current.fullPath, res.targetPath);
355
+ this.toastMessage = `Renomeado para: ${res.focusName}`;
356
+ await this.reloadDirectory(res.focusName);
309
357
  }
310
358
  catch (err) {
311
359
  this.toastMessage = err instanceof Error ? err.message : String(err);
@@ -313,16 +361,24 @@ export class ExploreioApp {
313
361
  }
314
362
  }
315
363
  else if (kind === 'delete') {
316
- const current = this.currentEntries[this.selectedIndex];
317
- if (current && (value.trim().toLowerCase() === 'y' || value.trim().toLowerCase() === 's')) {
318
- try {
319
- await deleteEntry(current.fullPath);
320
- this.toastMessage = `Removido: ${current.name}`;
321
- await this.reloadDirectory();
364
+ const targets = [...this.pendingDeletePaths];
365
+ this.pendingDeletePaths = [];
366
+ if (targets.length > 0 && (value.trim().toLowerCase() === 'y' || value.trim().toLowerCase() === 's')) {
367
+ const res = await deleteEntriesSafe(targets);
368
+ for (const item of res.succeeded) {
369
+ this.removePathFromFsState(item.sourcePath);
322
370
  }
323
- catch (err) {
324
- this.toastMessage = err instanceof Error ? err.message : String(err);
371
+ if (res.failed.length === 0) {
372
+ this.toastMessage =
373
+ res.succeeded.length === 1
374
+ ? `Removido: ${path.basename(res.succeeded[0].sourcePath)}`
375
+ : `Removidos ${res.succeeded.length} itens com sucesso.`;
325
376
  }
377
+ else {
378
+ const firstErr = res.failed[0]?.error ?? 'Erro ao remover';
379
+ this.toastMessage = `Removidos: ${res.succeeded.length} · Falhas: ${res.failed.length} (${firstErr})`;
380
+ }
381
+ await this.reloadDirectory();
326
382
  }
327
383
  else {
328
384
  this.toastMessage = 'Exclusão cancelada.';
@@ -397,6 +453,7 @@ export class ExploreioApp {
397
453
  if (ev.name === 'escape') {
398
454
  this.createModal = null;
399
455
  this.draw();
456
+ this.flushDeferredExternalRefresh();
400
457
  return;
401
458
  }
402
459
  if (modal.mode === 'file') {
@@ -463,6 +520,7 @@ export class ExploreioApp {
463
520
  process.exit(0);
464
521
  }
465
522
  if (this.keybinds.matches('global.help', ev)) {
523
+ this.helpTab = getDefaultHelpTabForView('browser');
466
524
  this.showHelp = true;
467
525
  this.draw();
468
526
  return;
@@ -515,16 +573,94 @@ export class ExploreioApp {
515
573
  this.draw();
516
574
  return;
517
575
  }
576
+ if (this.keybinds.matches('browser.toggleSelect', ev) && this.currentEntries[this.selectedIndex]) {
577
+ const current = this.currentEntries[this.selectedIndex];
578
+ if (this.selectedPaths.has(current.fullPath)) {
579
+ this.selectedPaths.delete(current.fullPath);
580
+ }
581
+ else {
582
+ this.selectedPaths.add(current.fullPath);
583
+ }
584
+ if (this.selectedIndex < maxIdx) {
585
+ this.selectedIndex++;
586
+ await this.refreshSelectedPreview();
587
+ }
588
+ this.draw();
589
+ return;
590
+ }
591
+ if (this.keybinds.matches('browser.yankCopy', ev)) {
592
+ const targets = this.getTargetPathsForFsAction();
593
+ if (targets.length === 0) {
594
+ this.toastMessage = 'Nenhum item selecionado para copiar.';
595
+ }
596
+ else {
597
+ this.fsClipboard = { mode: 'copy', paths: targets };
598
+ this.selectedPaths.clear();
599
+ const pasteKey = this.keybinds.formatActionKeys('browser.paste', '/');
600
+ const label = targets.length === 1 ? `"${path.basename(targets[0])}"` : `${targets.length} itens`;
601
+ this.toastMessage = `Copiado: ${label} · navegue e pressione ${pasteKey} para colar`;
602
+ }
603
+ this.draw();
604
+ return;
605
+ }
606
+ if (this.keybinds.matches('browser.yankMove', ev)) {
607
+ const targets = this.getTargetPathsForFsAction();
608
+ if (targets.length === 0) {
609
+ this.toastMessage = 'Nenhum item selecionado para mover.';
610
+ }
611
+ else {
612
+ this.fsClipboard = { mode: 'move', paths: targets };
613
+ this.selectedPaths.clear();
614
+ const pasteKey = this.keybinds.formatActionKeys('browser.paste', '/');
615
+ const label = targets.length === 1 ? `"${path.basename(targets[0])}"` : `${targets.length} itens`;
616
+ this.toastMessage = `Recortado p/ mover: ${label} · navegue e pressione ${pasteKey} para colar`;
617
+ }
618
+ this.draw();
619
+ return;
620
+ }
621
+ if (this.keybinds.matches('browser.paste', ev)) {
622
+ await this.executeFsPaste();
623
+ return;
624
+ }
625
+ if (this.keybinds.matches('browser.clearSelection', ev)) {
626
+ if (this.selectedPaths.size > 0 || this.fsClipboard) {
627
+ this.selectedPaths.clear();
628
+ this.fsClipboard = null;
629
+ this.toastMessage = 'Seleção e clipboard interno limpos.';
630
+ this.draw();
631
+ }
632
+ return;
633
+ }
634
+ if (ev.name === 'escape') {
635
+ if (this.filterQuery) {
636
+ this.filterQuery = '';
637
+ await this.reloadDirectory();
638
+ this.toastMessage = 'Filtro limpo.';
639
+ this.draw();
640
+ return;
641
+ }
642
+ if (this.selectedPaths.size > 0 || this.fsClipboard) {
643
+ this.selectedPaths.clear();
644
+ this.fsClipboard = null;
645
+ this.toastMessage = 'Seleção e clipboard interno limpos.';
646
+ this.draw();
647
+ return;
648
+ }
649
+ }
518
650
  if (this.keybinds.matches('browser.renameEntry', ev) && this.currentEntries[this.selectedIndex]) {
519
651
  this.promptKind = 'rename';
520
652
  this.promptInput = this.currentEntries[this.selectedIndex]?.name ?? '';
521
653
  this.draw();
522
654
  return;
523
655
  }
524
- if (this.keybinds.matches('browser.deleteEntry', ev) && this.currentEntries[this.selectedIndex]) {
525
- this.promptKind = 'delete';
526
- this.promptInput = '';
527
- this.draw();
656
+ if (this.keybinds.matches('browser.deleteEntry', ev)) {
657
+ const targets = this.getTargetPathsForFsAction();
658
+ if (targets.length > 0) {
659
+ this.pendingDeletePaths = targets;
660
+ this.promptKind = 'delete';
661
+ this.promptInput = '';
662
+ this.draw();
663
+ }
528
664
  return;
529
665
  }
530
666
  if (this.keybinds.matches('browser.copyPath', ev)) {
@@ -617,6 +753,82 @@ export class ExploreioApp {
617
753
  }
618
754
  this.draw();
619
755
  }
756
+ getTargetPathsForFsAction() {
757
+ if (this.selectedPaths.size > 0) {
758
+ return Array.from(this.selectedPaths);
759
+ }
760
+ const current = this.currentEntries[this.selectedIndex];
761
+ return current ? [current.fullPath] : [];
762
+ }
763
+ syncRenamedPathReferences(oldPath, newPath) {
764
+ if (this.selectedPaths.has(oldPath)) {
765
+ this.selectedPaths.delete(oldPath);
766
+ this.selectedPaths.add(newPath);
767
+ }
768
+ if (this.fsClipboard) {
769
+ this.fsClipboard = {
770
+ ...this.fsClipboard,
771
+ paths: this.fsClipboard.paths.map((p) => (p === oldPath ? newPath : p)),
772
+ };
773
+ }
774
+ }
775
+ removePathFromFsState(targetPath) {
776
+ this.selectedPaths.delete(targetPath);
777
+ if (this.fsClipboard) {
778
+ const remaining = this.fsClipboard.paths.filter((p) => p !== targetPath);
779
+ this.fsClipboard = remaining.length > 0 ? { ...this.fsClipboard, paths: remaining } : null;
780
+ }
781
+ }
782
+ buildDeletePromptLabel() {
783
+ const targets = this.pendingDeletePaths;
784
+ if (targets.length === 1) {
785
+ const targetPath = targets[0];
786
+ const entry = this.currentEntries.find((e) => e.fullPath === targetPath);
787
+ const safeName = stripUnsafeAnsi(entry?.name ?? path.basename(targetPath));
788
+ if (entry?.isDirectory) {
789
+ return `Excluir pasta "${safeName}" recursivamente? (y/N): `;
790
+ }
791
+ return `Excluir "${safeName}"? (y/N): `;
792
+ }
793
+ if (targets.length > 1) {
794
+ return `Excluir ${targets.length} itens marcados? (y/N): `;
795
+ }
796
+ return `Excluir "${stripUnsafeAnsi(this.currentEntries[this.selectedIndex]?.name ?? '')}"? (y/N): `;
797
+ }
798
+ async executeFsPaste() {
799
+ if (!this.fsClipboard || this.fsClipboard.paths.length === 0) {
800
+ const copyKey = this.keybinds.formatActionKeys('browser.yankCopy', '/');
801
+ const moveKey = this.keybinds.formatActionKeys('browser.yankMove', '/');
802
+ this.toastMessage = `Nada para colar. Use ${copyKey} (copiar) ou ${moveKey} (mover) antes.`;
803
+ this.draw();
804
+ return;
805
+ }
806
+ const { mode, paths } = this.fsClipboard;
807
+ const res = mode === 'copy'
808
+ ? await copyEntriesSafe(paths, this.currentDir)
809
+ : await moveEntriesSafe(paths, this.currentDir);
810
+ if (mode === 'move') {
811
+ const failedPaths = res.failed.map((f) => f.sourcePath);
812
+ this.fsClipboard = failedPaths.length > 0 ? { mode: 'move', paths: failedPaths } : null;
813
+ }
814
+ const verb = mode === 'copy' ? 'Copiado' : 'Movido';
815
+ const verbPlural = mode === 'copy' ? 'Copiados' : 'Movidos';
816
+ if (res.failed.length === 0) {
817
+ this.toastMessage =
818
+ res.succeeded.length === 1
819
+ ? `${verb}: ${res.focusName ?? path.basename(res.succeeded[0].sourcePath)}`
820
+ : `${verbPlural} ${res.succeeded.length} itens para esta pasta.`;
821
+ }
822
+ else if (res.succeeded.length > 0) {
823
+ const firstErr = res.failed[0]?.error ?? 'erro desconhecido';
824
+ this.toastMessage = `${verbPlural}: ${res.succeeded.length} · Falhas: ${res.failed.length} (${firstErr})`;
825
+ }
826
+ else {
827
+ this.toastMessage = res.failed[0]?.error ?? 'Não foi possível concluir a operação.';
828
+ }
829
+ await this.reloadDirectory(res.focusName);
830
+ this.draw();
831
+ }
620
832
  async handleReaderKey(ev) {
621
833
  this.toastMessage = '';
622
834
  const { height } = this.screen.getSize();
@@ -633,9 +845,11 @@ export class ExploreioApp {
633
845
  this.readerSearchMatches = [];
634
846
  await this.refreshSelectedPreview();
635
847
  this.draw();
848
+ this.flushDeferredExternalRefresh();
636
849
  return;
637
850
  }
638
851
  if (this.keybinds.matches('global.help', ev)) {
852
+ this.helpTab = getDefaultHelpTabForView('reader');
639
853
  this.showHelp = true;
640
854
  this.draw();
641
855
  return;
@@ -808,7 +1022,7 @@ export class ExploreioApp {
808
1022
  }
809
1023
  this.draw();
810
1024
  }
811
- async reloadDirectory(focusEntryName) {
1025
+ async reloadDirectory(focusEntryName, fallbackIndex) {
812
1026
  const parentDir = path.dirname(this.currentDir);
813
1027
  const [parentRes, currentRes] = await Promise.all([
814
1028
  parentDir !== this.currentDir
@@ -818,13 +1032,8 @@ export class ExploreioApp {
818
1032
  ]);
819
1033
  this.parentEntries = parentRes.entries;
820
1034
  this.currentEntries = currentRes.entries;
821
- if (focusEntryName) {
822
- const idx = this.currentEntries.findIndex((e) => e.name === focusEntryName);
823
- this.selectedIndex = idx >= 0 ? idx : 0;
824
- }
825
- else {
826
- this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.currentEntries.length - 1));
827
- }
1035
+ const effectiveFallback = fallbackIndex ?? (focusEntryName ? 0 : this.selectedIndex);
1036
+ this.selectedIndex = resolveNextSelectedIndex(this.currentEntries, focusEntryName, effectiveFallback);
828
1037
  await this.refreshSelectedPreview();
829
1038
  this.refreshGitHeaderSummary();
830
1039
  }
@@ -833,6 +1042,7 @@ export class ExploreioApp {
833
1042
  const theme = getTheme(this.themeName);
834
1043
  const { width, height } = this.screen.getSize();
835
1044
  const previewWidth = Math.max(24, Math.floor(width * 0.45) - 4);
1045
+ this.syncDirectoryWatcher();
836
1046
  if (!entry) {
837
1047
  this.previewBadge = 'VAZIO';
838
1048
  this.previewLines = [`${fg(theme.muted)}${ITALIC}(nenhum item selecionado)${RESET}`];
@@ -853,6 +1063,88 @@ export class ExploreioApp {
853
1063
  this.previewBadge = doc.badge;
854
1064
  this.previewLines = doc.lines;
855
1065
  }
1066
+ isBrowserInteractiveIdle() {
1067
+ return (this.running &&
1068
+ this.view === 'browser' &&
1069
+ !this.promptKind &&
1070
+ !this.createModal &&
1071
+ !this.showHelp);
1072
+ }
1073
+ syncDirectoryWatcher() {
1074
+ if (!this.running)
1075
+ return;
1076
+ const parentDir = path.dirname(this.currentDir);
1077
+ const selected = this.currentEntries[this.selectedIndex];
1078
+ const previewDir = selected?.isDirectory ? selected.fullPath : null;
1079
+ this.dirWatcher.updateTargets({
1080
+ currentDir: this.currentDir,
1081
+ parentDir: parentDir !== this.currentDir ? parentDir : null,
1082
+ previewDir,
1083
+ });
1084
+ }
1085
+ handleWatcherChange(batch) {
1086
+ if (!this.running)
1087
+ return;
1088
+ if (!this.isBrowserInteractiveIdle()) {
1089
+ for (const scope of batch.scopes) {
1090
+ this.deferredExternalScopes.add(scope);
1091
+ }
1092
+ return;
1093
+ }
1094
+ for (const scope of batch.scopes) {
1095
+ this.queuedExternalScopes.add(scope);
1096
+ }
1097
+ void this.drainExternalRefreshQueue();
1098
+ }
1099
+ flushDeferredExternalRefresh() {
1100
+ if (this.deferredExternalScopes.size === 0 || !this.isBrowserInteractiveIdle())
1101
+ return;
1102
+ for (const scope of this.deferredExternalScopes) {
1103
+ this.queuedExternalScopes.add(scope);
1104
+ }
1105
+ this.deferredExternalScopes.clear();
1106
+ void this.drainExternalRefreshQueue();
1107
+ }
1108
+ async drainExternalRefreshQueue() {
1109
+ if (this.externalRefreshRunning)
1110
+ return;
1111
+ this.externalRefreshRunning = true;
1112
+ try {
1113
+ while (this.queuedExternalScopes.size > 0 && this.isBrowserInteractiveIdle()) {
1114
+ const scopes = new Set(this.queuedExternalScopes);
1115
+ this.queuedExternalScopes.clear();
1116
+ await this.applyExternalScopes(scopes);
1117
+ }
1118
+ }
1119
+ finally {
1120
+ this.externalRefreshRunning = false;
1121
+ }
1122
+ }
1123
+ async applyExternalScopes(scopes) {
1124
+ if (scopes.has('current') || scopes.has('parent')) {
1125
+ const resolved = await resolveExistingDirectory(this.currentDir);
1126
+ if (!this.isBrowserInteractiveIdle())
1127
+ return;
1128
+ if (resolved.fellBack) {
1129
+ this.currentDir = resolved.dirPath;
1130
+ this.filterQuery = '';
1131
+ this.selectedIndex = 0;
1132
+ this.listScroll = 0;
1133
+ this.toastMessage = `Diretório anterior removido; voltando para ${stripUnsafeAnsi(resolved.dirPath)}`;
1134
+ await this.reloadDirectory();
1135
+ }
1136
+ else {
1137
+ const previousName = this.currentEntries[this.selectedIndex]?.name;
1138
+ await this.reloadDirectory(previousName, this.selectedIndex);
1139
+ }
1140
+ }
1141
+ else if (scopes.has('preview')) {
1142
+ await this.refreshSelectedPreview();
1143
+ }
1144
+ if (this.isBrowserInteractiveIdle()) {
1145
+ this.draw();
1146
+ }
1147
+ }
856
1148
  async openInFullscreenTerminal(filePath, viewMode) {
857
1149
  const result = await openInFullscreenShell(filePath, {
858
1150
  themeName: this.themeName,
@@ -997,6 +1289,7 @@ export class ExploreioApp {
997
1289
  else {
998
1290
  await this.refreshSelectedPreview();
999
1291
  }
1292
+ this.flushDeferredExternalRefresh();
1000
1293
  }
1001
1294
  this.draw();
1002
1295
  }
@@ -1112,17 +1405,27 @@ export class ExploreioApp {
1112
1405
  const cEntry = this.currentEntries[cIdx];
1113
1406
  if (cEntry) {
1114
1407
  const selected = cIdx === this.selectedIndex;
1408
+ const isMarked = this.selectedPaths.has(cEntry.fullPath);
1409
+ const clipMode = this.fsClipboard?.paths.includes(cEntry.fullPath) ? this.fsClipboard.mode : null;
1410
+ const markPrefixPlain = isMarked ? '● ' : clipMode === 'copy' ? '⧉ ' : clipMode === 'move' ? '✂ ' : '';
1411
+ const markPrefixStyled = isMarked
1412
+ ? `${fg(theme.warning)}${BOLD}●${RESET} `
1413
+ : clipMode === 'copy'
1414
+ ? `${fg(theme.success)}${BOLD}⧉${RESET} `
1415
+ : clipMode === 'move'
1416
+ ? `${fg(theme.danger)}${BOLD}✂${RESET} `
1417
+ : '';
1115
1418
  const sizeLabel = cEntry.isDirectory ? '/' : formatBytes(cEntry.size);
1116
1419
  const badge = getFileBadge(cEntry, theme);
1117
- const nameBudget = Math.max(8, currentW - sizeLabel.length - 5);
1420
+ const nameBudget = Math.max(8, currentW - sizeLabel.length - 5 - markPrefixPlain.length);
1118
1421
  const clippedName = truncateAnsi(stripUnsafeAnsi(cEntry.name), nameBudget);
1119
1422
  if (selected) {
1120
- const inner = ` ▸ ${clippedName}${' '.repeat(Math.max(1, currentW - visibleLength(clippedName) - sizeLabel.length - 4))}${sizeLabel} `;
1423
+ const inner = ` ▸ ${markPrefixPlain}${clippedName}${' '.repeat(Math.max(1, currentW - visibleLength(clippedName) - markPrefixPlain.length - sizeLabel.length - 4))}${sizeLabel} `;
1121
1424
  rowStr += `${bg(theme.selectionBg)}${fg(theme.selectionFg)}${BOLD}${fitAnsi(inner, currentW)}${RESET}`;
1122
1425
  }
1123
1426
  else {
1124
1427
  const color = cEntry.isDirectory ? theme.dir : theme.text;
1125
- const left = ` ${badge} ${fg(color)}${clippedName}${RESET}`;
1428
+ const left = ` ${badge} ${markPrefixStyled}${fg(color)}${clippedName}${RESET}`;
1126
1429
  const pad = ' '.repeat(Math.max(1, currentW - visibleLength(left) - sizeLabel.length - 1));
1127
1430
  rowStr += fitAnsi(`${left}${pad}${fg(theme.muted)}${DIM}${sizeLabel}${RESET} `, currentW);
1128
1431
  }
@@ -1180,14 +1483,14 @@ export class ExploreioApp {
1180
1483
  create: 'Criar arquivo ou pasta/ : ',
1181
1484
  duplicate: 'Duplicar para: ',
1182
1485
  rename: 'Renomear para: ',
1183
- delete: `Excluir "${this.currentEntries[this.selectedIndex]?.name ?? ''}"? (y/N): `,
1486
+ delete: this.buildDeletePromptLabel(),
1184
1487
  'git-commit': 'git commit -m : ',
1185
1488
  'git-branch-create': 'Nova branch (git checkout -b): ',
1186
1489
  'git-confirm': `${this.gitPendingConfirm?.label ?? 'Confirmar operação Git'}? (y/N): `,
1187
1490
  'keybinds-filter': 'Filtrar keybinds: ',
1188
1491
  'keybinds-reset-confirm': 'Restaurar TODOS os keybinds para o padrão? (y/N): ',
1189
1492
  };
1190
- const text = ` ${labels[this.promptKind]}${this.promptInput}█`;
1493
+ const text = ` ${labels[this.promptKind]}${stripUnsafeAnsi(this.promptInput)}█`;
1191
1494
  return `${bg(theme.selectionBg)}${fg(theme.selectionFg)}${BOLD}${fitAnsi(text, width)}${RESET}`;
1192
1495
  }
1193
1496
  if (this.view === 'keybinds' && this.keybindsCaptureMode) {
@@ -1195,7 +1498,7 @@ export class ExploreioApp {
1195
1498
  return `${bg(theme.selectionBg)}${fg(theme.selectionFg)}${BOLD}${fitAnsi(` ◉ Pressione a nova tecla para ${modeText} (Esc cancela)`, width)}${RESET}`;
1196
1499
  }
1197
1500
  if (this.toastMessage) {
1198
- return `${bg(theme.statusBg)}${fg(theme.warning)}${BOLD}${fitAnsi(` ◆ ${this.toastMessage}`, width)}${RESET}`;
1501
+ return `${bg(theme.statusBg)}${fg(theme.warning)}${BOLD}${fitAnsi(` ◆ ${stripUnsafeAnsi(this.toastMessage)}`, width)}${RESET}`;
1199
1502
  }
1200
1503
  if (this.view === 'keybinds') {
1201
1504
  const hint = ' Esc/q Voltar · ↑↓ Selecionar · Enter Capturar · +/a Add tecla · d/Bksp Remover · r Reset · R Reset Tudo · s Salvar · / Filtrar · 1-5/Tab Abas';
@@ -1221,72 +1524,28 @@ export class ExploreioApp {
1221
1524
  }
1222
1525
  const pos = this.currentEntries.length > 0 ? `${this.selectedIndex + 1}/${this.currentEntries.length}` : '0/0';
1223
1526
  const filterTag = this.filterQuery ? ` [filtro: ${this.filterQuery}]` : '';
1527
+ const selTag = this.selectedPaths.size > 0 ? ` [● ${this.selectedPaths.size} sel]` : '';
1528
+ const pasteKey = this.keybinds.formatActionKeys('browser.paste', '/');
1529
+ const clipTag = this.fsClipboard
1530
+ ? this.fsClipboard.mode === 'copy'
1531
+ ? ` [⧉ copiar ${this.fsClipboard.paths.length} · ${pasteKey}]`
1532
+ : ` [✂ mover ${this.fsClipboard.paths.length} · ${pasteKey}]`
1533
+ : '';
1224
1534
  const kbKey = this.keybinds.formatActionKeys('global.openKeybinds', '/');
1225
1535
  const helpKey = this.keybinds.formatActionKeys('global.help', '/');
1226
1536
  const quitKey = this.keybinds.formatActionKeys('global.quit', '/');
1227
- const hint = ` ${pos}${filterTag} · Enter Ler · Tab/Ctrl+G Git · e Vim · ${kbKey} Binds · t Tema · ${helpKey} Ajuda · ${quitKey} Sair`;
1537
+ const hint = ` ${pos}${filterTag}${selTag}${clipTag} · Enter Ler · Tab/Ctrl+G Git · e Vim · ${kbKey} Binds · ${helpKey} Ajuda · ${quitKey} Sair`;
1228
1538
  return `${bg(theme.statusBg)}${fg(theme.statusFg)}${fitAnsi(hint, width)}${RESET}`;
1229
1539
  }
1230
1540
  overlayHelpModal(lines, width, height, theme) {
1231
- const boxW = Math.min(82, width - 4);
1232
- const k = (id) => this.keybinds.formatActionKeys(id, '/');
1233
- const row = (keys, desc) => ` ${keys.padEnd(18).slice(0, 18)} ${desc}`;
1234
- const kbKey = k('global.openKeybinds');
1235
- const helpItems = [
1236
- ' NAVEGADOR (3 Painéis estilo Yazi)',
1237
- row(`${k('browser.moveUp')} · ${k('browser.moveDown')}`, 'Mover seleção (roda do mouse suportada)'),
1238
- row(k('browser.open'), 'Entrar na pasta ou ABRIR ARQUIVO NO LEITOR'),
1239
- row(k('browser.parentDir'), 'Subir para diretório pai'),
1240
- row(k('browser.filter'), 'Filtrar arquivos (fuzzy)'),
1241
- row(k('browser.toggleHidden'), 'Mostrar/ocultar arquivos ocultos'),
1242
- row(k('browser.copyPath'), 'Copiar caminho selecionado (arquivo ou pasta)'),
1243
- row(`${k('browser.createFile')} / ${k('browser.createFolder')}`, 'Novo arquivo (com extensão) / Nova pasta cross-OS'),
1244
- row(`${k('browser.duplicateEntry')} / ${k('browser.renameEntry')} / ${k('browser.deleteEntry')}`, 'Duplicar / Renomear / Excluir (com confirmação)'),
1245
- row(k('browser.openGitPanel'), 'Abrir PAINEL GIT / GITHUB (status, árvore, branches, PRs)'),
1246
- '',
1247
- ' PAINEL GIT / GITHUB',
1248
- row(`1-4 / ${k('git.nextTab')}`, 'Alternar abas (Status/Parados · Árvore · Branches · GitHub)'),
1249
- row(`${k('git.stageToggle')} · ${k('git.stageAll')} · ${k('git.commit')}`, 'Stage/Unstage · Stage All · Commit com mensagem'),
1250
- row(`${k('git.pull')}/${k('git.push')}/${k('git.fetch')}/${k('git.createBranch')}`, `Pull · Push · Fetch · Nova branch (${k('git.quickPalette')} paleta)`),
1251
- '',
1252
- ' MODO LEITOR FULLSCREEN (Markdown · Mermaid · JSON · HTML · Código)',
1253
- row(k('reader.toggleMode'), 'Alternar modo (Rendered↔Raw | Tree↔Pretty | Reader↔Source)'),
1254
- row(k('reader.openFullscreen'), 'Abrir arquivo em novo terminal TELA CHEIA'),
1255
- row(`${k('reader.jsonToggleNode')}`, `JSON Tree: alternar nó (${k('reader.jsonExpandAll')}=tudo, ${k('reader.jsonCollapseAll')}=recolher)`),
1256
- row(`${k('reader.search')} · ${k('reader.searchNext')}/${k('reader.searchPrev')}`, 'Buscar texto no arquivo e saltar ocorrências'),
1257
- row(k('reader.openEditor'), 'Abrir arquivo no EDITOR VIM NATIVO'),
1258
- row(k('global.cycleTheme'), 'Alternar tema (Midnight · Parchment Light · Nord)'),
1259
- row(k('reader.back'), 'Voltar ao navegador (ou sair)'),
1260
- '',
1261
- ' CUSTOMIZAÇÃO DE KEYBINDS (Pressione ' + kbKey + ' agora para editar!)',
1262
- row(kbKey, 'Abrir PAINEL INTERATIVO DE EDIÇÃO DE BINDS'),
1263
- row('~/.exploreiorc.json', 'Config base (rode "exploreio --init-config" para gerar)'),
1264
- '',
1265
- ' MODO EDITOR VIM (NORMAL · INSERT · VISUAL · COMMAND)',
1266
- row('i/I/a/A/o/O · Esc', 'Entrar em INSERT · voltar para NORMAL'),
1267
- row(':w · :wq · :q!', 'Salvar · Salvar e sair · Sair sem salvar · :<linha>'),
1268
- ];
1269
- const startRow = Math.max(1, Math.floor((height - (helpItems.length + 4)) / 2));
1270
- const padLeft = ' '.repeat(Math.max(0, Math.floor((width - boxW) / 2)));
1271
- const innerW = boxW - 2;
1272
- const modalLines = [
1273
- `${padLeft}${fg(theme.borderActive)}${BOLD}╭${'─'.repeat(innerW)}╮${RESET}`,
1274
- `${padLeft}${fg(theme.borderActive)}${BOLD}│${bg(theme.headerBg)}${fg(theme.accent)}${fitAnsi(` ◈ EXPLOREIO — ATALHOS (${kbKey} Editar Binds · Esc/? Fechar)`, innerW)}${RESET}${fg(theme.borderActive)}${BOLD}│${RESET}`,
1275
- ...helpItems.map((item) => {
1276
- const isHeader = item.startsWith(' NAVEGADOR') ||
1277
- item.startsWith(' PAINEL') ||
1278
- item.startsWith(' MODO') ||
1279
- item.startsWith(' CUSTOMIZAÇÃO');
1280
- return `${padLeft}${fg(theme.borderActive)}│${bg(theme.statusBg)}${fg(isHeader ? theme.accentAlt : theme.text)}${fitAnsi(item, innerW)}${RESET}${fg(theme.borderActive)}│${RESET}`;
1281
- }),
1282
- `${padLeft}${fg(theme.borderActive)}${BOLD}╰${'─'.repeat(innerW)}╯${RESET}`,
1283
- ];
1284
- modalLines.forEach((mLine, offset) => {
1285
- const targetRow = startRow + offset;
1286
- if (targetRow >= 0 && targetRow < lines.length) {
1287
- lines[targetRow] = mLine;
1288
- }
1541
+ const modalLines = renderHelpModalOverlay({
1542
+ activeTab: this.helpTab,
1543
+ keybinds: this.keybinds,
1544
+ width,
1545
+ height,
1546
+ theme,
1289
1547
  });
1548
+ applyModalOverlay(lines, modalLines, height);
1290
1549
  }
1291
1550
  // ==================== PAINEL GIT & GITHUB (SPEC-005) ====================
1292
1551
  refreshGitHeaderSummary() {
@@ -2019,6 +2278,7 @@ export class ExploreioApp {
2019
2278
  }
2020
2279
  this.view = this.keybindsReturnView;
2021
2280
  this.draw();
2281
+ this.flushDeferredExternalRefresh();
2022
2282
  return;
2023
2283
  }
2024
2284
  if (ev.char === 't') {