Skip to content

Fix #202: add a View Only toggle to the VNC session toolbar#273

Open
eran132 wants to merge 1 commit into
Terminals-Origin:masterfrom
eran132:fix/202-vnc-viewonly-toggle
Open

Fix #202: add a View Only toggle to the VNC session toolbar#273
eran132 wants to merge 1 commit into
Terminals-Origin:masterfrom
eran132:fix/202-vnc-viewonly-toggle

Conversation

@eran132

@eran132 eran132 commented Jun 6, 2026

Copy link
Copy Markdown

Summary

Fixes #202. "View Only" for VNC could only be set on the favorite before connecting — there was no way to toggle it during a live session (as requested in the issue, similar to UltraVNC Viewer's option toggle).

This adds a checkable View Only item to the existing VNC actions toolbar dropdown (the one that already offers Send ALT/CTRL/etc.), so it only shows for VNC sessions.

Change

  • VNCConnection.ToggleViewOnly() flips the live input mode via RemoteDesktop.SetInputMode(viewOnly) and returns the new state; VNCConnection.ViewOnly exposes the current state. The state is seeded from the favorite's VncViewOnly option on connect, so the toggle starts in sync.
  • VncMenuVisitor adds the checkable menu item and re-syncs its Checked state to the current connection on each toolbar visit (so switching tabs reflects the right state).

Tests

VncMenuVisitorTests: updated the dropdown item count (5 → 6) and added a test asserting the View Only toggle is present and labelled. Verified red→green (both fail before the change, pass after). Full suite shows no new failures (the only pre-existing local failures are the SQL/LocalDB tests, which need a database).

Note: the live input-mode effect (SetInputMode) can't be exercised headlessly, same as the existing Send-keys handlers; the menu wiring and toggle-state logic are covered by tests, and the runtime behavior relies on VncSharp's documented SetInputMode API.

🤖 Generated with Claude Code

VNC sessions could only set View Only before connecting (favorite option);
there was no way to flip it during a live session. Add a checkable
"View Only" item to the VNC actions toolbar dropdown that toggles input
mode on the running session.

- VNCConnection.ToggleViewOnly() flips the state and calls
  RemoteDesktop.SetInputMode, exposing the current state via ViewOnly.
  The state is seeded from the favorite's VncViewOnly option on connect.
- VncMenuVisitor adds the checkable menu item and keeps its checked state
  in sync with the current connection on each toolbar visit.

Fixes Terminals-Origin#202

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 6, 2026 10:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a “View Only” toggle to the VNC actions toolbar menu and wires it to the active VNC session’s input mode.

Changes:

  • Add “View Only” menu item to the VNC toolbar dropdown and keep its checked state in sync when switching sessions/tabs.
  • Implement VNCConnection.ViewOnly + ToggleViewOnly() and initialize from VncOptions.
  • Extend UI tests to validate the new menu item and update expected menu item count.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Source/Tests/UserInterface/VncMenuVisitorTests.cs Updates existing assertion count and adds a test ensuring the View Only toggle exists and is labeled correctly.
Source/Terminals.Plugins.Vnc/VncMenuVisitor.cs Adds a View Only ToolStripMenuItem, syncs checked state from current VNCConnection, and toggles session mode on click.
Source/Terminals.Plugins.Vnc/VNCConnection.cs Persists view-only state, exposes it via property, toggles it at runtime, and initializes it from options on connect.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

menuVisitor.Visit(sut.Toolbar);
int itemsCount = ((ToolStripDropDownButton)sut.Toolbar.Items[0]).DropDownItems.Count;
Assert.AreEqual(5, itemsCount, "First visit should update the menu by add its own drop donw menu items");
Assert.AreEqual(6, itemsCount, "First visit should update the menu by add its own drop donw menu items");
Comment on lines +86 to +89
this.viewOnlyToolStripMenuItem = new ToolStripMenuItem();
this.viewOnlyToolStripMenuItem.Name = "viewOnlyToolStripMenuItem";
this.viewOnlyToolStripMenuItem.Size = new Size(202, 22);
this.viewOnlyToolStripMenuItem.Text = "View Only";
Comment on lines +36 to +44
public bool ToggleViewOnly()
{
if (rd == null)
return this.viewOnly;

this.viewOnly = !this.viewOnly;
rd.SetInputMode(this.viewOnly);
return this.viewOnly;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Toolbar button to toggle "View Only" option for VNC sessions

2 participants