Skip to content

Viewing mode on desktop: a personal switch that turns your own typing off #613

Open

Description

@HMarzban

Summary

Add a personal Editing / Viewing mode to the desktop pad. Viewing stops your own typing; the document, the chat and other people do not change. It is never the Editing lock and never access (CONTEXT.md §Document access, Viewing mode). It follows the Google Docs mode menu. There is no Suggesting mode. The two keys match Google Docs.

What the user sees

  • Mode control. The first toolbar control reads "Editing ▾" (pencil icon) or "Viewing ▾" (book icon). Its menu has two menuitemradio rows:
  • Viewing toolbar. Formatting hides. A quiet "Edit" button and Comment take its place, and the free space reads "Typing is off for you. Others can still edit." Discord and the right group stay. The mode control does not move.
  • Shortcut. The Google Docs keys (maintainer ruling, 2026-10-25). ⌥⇧⌘C / Ctrl+Alt+Shift+C switches to Viewing. ⌥⇧⌘Z / Ctrl+Alt+Shift+Z switches to Editing.
  • Typing hint. An edit key, paste or undo in Viewing shows one info toast: "Typing is off in Viewing mode. To type, select Edit or press ⌥⇧⌘Z." The key text comes from formatShortcut.
  • Document menu row. "Viewing mode", a menuitemcheckbox that shows the shortcut.
  • Command jump row. "Switch to Viewing" or "Switch to Editing". The search words "view read reading typing off mode" also find it.
  • Editing lock. A person under the Editing lock sees no mode control. The lock always wins.
  • Still works. Chat, heading chat buttons, Comment on a selection, TOC navigation, Find, Filter, links and Copy.
  • Hidden in Viewing. The first-visit line and the starter card (First-visit line and empty-document starter card #625).
  • Announcements. One role=status region outside .ProseMirror says "Viewing mode is on. Typing is off." or "Editing mode is on. You can type."

Maintainer rulings, 2026-10-25

  • Everyone opens a document in Editing. Only a remembered personal choice opens it in Viewing. Visitors do not land in Viewing.
  • Remember Viewing per document per device, keyed on documentId, never the slug.
  • Collaborator cursors stay exactly as today in both modes.
  • Desktop only. The phone keeps its own read mode (Edit / Done).

Build steps

  1. State. Add padMode: 'editing' | 'viewing' to apps/webapp/src/stores/workspace.ts. Not settings.editor.isEditable (workspace.ts:19,68), which means phone edit mode. Read docsy:pad-mode:<documentId> on each documentId change, desktop only. Use the try/catch shape of readPersistedTocWidth (apps/webapp/src/components/pages/document/hooks/useTocResize.tsx:91-108). Remove the key for Editing. If this is the first child of [Tracking] Document access, sharing and reading redesign #610 to merge, commit the four drafted CONTEXT.md entries.
  2. One editability rule. apps/webapp/src/hooks/useEditorEditableState.ts:34-39 sets setEditable(!locked). Make it !locked && padMode !== 'viewing', or a lock flip ends Viewing. A touch double tap (EditorContent.tsx:67) reaches setEditable(true) in apps/webapp/src/hooks/useCaretPosition.ts:120,127, gated only on the lock. Gate it on Viewing too, for desktop touch screens.
  3. AppendHeadingButton. apps/webapp/src/components/pages/document/components/AppendHeadingButton.tsx:78-79 forces Editing on. Hide it in Viewing.
  4. Toolbar. In apps/webapp/src/components/TipTap/toolbar/desktop/EditorToolbar.tsx, add the mode control before StyleSelect (line 107). Use the house DropdownMenu and ToolbarButton. In Viewing, Edit, Comment and the line replace lines 107–285. Leave the right group (289–383) untouched. Add LuBookOpen to apps/webapp/src/components/icons/registry.ts; no book icon exists.
  5. Skeleton. Add an Editing-shaped mode control bone to apps/webapp/src/components/skeleton/ToolbarSkeleton.tsx. See the open decision below for a remembered Viewing pad.
  6. Shortcut. The keys are ruled (2026-10-25): ⌥⇧⌘C / Ctrl+Alt+Shift+C for Viewing, ⌥⇧⌘Z / Ctrl+Alt+Shift+Z for Editing. Match them with isModShortcut and its alt option from Make every keyboard shortcut work on macOS and Windows, with correct hints #612 (apps/webapp/src/utils/platform.ts:80-91). Its event.code fallback resolves Option-modified keys on a Mac. On Windows with Ctrl+Alt held, a typed character wins and the shortcut does not fire. That is the same rule as prosemirror-keymap. Do not guard on getModifierState('AltGraph'): Firefox on Windows reports it for plain Ctrl+Alt (MDN). Ignore the key under the Editing lock.
  7. Typing hint. A keydown listener on the pad wrapper (a non-editable view may not get keys). Edit keys: printable keys except Space, Enter, Backspace, Delete, and Mod+V, X, Z, Y. Block paste and drop too. Keys on links and buttons keep their meaning. Info from @components/toast, at most once per 3 s. Build the key text in the toast with formatShortcut.
  8. Command jump. Add the row beside Find in apps/webapp/src/components/commandJump/buildPlaceRows.ts, live pad only. Hide it on the phone and under the Editing lock; PlaceContext has no lock flag yet, so pass one. PlaceRow (line 13) has no search words, and apps/webapp/src/components/commandJump/CommandJump.tsx:69 matches labels only. This issue owns the new optional keywords field; Read full screen: large text, one section at a time, on the live document #614 and Title ▾ document menu with one action list for the menu and Command jump #621 reuse it.
  9. Document menu row. The "Viewing mode" row lives in the action list of the Title ▾ document menu from Title ▾ document menu with one action list for the menu and Command jump #621. Whichever of this issue and Title ▾ document menu with one action list for the menu and Command jump #621 lands second adds it.
  10. Selection comment. apps/webapp/src/components/TipTap/extensions/HeadingActions/plugins/selectionChatPlugin.ts:17 needs view.hasFocus() and editor.isEditable. First verify two things in a non-editable view. A mouse selection must update editor.state.selection, and view.hasFocus() must be able to be true. If both hold, relax the check to "not locked". If not, report back before Comment hides in Viewing.
  11. TOC writes. TOC Delete section and drag still write when the editing lock is on #611 builds the TOC lock guard. Extend that guard to Viewing: hide TOC Delete section (apps/webapp/src/components/toc/TocContextMenu.tsx:60-66) and the drag grip, and stop TOC drag (apps/webapp/src/components/toc/hooks/useTocDrag.ts:193). The other rows do not write. Share one guard with TOC Delete section and drag still write when the editing lock is on #611.
  12. First-visit line and starter card. Hide both (First-visit line and empty-document starter card #625) in Viewing.
  13. Mermaid fold. extensions/extension-mermaid/src/nodeView/fold.ts:83-84 folds a diagram built non-editable. A remembered Viewing pad would fold every diagram. Pass fold: { initial: 'open', remember: true } on desktop at apps/webapp/src/components/TipTap/TipTap.tsx:230. This also covers desktop readers under the Editing lock. Keep the default on the phone; the comment at TipTap.tsx:228-229 says phone diagrams start folded on purpose. The extension stays unchanged.
  14. Catalog. .cursor/docs/design-system.md §EditorToolbar: add the mode control and Viewing rows. The skeleton rule says "the swap moves no pixel" (§State language, loading row), and the toolbar loading row (line 349) says "the swap moves no control". Record the outcome of the open decision below in the toolbar loading row. No new token.

Decisions (ruled 2026-10-25)

  1. Does fold.initial: 'open' also cover desktop readers under the Editing lock? Yes. One desktop config has no timing risk. The phone keeps its folded start.
  2. Does the shortcut show a toast under the Editing lock? No, ignore it. The design text "Read-only. Only the owner can edit." is wrong for a sync-error lock.
  3. Which keys switch the mode? The Google Docs keys: ⌥⇧⌘C / Ctrl+Alt+Shift+C for Viewing, ⌥⇧⌘Z / Ctrl+Alt+Shift+Z for Editing (Google Docs shortcuts). They replace the design's ⌥⌘E / Ctrl+Alt+E, which clashes on both platforms (Make every keyboard shortcut work on macOS and Windows, with correct hints #612). Every hint, menu row and Command jump row uses the new keys.

Decisions added by the review (ruled 2026-10-25)

  • A remembered Viewing pad shifts the toolbar once at S1. Ruled: accept it as a recorded exception to "the swap moves no pixel". The S0 skeleton cannot read localStorage, and no server-side read of a per-device choice exists.

Out of scope

Checks

  • Browser at 1280px or wider, light, dark and dark-HC: switch by control, menu, Command jump and shortcut.
  • A reload and a renamed link keep Viewing.
  • A lock flip under Viewing stays in Viewing.
  • A Read-only non-owner sees no mode control.
  • Typing, paste and Mod+Z in Viewing show the hint and change nothing.
  • In Viewing, TOC Delete section and drag are gone, and the first-visit line and starter card hide.
  • Mermaid opens unfolded in Viewing.
  • Skeleton geometry at S0 and S1.
  • Test: one Cypress E2E, "a lock flip must not end Viewing". Prove it by sabotage: remove the padMode term from step 2 and watch it fail.

Depends on

Activity

  1. added this to the v2.4.0 milestone on Oct 25, 2026
  2. added
    Editor
    on Oct 25, 2026
  3. removed this from the v2.4.0 milestone on Oct 25, 2026
  4. HMarzban commented on Oct 25, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-10-25

    The maintainer accepted every remaining recommended answer ("all picks").

    1. fold.initial: 'open' also covers desktop readers under the Editing lock: yes. The phone keeps its folded start.
    2. The shortcut under the Editing lock: ignore it, no toast.
    3. The key: use the Google Docs keys. ⌥⇧⌘C / Ctrl+Alt+Shift+C switches to Viewing, and ⌥⇧⌘Z / Ctrl+Alt+Shift+Z switches to Editing. This replaces ⌘⌥E / Ctrl+Alt+E from the design, which clashes on both platforms (Make every keyboard shortcut work on macOS and Windows, with correct hints #612). Every hint, menu row and Command jump row uses the new keys.
  5. HMarzban commented on Oct 25, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-10-25

    Open decision 1: accept the one-time toolbar shift for a remembered Viewing pad, as a recorded exception to "the swap moves no pixel". The S0 skeleton cannot read localStorage, and no server-side read of a per-device choice exists. A later change should not treat this shift as a skeleton regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesktopEditorFeatureUI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions