davinci-resolve-mcp 2.78.0 → 2.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -113,3 +113,53 @@ def color_page_for_thumbnails(resolve):
113
113
  resolve.OpenPage(original)
114
114
  except Exception:
115
115
  pass
116
+
117
+
118
+ @contextmanager
119
+ def edit_page_for_timeline_edits(resolve):
120
+ """Hold the Edit page for the block, restoring the user's page after.
121
+
122
+ api_truth 'Timeline.DeleteClips (requires the Edit page; flaky first
123
+ attempt)': off the Edit page the call returns False and deletes nothing,
124
+ retries included — retrying cannot clear a page gate. Yields True when
125
+ Resolve is on the Edit page for the block.
126
+
127
+ Same shape as color_page_for_thumbnails, and for the same reason it lives
128
+ here rather than at the callsite: the switch must be serialized. Resolve has
129
+ one globally-active page, so an unlocked switch-work-restore races every
130
+ other page-switching operation — and losing that race puts the delete on
131
+ some other page, which is exactly the failure this guard exists to prevent.
132
+
133
+ Nesting is free (page_lock is reentrant, and an inner guard finds the page
134
+ already on edit and switches nothing), so a caller that deletes in a LOOP
135
+ should hold this once around the loop. Otherwise it pays a switch and a
136
+ restore per iteration: from Fairlight, N cuts cost 2N page flips, each a
137
+ visible flash and possible cache/render work.
138
+
139
+ If the current page can't be captured (GetCurrentPage returned None or
140
+ raised), no switch is attempted, so a skipped restore can never strand the
141
+ user on the Edit page.
142
+ """
143
+ original = None
144
+ try:
145
+ original = resolve.GetCurrentPage() if resolve else None
146
+ except Exception:
147
+ original = None
148
+ with page_lock():
149
+ on_edit = original == "edit"
150
+ if original and not on_edit:
151
+ try:
152
+ on_edit = bool(resolve.OpenPage("edit"))
153
+ except Exception:
154
+ pass
155
+ try:
156
+ yield on_edit
157
+ finally:
158
+ # Restore only a page we actually left: `on_edit` is False here when
159
+ # OpenPage refused, and restoring then would flip a page the user is
160
+ # still on.
161
+ if original and original != "edit" and on_edit:
162
+ try:
163
+ resolve.OpenPage(original)
164
+ except Exception:
165
+ pass