Skip to content

Add DocumentMode groundwork with MaskMode and Q toggle#4001

Open
krVatsal wants to merge 1 commit intoGraphiteEditor:masterfrom
krVatsal:documentMode-extension
Open

Add DocumentMode groundwork with MaskMode and Q toggle#4001
krVatsal wants to merge 1 commit intoGraphiteEditor:masterfrom
krVatsal:documentMode-extension

Conversation

@krVatsal
Copy link
Copy Markdown
Contributor

@krVatsal krVatsal commented Apr 3, 2026

This PR implements the early groundwork for Document Mode as planned for community bonding / week 1 in Marquee Selection Masking.
It introduces MaskMode and wires a keyboard toggle, while intentionally avoiding rendering or visual feature work.

What this PR changes?

  • Re-enables DocumentMode enum and adds MaskMode
  • Stores current document_mode in editor state
  • Adds ToggleDocumentMode message
  • Handles toggle logic in document message handler:
  1. DesignMode -> MaskMode
    
  2. MaskMode -> DesignMode
    
  • Maps Q to ToggleDocumentMode

Scope and intent

  • Pure editor state change only
  • No rendering pipeline changes
  • No frontend UI additions
  • No behavior beyond mode state toggle

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new DocumentMode enum, including a MaskMode variant, and integrates it into the DocumentMessageHandler to allow toggling and setting the document mode. The review feedback suggests ensuring UI consistency by triggering PortfolioMessage::UpdateDocumentWidgets when the mode changes and recommends uncommenting and updating the fmt::Display implementation for DocumentMode to avoid leaving dead code.

Comment on lines +1115 to +1123
DocumentMessage::ToggleDocumentMode => {
self.document_mode = match self.document_mode {
DocumentMode::MaskMode => DocumentMode::DesignMode,
_ => DocumentMode::MaskMode,
};
}
DocumentMessage::SetDocumentMode { document_mode } => {
self.document_mode = document_mode;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

When changing the document_mode, it is important to notify the frontend so that any UI elements (like the status bar or document bar) can refresh their state. Even if no UI currently displays this mode, adding PortfolioMessage::UpdateDocumentWidgets ensures consistency with how other document-level states (like render mode or snapping) are handled.

			DocumentMessage::ToggleDocumentMode => {
				self.document_mode = match self.document_mode {
					DocumentMode::MaskMode => DocumentMode::DesignMode,
					_ => DocumentMode::MaskMode,
				};
				responses.add(PortfolioMessage::UpdateDocumentWidgets);
			}
			DocumentMessage::SetDocumentMode { document_mode } => {
				if self.document_mode != document_mode {
					self.document_mode = document_mode;
					responses.add(PortfolioMessage::UpdateDocumentWidgets);
				}
			}

Comment on lines 41 to 50
// impl fmt::Display for DocumentMode {
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// match self {
// DocumentMode::DesignMode => write!(f, "Design Mode"),
// DocumentMode::SelectMode => write!(f, "Select Mode"),
// DocumentMode::GuideMode => write!(f, "Guide Mode"),
// DocumentMode::MaskMode => write!(f, "Mask Mode"),
// }
// }
// }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The Display implementation for DocumentMode is currently commented out. Since the enum is now active and being used for groundwork, it is better to enable this implementation and ensure it includes the new MaskMode variant. This avoids leaving dead code in the repository.

Suggested change
// impl fmt::Display for DocumentMode {
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// match self {
// DocumentMode::DesignMode => write!(f, "Design Mode"),
// DocumentMode::SelectMode => write!(f, "Select Mode"),
// DocumentMode::GuideMode => write!(f, "Guide Mode"),
// DocumentMode::MaskMode => write!(f, "Mask Mode"),
// }
// }
// }
impl fmt::Display for DocumentMode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
DocumentMode::DesignMode => write!(f, "Design Mode"),
DocumentMode::SelectMode => write!(f, "Select Mode"),
DocumentMode::GuideMode => write!(f, "Guide Mode"),
DocumentMode::MaskMode => write!(f, "Mask Mode"),
}
}
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant