Skip to content

gui: reclaim layout callback lifetimes#2

Merged
GGRei merged 1 commit into
mainfrom
fix/gui58-closure-lifetime-reclaim
Jun 19, 2026
Merged

gui: reclaim layout callback lifetimes#2
GGRei merged 1 commit into
mainfrom
fix/gui58-closure-lifetime-reclaim

Conversation

@GGRei

@GGRei GGRei commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

This uses the closure lifetime/reclaim API to reclaim transient layout callbacks in v-gui.

Window.update() now builds each layout tree inside a layout callback lifetime frame, keeps the current layout alive, and reclaims old frame-owned closure contexts after the new layout has been installed.

Persistent callbacks created during layout, such as animations, hover-created callbacks, async data sources, CRUD saves, and deferred drag/drop callbacks, are kept alive outside the transient reclaim scope when needed.

Changes

  • Add a small v-gui wrapper around the V closure lifetime API.
  • Track layout callback closures during Window.update().
  • Reclaim old layout-owned callbacks after replacing the layout tree.
  • Dispose layout callback lifetime state during window cleanup.
  • Keep persistent animations and hover-created callbacks outside frame reclaim.
  • Pin async data-grid and listbox source callbacks until completion/abort.
  • Pin async data-grid CRUD save callbacks until queued completion is applied.
  • Snapshot drag-reorder layout transitions before user drop handlers can rebuild layout.
  • Add regression coverage for layout callback memory growth, current-layout callback survival, persistent callbacks, async source callbacks, CRUD callbacks, drag reorder ordering, mouse lock callbacks, and idempotent cleanup.

Dependency

This PR depends on vlang

It should not be merged until vlang is merged and v-gui CI uses a V compiler that includes the closure lifetime/reclaim API.

Tests

/home/alex-portable/external_work/vlang_closure_lifetime_api_20260617/./v -o v_gui_verify cmd/v

/home/alex-portable/external_work/vlang_closure_lifetime_api_20260617/v_gui_verify test _window_lifetime_test.v
/home/alex-portable/external_work/vlang_closure_lifetime_api_20260617/v_gui_verify test _drag_reorder_test.v

git diff --check

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2b94d219a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread animation.v Outdated
@GGRei GGRei force-pushed the fix/gui58-closure-lifetime-reclaim branch from c2b94d2 to 593dbfd Compare June 18, 2026 12:37
@GGRei

GGRei commented Jun 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 593dbfdba7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread window_update.v Outdated
Comment thread window_update.v Outdated
Comment thread view_sidebar.v Outdated
@GGRei GGRei force-pushed the fix/gui58-closure-lifetime-reclaim branch from 593dbfd to 0478d8a Compare June 18, 2026 13:17
@GGRei

GGRei commented Jun 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0478d8a7dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread window_update.v Outdated
Comment thread window_update.v Outdated
Comment thread window_update.v Outdated
@GGRei GGRei force-pushed the fix/gui58-closure-lifetime-reclaim branch from 0478d8a to 7fabf3f Compare June 18, 2026 15:24
@GGRei

GGRei commented Jun 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fabf3ffcf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread window_update.v
Comment thread drag_reorder.v Outdated
Comment thread data_source_grid.v
@GGRei GGRei force-pushed the fix/gui58-closure-lifetime-reclaim branch from 7fabf3f to 5c09de0 Compare June 18, 2026 21:25
@GGRei

GGRei commented Jun 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 5c09de0b7f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@GGRei GGRei merged commit 7a20a6a into main Jun 19, 2026
0 of 8 checks passed
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