Skip to content

Conversation

@cilginc
Copy link
Contributor

@cilginc cilginc commented Oct 15, 2025

No description provided.

@ThatOtherAndrew
Copy link
Owner

Checking in with this from time to time and it's really impressive stuff, thank you so much for your work on this!

@cilginc cilginc force-pushed the refactor-structure branch from db4b31f to 865b158 Compare October 15, 2025 22:10
@cilginc cilginc marked this pull request as ready for review October 15, 2025 22:28
@cilginc
Copy link
Contributor Author

cilginc commented Oct 15, 2025

You can merge now. FYI, I had to apply this workaround across multiple parts of the code, so it’s not fully idiomatic yet.

type App struct {
	app *models.App
}

func New(app *models.App) *App {
	return &App{app: app}
}

Instead of defining methods on the struct like this:

func (a *App) foo() {}

I prefer using standalone functions that take the struct as an argument:

func foo(a *App) {}

This avoids mutating structs from other packages, which is generally discouraged in Go. It keeps your API simpler and avoids unintentional side effects.

Also, check the TODO comments I added for future refactoring.

Currently, shaders are embedded in the binary, but we could also load them from disk or combine both approaches. Embedding works fine for now and keeps things self-contained.

@ThatOtherAndrew
Copy link
Owner

Very curious to test out this copilot review feature.

Don't worry, will be reviewing manually too (hence the slow merge - sorry!)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Major refactor to modularize the project, move Wayland/C interop into a dedicated package, externalize shaders, and introduce a proper cmd entrypoint.

  • Extracted Wayland integration into pkg/wayland with xkbcommon-based key handling.
  • Split application into internal packages (models, draw, update, spawn, stroke, gesture, execute, opengl) and moved main to cmd/hexecute.
  • Externalized GLSL shaders to files (with go:embed) and added shader compilation helpers.
  • Updated module path to GitHub and adjusted project structure.

Reviewed Changes

Copilot reviewed 31 out of 35 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
wayland.go Removed legacy monolithic Wayland/C interop (replaced by pkg/wayland).
pkg/wayland/wlr-layer-shell-client.h Formatting/consistency tweaks to autogenerated header.
pkg/wayland/wayland.h New C header: Wayland/XKB declarations and exported functions.
pkg/wayland/wayland.go New Go wrapper for Wayland/EGL window lifecycle and input.
pkg/wayland/wayland.c New C implementation for Wayland glue, XKB, and input tracking.
pkg/wayland/keyboard-shortcuts-inhibit-client.h Formatting/consistency tweaks to autogenerated header.
pkg/wayland/.clangd Added editor config for C/C++ completions (non-functional change).
main.go Removed monolithic main (replaced by cmd/hexecute).
internal/update/update.go New package for cursor/particle update logic.
internal/stroke/stroke.go Ported stroke/gesture logic into internal package.
internal/spawn/spawn.go Particle spawning helpers split out.
internal/shaders/shader.go Shader compilation helpers (from file and from source).
internal/shaders/paths.go Shader paths and embedded shader sources.
internal/shaders/*.glsl GLSL shaders extracted to files.
internal/opengl/opengl.go OpenGL init and VAO/VBO/program setup.
internal/models/models.go Centralized data structures (App, Point, Particle, GestureConfig).
internal/gesture/gesture.go Gesture config load/save helpers.
internal/fornow/fornow.go Transitional logic: point accumulation and gesture execution.
internal/execute/execute.go Command execution helper.
internal/draw/draw.go Rendering logic (background, glow, lines, particles).
internal/config/config.go Config path helper.
go.mod Module path updated; go version directive changed.
cmd/hexecute/main.go New entrypoint wiring packages together and event loop.
README.md Updated demo asset path.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +121 to +123
struct xkb_context *xkb_context;
struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state;
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

xkb_context, xkb_keymap, and xkb_state are allocated but never released, causing a memory leak. Add a cleanup function (xkb_state_unref, xkb_keymap_unref, xkb_context_unref) and call it from WaylandWindow.Destroy.

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +47
if *listGestures {
gestures, err := gestures.LoadGestures()
if err != nil {
log.Fatal("Failed to load gestures:", err)
}
if len(gestures) == 0 {
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The local variable gestures shadows the imported package name 'gestures', which reduces readability and can lead to subtle mistakes. Consider renaming the variable to 'gs' or 'loadedGestures'.

Copilot uses AI. Check for mistakes.
Comment on lines +152 to +154
spawn := spawn.New(app)
spawn.SpawnExitWisps(float32(x), float32(y))
}
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The local variable spawn shadows the imported package 'spawn'. Rename the variable (e.g., 'spawner') to avoid confusion; the same pattern appears again when spawning cursor sparkles.

Copilot uses AI. Check for mistakes.
Comment on lines +205 to +206
spawn := spawn.New(app)
spawn.SpawnCursorSparkles(float32(x), float32(y))
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

[nitpick] Same shadowing as above; rename the local variable to avoid masking the package import.

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +45
logMsg := make([]byte, logLength)
gl.GetProgramInfoLog(a.app.Program, logLength, nil, &logMsg[0])
log.Fatalf("Failed to link program: %s", logMsg)
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

[nitpick] Avoid calling log.Fatalf in a library/init function; prefer returning an error so the caller can decide how to handle failures. This pattern repeats for other program links in this file.

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +31
type App struct {
*models.App
}

Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

[nitpick] This wrapper type is declared but not used in the file; consider removing it to keep the entrypoint lean.

Suggested change
type App struct {
*models.App
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Finally, accurate information from AI! The issue has been resolved in this PR, though it currently doesn’t affect the project.

@ThatOtherAndrew
Copy link
Owner

if i had a penny for every hallucination here then i wouldn't need employment

@ThatOtherAndrew
Copy link
Owner

@cilginc what's with the fornow.go file?

@cilginc
Copy link
Contributor Author

cilginc commented Oct 17, 2025

@cilginc what's with the fornow.go file?

Oh, I forgot to refactor that package before committing.

Working on it.

@cilginc cilginc force-pushed the refactor-structure branch from 061bb59 to f47aba9 Compare October 17, 2025 15:13
Copy link
Owner

@ThatOtherAndrew ThatOtherAndrew left a comment

Choose a reason for hiding this comment

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

Finally got through all this! And still with 1h20m of overnight sleep remaining 😅

Thanks again for the refactor!

@ThatOtherAndrew
Copy link
Owner

Ready to merge, I believe!

What command is it that you've been using to build the project outside of Nix? Is it something similar to the form go build -o /bin/hexecute ./cmd/hexecute?

@cilginc
Copy link
Contributor Author

cilginc commented Oct 19, 2025

Ready to merge, I believe!

What command is it that you've been using to build the project outside of Nix? Is it something similar to the form go build -o /bin/hexecute ./cmd/hexecute?

I use go build -o bin ./....

@ThatOtherAndrew
Copy link
Owner

Didn't know that ellipsis was a syntax, thanks! I'll update the README accordingly.

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.

2 participants