Skip to content

Desktop: UI trait - #5071

Open
timon-schelling wants to merge 2 commits into
masterfrom
desktop-ui-trait
Open

timon-schelling wants to merge 2 commits into
masterfrom
desktop-ui-trait

Conversation

@timon-schelling

Copy link
Copy Markdown
Member

No description provided.

@timon-schelling timon-schelling changed the title Desktop UI trait Desktop: UI trait Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

This PR's title needs revising to follow the project's conventions:

  • It should begin with an imperative verb like "Add" or "Fix", rather than past tense ("Added"), third person ("Adds"), or a noun phrase.
  • It's too vague to tell what the change does.
  • It should have no trailing period, and no prefix like "feat:", issue number, emoji, or tag like "[WIP]".

Suggested titles:

Add a UI backend trait to the desktop app and move CEF behind it
Abstract the desktop app's UI behind a backend trait, with CEF as its implementation
Add a desktop UiBackend trait and rename the CEF UI crate to graphite-desktop-ui-cef

Editing the title reviews it again.

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

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.

2 issues found across 22 files

Confidence score: 4/5

  • UiBackend in desktop/src/ui.rs still exposes CEF types, so other backends must depend on CEF. Move InputEvent and Cursor into the desktop layer.
  • The PR title is not an imperative command and lacks a subsystem prefix. Use a title like “Desktop: Add UI trait”.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="desktop/src/ui.rs">

<violation number="1" location="desktop/src/ui.rs:8">
P2: Custom agent: **PR title enforcement**

The title “Desktop UI trait” is a noun phrase, not an imperative command. Use the subsystem prefix and an action, such as “Desktop: Add UI trait”.</violation>

<violation number="2" location="desktop/src/ui.rs:19">
P2: `UiCommand::Input` and `UiEvent::Cursor` carry `InputEvent` and `Cursor` from the CEF crate, so the backend-agnostic `UiBackend` still forces every backend to use CEF's types. Move these types into the desktop layer, or accept that the trait is CEF-specific.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread desktop/src/ui.rs
pub(crate) type UiError = Box<dyn std::error::Error + Send + Sync>;

pub(crate) enum UiCommand {
Input(InputEvent),

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.

P2: UiCommand::Input and UiEvent::Cursor carry InputEvent and Cursor from the CEF crate, so the backend-agnostic UiBackend still forces every backend to use CEF's types. Move these types into the desktop layer, or accept that the trait is CEF-specific.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/src/ui.rs, line 19:

<comment>`UiCommand::Input` and `UiEvent::Cursor` carry `InputEvent` and `Cursor` from the CEF crate, so the backend-agnostic `UiBackend` still forces every backend to use CEF's types. Move these types into the desktop layer, or accept that the trait is CEF-specific.</comment>

<file context>
@@ -0,0 +1,32 @@
+pub(crate) type UiError = Box<dyn std::error::Error + Send + Sync>;
+
+pub(crate) enum UiCommand {
+	Input(InputEvent),
+	Resized { width: u32, height: u32 },
+	ScaleChanged(f64),
</file context>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should be winit types?

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.

@timon-schelling Yes — that works, and it's arguably the cleaner resolution. winit already owns the window/input layer in the desktop app, so the trait speaking winit types means no CEF types leak through the abstraction and you don't have to invent parallel input/cursor types in desktop/src/ui.rs.

The one consequence to keep in mind: the conversions move into the backend. The CEF implementation would map winit input events onto its InputEventBuilder (which is presumably where the multi-click/pinch/scroll constants in the re-export come from) and map CEF cursor changes back to winit::window::CursorIcon for the app to apply. Both are small conversions and they belong in desktop/src/ui/cef.rs, so the layering actually improves — app.rs stops dealing with CEF input specifics and just forwards winit events.

My original comment wasn't tied to the exact fix; the point was that UiCommand::Input(InputEvent) and UiEvent::Cursor(Cursor) currently pin the trait to the CEF crate. Using winit types resolves that just as well as moving the types up, and I'd say it's the better option given winit is already a core dependency here.

Tip: get faster answers by chatting with cubic’s review copilot in the review UI

Comment thread desktop/src/ui.rs
@@ -0,0 +1,32 @@
use crate::preferences::DesktopPreferences;

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.

P2: Custom agent: PR title enforcement

The title “Desktop UI trait” is a noun phrase, not an imperative command. Use the subsystem prefix and an action, such as “Desktop: Add UI trait”.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/src/ui.rs, line 8:

<comment>The title “Desktop UI trait” is a noun phrase, not an imperative command. Use the subsystem prefix and an action, such as “Desktop: Add UI trait”.</comment>

<file context>
@@ -0,0 +1,32 @@
+mod cef;
+pub(crate) use cef::*;
+
+pub(crate) trait UiBackend: Sized {
+	fn start(preferences: &DesktopPreferences, wgpu_context: &WgpuContext) -> Result<Self, UiError>;
+	fn send(&self, command: UiCommand);
</file context>

This branch was successfully deployed

1 active deployment
graphite-dev (Preview) — 512f71e9 Deployed Dec 4, 2026 by github-actions[bot]
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