dsh-remote-vs 0.26.0 → 0.28.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.
Files changed (75) hide show
  1. package/README.en.md +112 -28
  2. package/README.md +84 -25
  3. package/THIRD-PARTY-NOTICES.md +7 -2
  4. package/lib/client.js +1237 -254
  5. package/lib/index.js +821 -17
  6. package/lib/types/changes/recorder.d.ts +119 -2
  7. package/lib/types/client/CodeEditor.d.ts +29 -0
  8. package/lib/types/client/OutlinePanel.d.ts +22 -0
  9. package/lib/types/client/ProcessesSection.d.ts +19 -0
  10. package/lib/types/client/api.d.ts +22 -2
  11. package/lib/types/client/blame-model.d.ts +77 -0
  12. package/lib/types/client/changes/apply-failure.d.ts +41 -0
  13. package/lib/types/client/changes/block-confirm.d.ts +97 -0
  14. package/lib/types/client/changes/diff-outcome.d.ts +56 -0
  15. package/lib/types/client/changes/freshness.d.ts +51 -0
  16. package/lib/types/client/changes/model.d.ts +19 -1
  17. package/lib/types/client/changes/session-diff.d.ts +100 -0
  18. package/lib/types/client/changes/staleness.d.ts +98 -0
  19. package/lib/types/client/changes/turn-reverted.d.ts +82 -0
  20. package/lib/types/client/changes/turn-view.d.ts +131 -0
  21. package/lib/types/client/changes/undo-affordance.d.ts +44 -10
  22. package/lib/types/client/changes/undo-target.d.ts +12 -0
  23. package/lib/types/client/i18n.d.ts +1 -1
  24. package/lib/types/client/outline-model.d.ts +59 -0
  25. package/lib/types/client/scm/actions.d.ts +12 -1
  26. package/lib/types/client/store.d.ts +109 -1
  27. package/lib/types/client/vsc/blame.d.ts +19 -0
  28. package/lib/types/client/vsc/change-marks.d.ts +21 -0
  29. package/lib/types/client/vsc/kit.d.ts +0 -2
  30. package/lib/types/client/vsc/preview-document.d.ts +46 -0
  31. package/lib/types/client/vsc/preview-model.d.ts +31 -0
  32. package/lib/types/client/vsc/preview-services.d.ts +24 -0
  33. package/lib/types/git-ops.d.ts +18 -0
  34. package/lib/types/processes.d.ts +43 -0
  35. package/lib/types/protocol.d.ts +133 -1
  36. package/package.json +2 -1
  37. package/src/changes/recorder.ts +851 -8
  38. package/src/client/CodeEditor.tsx +86 -4
  39. package/src/client/EditorPane.tsx +581 -41
  40. package/src/client/MonitorView.tsx +16 -5
  41. package/src/client/OutlinePanel.tsx +287 -0
  42. package/src/client/ProcessesSection.tsx +292 -0
  43. package/src/client/api.ts +38 -3
  44. package/src/client/blame-model.ts +242 -0
  45. package/src/client/changes/ChangesDock.tsx +539 -54
  46. package/src/client/changes/apply-failure.ts +73 -0
  47. package/src/client/changes/block-confirm.ts +180 -0
  48. package/src/client/changes/changes.css +45 -0
  49. package/src/client/changes/diff-outcome.ts +97 -0
  50. package/src/client/changes/freshness.ts +68 -0
  51. package/src/client/changes/model.ts +56 -1
  52. package/src/client/changes/session-diff.ts +187 -0
  53. package/src/client/changes/staleness.ts +148 -0
  54. package/src/client/changes/turn-reverted.ts +254 -0
  55. package/src/client/changes/turn-view.ts +195 -0
  56. package/src/client/changes/undo-affordance.ts +295 -63
  57. package/src/client/changes/undo-target.ts +12 -0
  58. package/src/client/i18n.ts +294 -2
  59. package/src/client/index.tsx +4 -0
  60. package/src/client/outline-model.ts +775 -0
  61. package/src/client/scm/DiffView.tsx +32 -13
  62. package/src/client/scm/HistoryPanel.tsx +38 -1
  63. package/src/client/scm/actions.ts +55 -2
  64. package/src/client/store.tsx +446 -21
  65. package/src/client/vsc/blame.ts +147 -0
  66. package/src/client/vsc/change-marks.ts +21 -0
  67. package/src/client/vsc/kit.tsx +3 -11
  68. package/src/client/vsc/preview-document.tsx +326 -0
  69. package/src/client/vsc/preview-model.ts +216 -0
  70. package/src/client/vsc/preview-services.ts +118 -0
  71. package/src/client/vsc/vsc.css +965 -39
  72. package/src/git-ops.ts +34 -0
  73. package/src/processes.ts +177 -0
  74. package/src/protocol.ts +138 -1
  75. package/src/routes.ts +138 -9
@@ -28,14 +28,24 @@ import { isConnectionFailure, useConnectionStatus } from './connection.ts'
28
28
  import { sameLocalDir } from './composer.ts'
29
29
  import { editorViewStateOf, pruneEditorViewStates, registerLiveEditor, rememberEditorViewState } from './live-editor.ts'
30
30
  import { useRemoteChatTarget } from './use-remote-chat-target.ts'
31
- import { useExplorer, gotoChange, markChangeStale, undoChange, type EditorTab } from './store.tsx'
31
+ import { useExplorer, gotoChange, markChangeStale, repoRelative, undoChange, type EditorTab } from './store.tsx'
32
+ import { blockIdForMark, isStoredBlockConfirmed, toggleStoredBlock, type ConfirmStorage } from './changes/block-confirm.ts'
33
+ import { changeOriginForTab } from './changes/undo-target.ts'
34
+ import type { ChangeMark } from './vsc/change-marks.ts'
32
35
  import { DiffView } from './scm/DiffView.tsx'
36
+ import { loadBlame, loadFileHistory } from './scm/actions.ts'
37
+ import { isCommittedBlame, planBlameWindow, type BlameLine, type FileHistoryCommit } from './blame-model.ts'
33
38
  import { Btn } from './ui.tsx'
34
- import { renderMarkdown } from './vsc/markdown.tsx'
39
+ import { MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives'
35
40
  import { langLabel, langFromPath } from './vsc/tokenize.ts'
36
- import { installSaveShortcut } from './vsc/save-shortcut.ts'
41
+ import { FOREIGN_TARGET, installSaveShortcut, isModalLayerOpen } from './vsc/save-shortcut.ts'
42
+ import { OutlinePanel } from './OutlinePanel.tsx'
43
+ import type { OutlineEntry } from './outline-model.ts'
37
44
  import { Breadcrumb } from './vsc/breadcrumb.tsx'
38
45
  import { ImagePreview } from './vsc/image-preview.tsx'
46
+ import { hasTextSource, isBytePreview, previewKindLabel, previewKindOf, type PreviewKind } from './vsc/preview-model.ts'
47
+ import { BytePreview, SvgPreview, TablePreview } from './vsc/preview-document.tsx'
48
+ import { isDarkScheme, subscribeColorScheme } from './theme.ts'
39
49
  import {
40
50
  editorSettingsSnapshot,
41
51
  stepFontSize,
@@ -66,6 +76,48 @@ import {
66
76
  /** How many hunks of a conflict diff are rendered before the rest is summarised. */
67
77
  const CONFLICT_DIFF_HUNKS = 20
68
78
 
79
+ /**
80
+ * 「大纲」是否可用:一个真正的文本文件 tab,读完且没读错,不是二进制/图片。
81
+ *
82
+ * 预览模式(markdown/HTML)也排除:那时 CodeMirror 被 CSS 隐藏,跳过去虽然改了
83
+ * 选区,屏幕上却什么也看不到 —— 一个看起来没反应的按钮比没有按钮更糟。
84
+ */
85
+ function outlineAvailable(tab: EditorTab | undefined): tab is EditorTab {
86
+ if (tab === undefined || tab.kind !== 'file') return false
87
+ if (tab.image || tab.binary || tab.loading || tab.error !== undefined) return false
88
+ return !(tab.preview && hasTextSource(previewKindOf(tab.fullPath)))
89
+ }
90
+
91
+ const BLAME_PREF_KEY = 'dsh-remote-vs.editor.blame'
92
+ const EMPTY_BLAME: ReadonlyMap<number, BlameLine> = new Map()
93
+
94
+ /** Inline blame is OFF by default; the user opts in and the choice survives a reload. */
95
+ function readBlamePreference(): boolean {
96
+ try {
97
+ return localStorage.getItem(BLAME_PREF_KEY) === '1'
98
+ } catch {
99
+ return false
100
+ }
101
+ }
102
+
103
+ function writeBlamePreference(value: boolean): void {
104
+ try {
105
+ localStorage.setItem(BLAME_PREF_KEY, value ? '1' : '0')
106
+ } catch {
107
+ // Private mode: the preference simply does not persist.
108
+ }
109
+ }
110
+
111
+ /** Number of lines a loaded buffer has (the last empty line still counts). */
112
+ function lineCountOf(text: string): number {
113
+ if (text === '') return 1
114
+ let count = 1
115
+ for (let index = 0; index < text.length; index += 1) {
116
+ if (text.charCodeAt(index) === 10) count += 1
117
+ }
118
+ return count
119
+ }
120
+
69
121
  /**
70
122
  * Reject a remote call that never answers.
71
123
  *
@@ -318,6 +370,10 @@ function StatusBar(props: {
318
370
  export function EditorPane(props: { visible: boolean }): ReactNode {
319
371
  const store = useExplorer()
320
372
  const { t, tabs, activeTab, alias } = store
373
+ // Commands run in `repoRoot`, not in the workspace root: a repository that
374
+ // lives in a subdirectory (`repoSubdir`) would otherwise get a workspace-
375
+ // relative path and fail with `no such path`.
376
+ const repoRel = activeTab === undefined ? '' : repoRelative(store.repoRoot, activeTab.fullPath)
321
377
  const settings = useEditorSettings()
322
378
  /**
323
379
  * Which chrome this mount renders. Derived from the store's EFFECTIVE surface
@@ -384,6 +440,160 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
384
440
  useEffect(() => {
385
441
  setCaret(undefined)
386
442
  }, [activeTab?.id])
443
+
444
+ // --- inline blame + per-file history -------------------------------------
445
+ const [blameOn, setBlameOn] = useState<boolean>(readBlamePreference)
446
+ const [blameRows, setBlameRows] = useState<ReadonlyMap<number, BlameLine>>(EMPTY_BLAME)
447
+ const [blameViewport, setBlameViewport] = useState<{ from: number; to: number } | undefined>(undefined)
448
+ const [blameError, setBlameError] = useState<string | undefined>(undefined)
449
+ const blameTicket = useRef(0)
450
+ const blameRequested = useRef(new Set<string>())
451
+ const blameFailed = useRef('')
452
+ const blameViewportTimer = useRef<number | undefined>(undefined)
453
+ const [fileHistoryOpen, setFileHistoryOpen] = useState(false)
454
+ const [fileHistoryRows, setFileHistoryRows] = useState<FileHistoryCommit[]>([])
455
+ const [fileHistoryLoading, setFileHistoryLoading] = useState(false)
456
+ const [fileHistoryError, setFileHistoryError] = useState<string | undefined>(undefined)
457
+
458
+ // A new buffer (or an edited one) invalidates both windows and their line
459
+ // numbers; the next viewport report starts a fresh read.
460
+ useEffect(() => {
461
+ blameTicket.current += 1
462
+ blameRequested.current.clear()
463
+ blameFailed.current = ''
464
+ setBlameViewport(undefined)
465
+ setBlameRows(EMPTY_BLAME)
466
+ setBlameError(undefined)
467
+ setFileHistoryOpen(false)
468
+ setFileHistoryRows([])
469
+ setFileHistoryError(undefined)
470
+ }, [activeTab?.id, activeTab?.dirty, activeTab?.reloadNonce])
471
+
472
+ const toggleBlame = useCallback(() => {
473
+ setBlameOn(current => {
474
+ const next = !current
475
+ writeBlamePreference(next)
476
+ return next
477
+ })
478
+ }, [])
479
+
480
+ /**
481
+ * One `-L` read per uncovered viewport window.
482
+ *
483
+ * `blameRequested` is the cheap "this exact window was already asked for"
484
+ * guard; it is cleared on a buffer/dirty change, and a failed read deletes its
485
+ * key so a later scroll can retry it. Only one request may be in flight —
486
+ * CodeMirror scroll events are frequent and the exec channel is shared.
487
+ */
488
+ useEffect(() => {
489
+ const tab = activeTab
490
+ if (
491
+ !blameOn || tab === undefined || tab.kind !== 'file' || tab.loading || tab.dirty || tab.binary || tab.truncated || tab.preview
492
+ || isBytePreview(previewKindOf(tab.fullPath))
493
+ || alias === '' || store.repoRoot === undefined || repoRel === '' || blameViewport === undefined
494
+ ) {
495
+ setBlameRows(EMPTY_BLAME)
496
+ return
497
+ }
498
+ const total = lineCountOf(tab.text)
499
+ const failureKey = `${tab.id}:${tab.reloadNonce ?? 0}:${repoRel}:${blameOn ? '1' : '0'}`
500
+ if (blameFailed.current === failureKey) return
501
+ const window = planBlameWindow(
502
+ blameViewport.from,
503
+ blameViewport.to,
504
+ total,
505
+ new Set(blameRows.keys()),
506
+ )
507
+ if (window === undefined) return
508
+ const { from, to } = window
509
+ const key = `${tab.id}:${tab.reloadNonce ?? 0}:${from}:${to}`
510
+ if (blameRequested.current.has(key)) return
511
+ blameRequested.current.add(key)
512
+ const ticket = ++blameTicket.current
513
+ const controller = new AbortController()
514
+ void loadBlame(alias, store.repoRoot, repoRel, from, to, { signal: controller.signal })
515
+ .then((rows) => {
516
+ if (ticket !== blameTicket.current) return
517
+ setBlameRows((previous) => {
518
+ const next = new Map(previous)
519
+ for (const row of rows) next.set(row.line, row)
520
+ return next
521
+ })
522
+ setBlameError(undefined)
523
+ })
524
+ .catch((error: unknown) => {
525
+ blameRequested.current.delete(key)
526
+ if (controller.signal.aborted) return
527
+ if (ticket !== blameTicket.current) return
528
+ blameFailed.current = failureKey
529
+ setBlameError(error instanceof Error ? error.message : String(error))
530
+ })
531
+ return () => { controller.abort() }
532
+ }, [
533
+ activeTab?.id,
534
+ activeTab?.dirty,
535
+ activeTab?.reloadNonce,
536
+ blameOn,
537
+ blameRows,
538
+ blameViewport?.from,
539
+ blameViewport?.to,
540
+ alias,
541
+ repoRel,
542
+ store.repoRoot,
543
+ ])
544
+
545
+ const onEditorViewport = useCallback((first: number, last: number) => {
546
+ if (blameViewportTimer.current !== undefined) window.clearTimeout(blameViewportTimer.current)
547
+ blameViewportTimer.current = window.setTimeout(() => {
548
+ blameViewportTimer.current = undefined
549
+ setBlameViewport(previous => (
550
+ previous !== undefined && previous.from === first && previous.to === last
551
+ ? previous
552
+ : { from: first, to: last }
553
+ ))
554
+ }, 140)
555
+ }, [])
556
+ useEffect(() => () => {
557
+ if (blameViewportTimer.current !== undefined) window.clearTimeout(blameViewportTimer.current)
558
+ }, [])
559
+
560
+ useEffect(() => {
561
+ const tab = activeTab
562
+ if (!fileHistoryOpen || tab === undefined || tab.kind !== 'file' || alias === '' || store.repoRoot === undefined || repoRel === '') {
563
+ setFileHistoryRows([])
564
+ setFileHistoryError(undefined)
565
+ setFileHistoryLoading(false)
566
+ return
567
+ }
568
+ let cancelled = false
569
+ setFileHistoryLoading(true)
570
+ setFileHistoryError(undefined)
571
+ void loadFileHistory(alias, store.repoRoot, repoRel, 100)
572
+ .then((rows) => {
573
+ if (cancelled) return
574
+ setFileHistoryRows(rows)
575
+ setFileHistoryLoading(false)
576
+ })
577
+ .catch((error: unknown) => {
578
+ if (cancelled) return
579
+ setFileHistoryError(error instanceof Error ? error.message : String(error))
580
+ setFileHistoryLoading(false)
581
+ })
582
+ return () => { cancelled = true }
583
+ }, [fileHistoryOpen, activeTab?.id, activeTab?.dirty, alias, repoRel, store.repoRoot])
584
+
585
+ useEffect(() => {
586
+ if (!fileHistoryOpen) return
587
+ const onKeyDown = (event: KeyboardEvent): void => {
588
+ if (event.key !== 'Escape') return
589
+ event.preventDefault()
590
+ event.stopPropagation()
591
+ setFileHistoryOpen(false)
592
+ }
593
+ window.addEventListener('keydown', onKeyDown, true)
594
+ return () => window.removeEventListener('keydown', onKeyDown, true)
595
+ }, [fileHistoryOpen])
596
+
387
597
  /**
388
598
  * The "see the difference" payload of a refused save.
389
599
  *
@@ -491,26 +701,64 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
491
701
  const previewIsHtml = activeTab?.html === true
492
702
  const previewIsMarkdown = activeTab?.markdown === true
493
703
  const previewVisible = activeTab?.preview === true
704
+ const previewKind: PreviewKind = activeTab?.kind === 'file' ? previewKindOf(activeTab.fullPath) : 'text'
705
+ const bytePreview = isBytePreview(previewKind)
706
+
707
+ const darkScheme = useSyncExternalStore(subscribeColorScheme, isDarkScheme)
494
708
 
495
- const htmlDoc = useMemo(() => (previewIsHtml ? (previewText ?? '') : ''), [previewIsHtml, previewText])
709
+ const htmlDoc = useMemo(() => {
710
+ if (!previewIsHtml) return ''
711
+ const dark = darkScheme
712
+ const csp = [
713
+ "default-src 'none'",
714
+ "style-src 'unsafe-inline'",
715
+ 'img-src data: blob:',
716
+ 'font-src data:',
717
+ 'media-src data: blob:',
718
+ "form-action 'none'",
719
+ "base-uri 'none'",
720
+ ].join('; ')
721
+ return [
722
+ '<!doctype html><meta charset="utf-8">',
723
+ `<meta http-equiv="Content-Security-Policy" content="${csp}">`,
724
+ '<style>',
725
+ `:root{color-scheme:${dark ? 'dark' : 'light'}}`,
726
+ `html,body{background:${dark ? '#1e1e1e' : '#ffffff'};color:${dark ? '#d4d4d4' : '#1f1f1f'}}`,
727
+ 'body{margin:14px;font:14px/1.65 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;overflow-wrap:break-word}',
728
+ 'img,video,canvas{max-width:100%;height:auto}',
729
+ 'table{border-collapse:collapse}',
730
+ `td,th{border:1px solid ${dark ? 'rgba(255,255,255,.14)' : 'rgba(0,0,0,.12)'};padding:4px 8px}`,
731
+ 'pre{overflow:auto}',
732
+ '</style>',
733
+ previewText ?? '',
734
+ ].join('')
735
+ }, [previewIsHtml, previewText, darkScheme])
736
+
737
+ /** Stable labels identity: the platform renderer keys its cache on it. */
738
+ const markdownLabels = useMemo(() => ({
739
+ code: {
740
+ copyLabel: t('preview.copyCode'),
741
+ copiedLabel: t('preview.copied'),
742
+ },
743
+ footnotes: t('preview.footnotes'),
744
+ }), [t])
496
745
 
497
746
  /**
498
- * The parsed Markdown preview.
499
- *
500
- * It used to be `renderMarkdown(activeTab.text)` inline in the JSX, which
501
- * re-parsed the whole document into a fresh element tree on EVERY store
502
- * publish: this component subscribes to the store, so opening another file,
503
- * saving, a git refresh or switching a panel all paid for a parse of text
504
- * that had not changed. `renderMarkdown` is a pure function of the text, so
505
- * the memo key is the TEXT (a stable identity while the bytes are) plus the
506
- * two mode flags — see `previewText` above for why the tab object is the wrong
507
- * key. The guards keep the parse from happening at all for a file that is
508
- * being read in source mode.
747
+ * Markdown preview through the host's platform renderer (the same one the
748
+ * chat uses): GFM tables, code highlighting and footnotes come for free and
749
+ * raw HTML in a remote document is not inserted into the app DOM.
509
750
  */
510
751
  const markdownPreview = useMemo(() => {
511
752
  if (!previewIsMarkdown || !previewVisible || previewText === undefined) return null
512
- return renderMarkdown(previewText)
513
- }, [previewIsMarkdown, previewVisible, previewText])
753
+ return (
754
+ <div className="rvs-preview-scroll">
755
+ {activeTab?.truncated === true && <div className="rvs-preview-banner">{t('preview.truncated')}</div>}
756
+ <div className="rvs-preview-markdown rvs-markdown" data-preview-path={activeTab?.fullPath ?? ''}>
757
+ <MarkdownText text={previewText} labels={markdownLabels} variant="body" />
758
+ </div>
759
+ </div>
760
+ )
761
+ }, [previewIsMarkdown, previewVisible, previewText, markdownLabels, activeTab?.fullPath, activeTab?.truncated, t])
514
762
 
515
763
  /**
516
764
  * The status bar's indent hint, derived from the loaded text.
@@ -771,11 +1019,114 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
771
1019
  const tab = saveShortcutTabRef.current
772
1020
  // Working-tree diffs are `DiffView`'s own onSave contract; previews have no
773
1021
  // buffer at all. `saveActive` would misreport both.
774
- if (tab === undefined || tab.kind !== 'file' || tab.image || tab.binary) return undefined
1022
+ if (tab === undefined || tab.kind !== 'file' || tab.image || tab.binary || isBytePreview(previewKindOf(tab.fullPath))) return undefined
775
1023
  return () => { void saveActiveRef.current() }
776
1024
  })
777
1025
  }, [props.visible])
778
1026
 
1027
+ // --- 符号大纲(Ctrl+Shift+O)---------------------------------------------
1028
+ /**
1029
+ * 打开中的大纲。
1030
+ *
1031
+ * 存的是「打开那一刻的实时缓冲区全文」,而不是 `tabId` + 每次渲染再去读 ——
1032
+ * 面板打开期间焦点在筛选框里,缓冲区不可能再变,所以一份快照足够;把全文放进
1033
+ * state 也让 `OutlinePanel` 的 `useMemo` 有稳定输入(不会每帧重扫文件)。
1034
+ *
1035
+ * `tabId` 留在里面是为了自检:换 tab 时旧大纲不能继续挂在屏幕上的新文件上。
1036
+ */
1037
+ const [outline, setOutline] = useState<{ tabId: string; path: string; text: string } | undefined>(undefined)
1038
+
1039
+ // 换 tab / 重载后旧大纲的行号已经不属于屏幕上的文件了:直接关掉,绝不猜。
1040
+ useEffect(() => {
1041
+ setOutline(undefined)
1042
+ }, [activeTab?.id, activeTab?.reloadNonce])
1043
+ // Hiding this surface (panel switch, rail tab, float window) must take the
1044
+ // portal down with it: the mask is `position: fixed` and would otherwise stay
1045
+ // painted over whatever surface replaced this one.
1046
+ useEffect(() => {
1047
+ if (!props.visible) setOutline(undefined)
1048
+ }, [props.visible])
1049
+
1050
+ const openOutline = useCallback(() => {
1051
+ const tab = saveShortcutTabRef.current
1052
+ if (!outlineAvailable(tab)) return
1053
+ // 实时 buffer 优先:`tab.text` 是加载时的字节,输入从来没有回写进去
1054
+ // (见下方 editor host 的注释)。dirty 文件只有这里能拿到正确内容。
1055
+ setOutline({ tabId: tab.id, path: tab.fullPath, text: editorRef.current?.getContent() ?? tab.text })
1056
+ }, [])
1057
+ const closeOutline = useCallback(() => { setOutline(undefined) }, [])
1058
+
1059
+ /**
1060
+ * 跳转:复用现有的「选中行区间 + 滚到中央 + 点灯」,1-based 行号。
1061
+ *
1062
+ * 跳转放到下一个 task:浮层卸载时会把焦点还给打开它的按钮(portal 的常规
1063
+ * 做法,见 QuickOpen),先 `revealRange` 再卸载的话,焦点会被那一步抢回去,
1064
+ * 用户接着敲的字就落空了。等卸载稳定后再把焦点交给编辑器。
1065
+ */
1066
+ const jumpToOutline = useCallback((entry: OutlineEntry) => {
1067
+ setOutline(undefined)
1068
+ window.setTimeout(() => { editorRef.current?.revealRange(entry.line, entry.line) }, 0)
1069
+ }, [])
1070
+
1071
+ // window 监听用 ref 取最新值:effect 只为可见性重装,不随每次渲染重装。
1072
+ const openOutlineRef = useRef(openOutline)
1073
+ openOutlineRef.current = openOutline
1074
+ const closeOutlineRef = useRef(closeOutline)
1075
+ closeOutlineRef.current = closeOutline
1076
+ const outlineOpenRef = useRef(false)
1077
+ outlineOpenRef.current = outline !== undefined
1078
+
1079
+ /**
1080
+ * Ctrl/Cmd+Shift+O:转到符号。
1081
+ *
1082
+ * 用 window 冒泡监听而不是 CodeMirror keymap:和 Ctrl+S 同理 —— 点过 tab 条、
1083
+ * 信息栏或侧栏之后光标已经不在编辑器里,keymap 根本不会触发。只在这个座位可见
1084
+ * 时安装(多个 EditorPane 可能同时挂载,隐藏的那个不该抢键)。
1085
+ *
1086
+ * 不抢别人的键:
1087
+ * - 终端:xterm 已经把 ^O 发给远端 shell(readline 的 operate-and-get-next),
1088
+ * 再开浮层就是一次按键两个动作;
1089
+ * - 其他输入框(聊天输入、对话框输入)与任何模态层(宿主审批、右键菜单)都保留
1090
+ * 这个键;
1091
+ * - 不满足条件时**不** preventDefault:浏览器自己的 Ctrl+Shift+O 在别处仍是它
1092
+ * 的(我们只接管自己确实要处理的那一次按键)。
1093
+ */
1094
+ useEffect(() => {
1095
+ if (!props.visible) return
1096
+ const onKey = (event: KeyboardEvent): void => {
1097
+ // Another owner (host shortcut, an outer handler) already claimed this
1098
+ // key: bubble phase must yield, same contract as save-shortcut.ts.
1099
+ if (event.defaultPrevented) return
1100
+ const ctrlShiftO = (event.ctrlKey || event.metaKey) && event.shiftKey && !event.altKey
1101
+ const altO = event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey
1102
+ if (!ctrlShiftO && !altO) return
1103
+ if (event.key.toLowerCase() !== 'o') return
1104
+ // 按住不放不该让浮层闪;输入法组字期间这也不是一个命令。
1105
+ if (event.repeat || event.isComposing === true) return
1106
+ // 自己开着:再按一次关闭(与 Ctrl+P 的「再按一次退出」同一习惯)。
1107
+ if (outlineOpenRef.current) {
1108
+ event.preventDefault()
1109
+ closeOutlineRef.current()
1110
+ return
1111
+ }
1112
+ if (isModalLayerOpen()) return
1113
+ const focused = document.activeElement
1114
+ if (focused instanceof HTMLElement && focused.closest('.xterm') !== null) return
1115
+ // CodeMirror 的 `.cm-content` 是 contenteditable,天然在 FOREIGN_TARGET 里:
1116
+ // 只放过**本插件编辑器**里那一份(`.rvs-editor-host` 的子树),宿主自己的
1117
+ // 聊天输入同样是 CodeMirror —— 在别人的编辑器里抢键和在别人的输入框里抢键
1118
+ // 是同一件事。
1119
+ if (focused instanceof HTMLElement
1120
+ && focused.closest(FOREIGN_TARGET) !== null
1121
+ && focused.closest('.rvs-editor-host') === null) return
1122
+ if (!outlineAvailable(saveShortcutTabRef.current)) return
1123
+ event.preventDefault()
1124
+ openOutlineRef.current()
1125
+ }
1126
+ window.addEventListener('keydown', onKey)
1127
+ return () => window.removeEventListener('keydown', onKey)
1128
+ }, [props.visible])
1129
+
779
1130
  if (tabs.length === 0) {
780
1131
  if (center) {
781
1132
  return (
@@ -809,14 +1160,71 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
809
1160
  */
810
1161
  const canSwitchToEdit = activeTab !== undefined
811
1162
  && activeTab.kind === 'diff'
1163
+ // 会话只读 diff 不开「切换为内容编辑」:它属于会话账本,编辑入口是面板左键
1164
+ // (会带着标记打开);这里再开一次只会打开一个没有标记的普通标签页。
1165
+ && activeTab.sessionDiff === undefined
812
1166
  && activeTab.ref === undefined
813
1167
  && activeTab.diff !== undefined
814
1168
  && !activeTab.diff.unsupported
815
1169
  && !(activeTab.diff.newText === '' && activeTab.diff.oldText !== '')
816
1170
  const displayPath = activeTab?.fullPath ?? ''
1171
+ /**
1172
+ * 信息栏里那句"这一页是什么 diff"。
1173
+ *
1174
+ * 三种来源必须分得清:会话账本的只读比较、暂存区(只读)、某个提交(历史)。
1175
+ * 写成一串 if 而不是嵌套三元:三种情况各说各的,读起来不会串行。
1176
+ */
1177
+ let diffScopeLabel = ''
1178
+ if (activeTab?.kind === 'diff') {
1179
+ if (activeTab.sessionDiff !== undefined) diffScopeLabel = t('changes.diffTabLabel')
1180
+ else if (activeTab.ref !== undefined) diffScopeLabel = `${t('scm.commitDiff')} ${activeTab.ref.slice(0, 7)}`
1181
+ else if (activeTab.staged) diffScopeLabel = t('scm.stagedReadonly')
1182
+ }
1183
+ /**
1184
+ * 编辑器悬浮栏的「确认保留」(块级本地笔记,见 `changes/block-confirm.ts`)。
1185
+ *
1186
+ * 三个前提缺一不可:这一页有改动标记、标记带着块标识(建标记时带了远端绝对路径)、
1187
+ * 以及这批标记有 provenance(会话归属 —— 笔记按会话存)。任何一个缺失就不提供这个
1188
+ * 动作,悬浮栏回到"只有撤销"。
1189
+ *
1190
+ * 读写都走 `localStorage`,**不发任何请求**:这是"我看到哪儿了"的记号,不是远端
1191
+ * 事实;状态变化不经过 React(编辑器在 React 之外点它),所以每次现读。
1192
+ */
1193
+ const blockConfirm = (() => {
1194
+ const set = activeTab?.changeSet
1195
+ if (activeTab === undefined || set === undefined || set === null) return undefined
1196
+ const blocks = set.blocks
1197
+ const sessionId = changeOriginForTab(activeTab.id)?.sessionId
1198
+ if (blocks === undefined || sessionId === undefined || sessionId === '') return undefined
1199
+ const storage = (): ConfirmStorage | undefined => {
1200
+ try {
1201
+ return window.localStorage
1202
+ } catch {
1203
+ // 隐私模式 / 禁用存储:不提供这一级(而不是给一个点了不生效的按钮)。
1204
+ return undefined
1205
+ }
1206
+ }
1207
+ return {
1208
+ isConfirmed: (mark: ChangeMark): boolean => {
1209
+ const id = blockIdForMark(blocks, mark)
1210
+ const store = storage()
1211
+ return id === undefined || store === undefined ? false : isStoredBlockConfirmed(store, sessionId, id)
1212
+ },
1213
+ onToggle: (mark: ChangeMark): void => {
1214
+ const id = blockIdForMark(blocks, mark)
1215
+ const store = storage()
1216
+ if (id === undefined || store === undefined) return
1217
+ toggleStoredBlock(store, sessionId, id)
1218
+ },
1219
+ label: (): string => t('changes.confirmBlock'),
1220
+ pressedLabel: (): string => t('changes.confirmedBlock'),
1221
+ }
1222
+ })()
817
1223
  const language = isDiff
818
1224
  ? 'Diff'
819
- : activeTab?.image === true ? 'Image' : langLabel(langFromPath(activeTab?.rel ?? ''))
1225
+ : activeTab?.image === true
1226
+ ? 'Image'
1227
+ : previewKindLabel(previewKind) ?? langLabel(langFromPath(activeTab?.rel ?? ''))
820
1228
  const activeImageKey = activeTab === undefined ? undefined : imageCacheKey(activeTab)
821
1229
  const imageSrc = activeTab !== undefined && activeTab.image && activeImageKey !== undefined
822
1230
  ? images[activeImageKey]
@@ -824,9 +1232,10 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
824
1232
  const imageFailure = activeTab !== undefined && activeTab.image && activeImageKey !== undefined
825
1233
  ? imageError[activeImageKey]
826
1234
  : undefined
1235
+ const caretBlame = caret === undefined ? undefined : blameRows.get(caret.line)
827
1236
 
828
1237
  return (
829
- <div className="rvs-pane grow rvs-edge" style={fontStyle}>
1238
+ <div className="rvs-pane grow rvs-edge" style={{ ...(fontStyle ?? {}), position: 'relative' }}>
830
1239
  {/* Tab strip: switch / close / dirty dot / diff glyph. Middle-click closes
831
1240
  too — the muscle memory shared with VS Code and browsers. */}
832
1241
  <div className="rvs-etabs" role="tablist" aria-label={t('editor.tabsLabel')}>
@@ -919,7 +1328,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
919
1328
  )
920
1329
  : <span className="rvs-einfo-path" title={displayPath}>{displayPath}</span>}
921
1330
  <span className="rvs-einfo-actions">
922
- {activeTab.kind === 'file' && (activeTab.markdown || activeTab.html) && (
1331
+ {activeTab.kind === 'file' && hasTextSource(previewKind) && (
923
1332
  <Segmented<'preview' | 'source'>
924
1333
  value={activeTab.preview ? 'preview' : 'source'}
925
1334
  onChange={(next) => store.updateTab(activeTab.id, { preview: next === 'preview' })}
@@ -930,10 +1339,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
930
1339
  />
931
1340
  )}
932
1341
  {activeTab.kind === 'diff' && (
933
- <span style={{ color: 'var(--rvs-fg3)' }}>
934
- {activeTab.staged && activeTab.ref === undefined ? t('scm.stagedReadonly') : ''}
935
- {activeTab.ref !== undefined ? `${t('scm.commitDiff')} ${activeTab.ref.slice(0, 7)}` : ''}
936
- </span>
1342
+ <span style={{ color: 'var(--rvs-fg3)' }}>{diffScopeLabel}</span>
937
1343
  )}
938
1344
  <span style={{ color: 'var(--rvs-fg3)' }}>{language}</span>
939
1345
  {/* Connection health sits where the build stamp does: it is the
@@ -944,7 +1350,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
944
1350
  so the stamp says WHICH code is running, and the token count
945
1351
  says whether the grammar actually produced colored tokens. */}
946
1352
  <span className="rvs-build" title={`dsh-remote-vs build ${__RVS_BUILD__}`}>{__RVS_BUILD__}</span>
947
- {tokenCount !== undefined && (
1353
+ {tokenCount !== undefined && !bytePreview && (
948
1354
  <span className="rvs-build" title={t('editor.tokenCount')}>tok {tokenCount}</span>
949
1355
  )}
950
1356
  {activeTab.kind === 'file' && (
@@ -953,19 +1359,34 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
953
1359
  both the class and the label, while the project's own
954
1360
  review checklist forbids nested ternaries. One lookup per
955
1361
  concern instead. */}
956
- <span className={`rvs-status ${tabStatusClass(activeTab)}`}>
957
- {t(tabStatusKey(activeTab))}
958
- </span>
1362
+ {!bytePreview && !activeTab.image && (
1363
+ <span className={`rvs-status ${tabStatusClass(activeTab)}`}>
1364
+ {t(tabStatusKey(activeTab))}
1365
+ </span>
1366
+ )}
959
1367
  <IconButton title={t('editor.reloadFile')} onClick={() => { void reloadWithGuard(activeTab) }} disabled={offline || activeTab.loading}>
960
1368
  <IconRefresh size={13} />
961
1369
  </IconButton>
962
- <IconButton
963
- title={`${t('editor.save')} (Ctrl+S)`}
964
- onClick={() => { void saveActive() }}
965
- disabled={offline || activeTab.loading || activeTab.binary || activeTab.truncated || !activeTab.dirty}
966
- >
967
- <IconSave size={13} />
968
- </IconButton>
1370
+ {!bytePreview && !activeTab.image && (
1371
+ <IconButton
1372
+ title={`${t('editor.save')} (Ctrl+S)`}
1373
+ onClick={() => { void saveActive() }}
1374
+ disabled={offline || activeTab.loading || activeTab.binary || activeTab.truncated || !activeTab.dirty}
1375
+ >
1376
+ <IconSave size={13} />
1377
+ </IconButton>
1378
+ )}
1379
+ {/* 大纲:只对文本文件出现。`≡` 是行内字形(与 blame 的 `B`、
1380
+ 浮窗的图标同一套做法),不额外引一个图标组件。 */}
1381
+ {!activeTab.image && !activeTab.binary && !isBytePreview(previewKind) && (
1382
+ <IconButton
1383
+ title={`${t('editor.outline')} (Ctrl+Shift+O)`}
1384
+ onClick={openOutline}
1385
+ disabled={!outlineAvailable(activeTab)}
1386
+ >
1387
+ <span className="rvs-glyph-text">≡</span>
1388
+ </IconButton>
1389
+ )}
969
1390
  </>
970
1391
  )}
971
1392
  {activeTab.kind === 'diff' && (
@@ -987,7 +1408,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
987
1408
  )}
988
1409
  </>
989
1410
  )}
990
- {activeTab.kind === 'file' && !activeTab.image && !activeTab.binary && (
1411
+ {activeTab.kind === 'file' && !activeTab.image && !activeTab.binary && !bytePreview && (
991
1412
  <IconButton
992
1413
  title={t('editor.wrap')}
993
1414
  onClick={() => updateEditorSettings({ wrap: !settings.wrap })}
@@ -995,11 +1416,37 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
995
1416
  <IconWrap size={13} />
996
1417
  </IconButton>
997
1418
  )}
1419
+ {activeTab.kind === 'file' && !activeTab.image && !activeTab.binary && !isBytePreview(previewKind) && repoRel !== '' && (
1420
+ <>
1421
+ <IconButton
1422
+ title={blameError === undefined ? t('editor.blameToggle') : `${t('editor.blameToggle')}: ${blameError}`}
1423
+ className={blameOn ? 'rvs-hbtn-on' : undefined}
1424
+ onClick={toggleBlame}
1425
+ >
1426
+ <span className="rvs-glyph-text">B</span>
1427
+ </IconButton>
1428
+ <IconButton
1429
+ title={t('editor.fileHistory')}
1430
+ className={fileHistoryOpen ? 'rvs-hbtn-on' : undefined}
1431
+ onClick={() => { setFileHistoryOpen(open => !open) }}
1432
+ >
1433
+ <IconDiff size={13} />
1434
+ </IconButton>
1435
+ {blameOn && caretBlame !== undefined && isCommittedBlame(caretBlame.hash) && (
1436
+ <IconButton
1437
+ title={t('editor.blameOpenCaret')}
1438
+ onClick={() => { store.focusCommit(caretBlame.hash) }}
1439
+ >
1440
+ <span className="rvs-glyph-text">↗</span>
1441
+ </IconButton>
1442
+ )}
1443
+ </>
1444
+ )}
998
1445
  <span className="rvs-einfo-actions-divider" aria-hidden="true" />
999
1446
  {/* The floating window owns its OWN Ctrl+wheel zoom (a property of
1000
1447
  that window, persisted per window): the shared preference is not
1001
1448
  what paints there, so these two would look dead inside it. */}
1002
- {variant !== 'float' && (
1449
+ {variant !== 'float' && !bytePreview && !activeTab.image && activeTab.kind !== 'diff' && (
1003
1450
  <>
1004
1451
  <IconButton
1005
1452
  title={t('editor.fontSmaller')}
@@ -1039,6 +1486,65 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
1039
1486
  </span>
1040
1487
  </div>
1041
1488
 
1489
+ {fileHistoryOpen && activeTab.kind === 'file' && (
1490
+ <div className="rvs-file-history" role="dialog" aria-label={t('editor.fileHistory')}>
1491
+ <div className="rvs-file-history-head">
1492
+ <span className="rvs-file-history-title">{t('editor.fileHistory')}</span>
1493
+ <span className="rvs-file-history-path" title={repoRel}>{repoRel}</span>
1494
+ <button
1495
+ type="button"
1496
+ className="rvs-file-history-close"
1497
+ title={t('common.close')}
1498
+ aria-label={t('common.close')}
1499
+ onClick={() => { setFileHistoryOpen(false) }}
1500
+ >
1501
+ <IconClose size={11} />
1502
+ </button>
1503
+ </div>
1504
+ {fileHistoryLoading && <div className="rvs-file-history-note">{t('common.loading')}</div>}
1505
+ {!fileHistoryLoading && fileHistoryError !== undefined && (
1506
+ <div className="rvs-file-history-note error">{fileHistoryError}</div>
1507
+ )}
1508
+ {!fileHistoryLoading && fileHistoryError === undefined && fileHistoryRows.length === 0 && (
1509
+ <div className="rvs-file-history-note">{t('editor.fileHistoryEmpty')}</div>
1510
+ )}
1511
+ {!fileHistoryLoading && fileHistoryError === undefined && fileHistoryRows.length > 0 && (
1512
+ <div className="rvs-file-history-list">
1513
+ {fileHistoryRows.map(commit => (
1514
+ <button
1515
+ type="button"
1516
+ key={commit.hash}
1517
+ className="rvs-file-history-row"
1518
+ onClick={() => {
1519
+ setFileHistoryOpen(false)
1520
+ store.openCommitFile(commit.hash, commit.path, commit.origPath)
1521
+ }}
1522
+ >
1523
+ <span className="rvs-file-history-hash">{commit.hash.slice(0, 7)}</span>
1524
+ <span className="rvs-file-history-subject" title={commit.subject}>{commit.subject}</span>
1525
+ <span className="rvs-file-history-meta">
1526
+ {commit.author} · {new Date(commit.date * 1000).toLocaleDateString()}
1527
+ </span>
1528
+ </button>
1529
+ ))}
1530
+ </div>
1531
+ )}
1532
+ </div>
1533
+ )}
1534
+
1535
+ {/* 大纲浮层:portal 到 <body>,所以放在 JSX 的哪一层都不影响定位;
1536
+ 放在信息栏旁边只是让它和触发它的按钮读在一起。`tabId` 判定是最后
1537
+ 一道闸:换 tab 之后旧大纲绝不挂在新文件上。 */}
1538
+ {outline !== undefined && outline.tabId === activeTab.id && (
1539
+ <OutlinePanel
1540
+ t={t}
1541
+ path={outline.path}
1542
+ text={outline.text}
1543
+ onPick={jumpToOutline}
1544
+ onClose={closeOutline}
1545
+ />
1546
+ )}
1547
+
1042
1548
  <div className="rvs-body" ref={bodyRef}>
1043
1549
  {/*
1044
1550
  A REFUSED save: the remote file moved on, so nothing was written.
@@ -1155,6 +1661,32 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
1155
1661
  <div>{imageFailure ?? t('common.loading')}</div>
1156
1662
  </div>
1157
1663
  )}
1664
+ {!activeTab.image && isBytePreview(previewKind) && (
1665
+ <BytePreview
1666
+ alias={alias}
1667
+ path={activeTab.fullPath}
1668
+ sessionId={chatEnabled ? chat.sessionId : undefined}
1669
+ kind={previewKind}
1670
+ revision={activeTab.reloadNonce ?? 0}
1671
+ t={t}
1672
+ />
1673
+ )}
1674
+ {!activeTab.image && !activeTab.binary && activeTab.preview && previewKind === 'svg' && (
1675
+ <SvgPreview
1676
+ path={activeTab.rel}
1677
+ text={previewText ?? ''}
1678
+ truncated={activeTab.truncated}
1679
+ t={t}
1680
+ />
1681
+ )}
1682
+ {!activeTab.image && !activeTab.binary && activeTab.preview && previewKind === 'table' && (
1683
+ <TablePreview
1684
+ path={activeTab.rel}
1685
+ text={previewText ?? ''}
1686
+ truncated={activeTab.truncated}
1687
+ t={t}
1688
+ />
1689
+ )}
1158
1690
  {!activeTab.image && activeTab.binary && (
1159
1691
  <div className="rvs-editor-notice">
1160
1692
  <div className="rvs-editor-notice-title">{t('editor.binaryTitle')}</div>
@@ -1164,7 +1696,10 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
1164
1696
  )}
1165
1697
  {!activeTab.image && !activeTab.binary && activeTab.markdown && activeTab.preview && markdownPreview}
1166
1698
  {!activeTab.image && !activeTab.binary && activeTab.html && activeTab.preview && (
1167
- <iframe className="rvs-html-frame" title={activeTab.rel} sandbox="allow-same-origin" srcDoc={htmlDoc} />
1699
+ <div className="rvs-preview-frame-wrap">
1700
+ {activeTab.truncated && <div className="rvs-preview-banner">{t('preview.truncated')}</div>}
1701
+ <iframe className="rvs-html-frame" title={activeTab.rel} sandbox="" srcDoc={htmlDoc} />
1702
+ </div>
1168
1703
  )}
1169
1704
  {/* The editor host stays MOUNTED and is hidden with CSS in
1170
1705
  preview mode. Unmounting it (the old behaviour) rebuilt the
@@ -1175,9 +1710,9 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
1175
1710
  caret across preview/source switches, and sibling surfaces
1176
1711
  (the image/HTML previews) end up in the same DOM positions
1177
1712
  as before, so their own remount behaviour is unchanged. */}
1178
- {!activeTab.image && !activeTab.binary && (
1713
+ {!activeTab.image && !activeTab.binary && !isBytePreview(previewKind) && (
1179
1714
  <div
1180
- className={`rvs-editor-host${activeTab.preview && (activeTab.markdown || activeTab.html) ? ' rvs-hidden' : ''}`}
1715
+ className={`rvs-editor-host${activeTab.preview && hasTextSource(previewKind) ? ' rvs-hidden' : ''}`}
1181
1716
  >
1182
1717
  {activeTab.truncated && <div className="rvs-banner warn">{t('editor.truncated')}</div>}
1183
1718
  <CodeEditor
@@ -1198,6 +1733,9 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
1198
1733
  {...(activeTab.line === undefined ? {} : { revealLine: activeTab.line })}
1199
1734
  {...(activeTab.lineNonce === undefined ? {} : { revealNonce: activeTab.lineNonce })}
1200
1735
  {...(activeTab.changeSet === undefined ? {} : { changeSet: activeTab.changeSet })}
1736
+ blame={blameOn ? blameRows : undefined}
1737
+ onOpenBlame={(entry) => { store.focusCommit(entry.hash) }}
1738
+ onViewport={onEditorViewport}
1201
1739
  {...(activeTab.revealHunkLine === undefined ? {} : { revealHunkLine: activeTab.revealHunkLine })}
1202
1740
  {...(activeTab.revealHunkNonce === undefined ? {} : { revealHunkNonce: activeTab.revealHunkNonce })}
1203
1741
  {...(editorViewStateOf(activeTab.id) === undefined
@@ -1210,6 +1748,8 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
1210
1748
  onChangeStale={() => { markChangeStale(activeTab.id) }}
1211
1749
  onUndoChange={(mark) => { void undoChange(activeTab.id, mark) }}
1212
1750
  undoLabel={(mark) => undoActionLabel(t, mark.kind)}
1751
+ undoTriggerLabel={() => t('changes.actions')}
1752
+ {...(blockConfirm === undefined ? {} : { blockConfirm })}
1213
1753
  onSave={() => { void saveActive() }}
1214
1754
  onDirty={(dirty) => store.updateTab(activeTab.id, { dirty })}
1215
1755
  onBuffer={(tabId, text) => store.updateTab(tabId, { text })}