shelley: intercept PageUp/PageDown in diff modal

Philip Zeyliger created

Prompt: make it so that in shelley, when i use pageup/pagedown when the diff modal is open, it goes to the diff modal and not to the background.

When the diff modal is open, PageUp/PageDown should scroll the diff
editor content, not the background chat. This adds handling to intercept
those keys and forward them to the Monaco editor's built-in cursor page
navigation.

Change summary

ui/src/components/DiffViewer.tsx | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

Detailed changes

ui/src/components/DiffViewer.tsx 🔗

@@ -659,6 +659,22 @@ function DiffViewer({ cwd, isOpen, onClose, onCommentTextChange, initialCommit }
         return;
       }
 
+      // Intercept PageUp/PageDown to scroll the diff editor instead of background
+      if (e.key === "PageUp" || e.key === "PageDown") {
+        if (editorRef.current) {
+          e.preventDefault();
+          e.stopPropagation();
+          const modifiedEditor = editorRef.current.getModifiedEditor();
+          // Trigger the editor's built-in page up/down action
+          modifiedEditor.trigger(
+            "keyboard",
+            e.key === "PageUp" ? "cursorPageUp" : "cursorPageDown",
+            null,
+          );
+        }
+        return;
+      }
+
       // Comment mode navigation shortcuts (only when comment dialog is closed)
       if (mode === "comment" && !showCommentDialog) {
         if (e.key === ".") {