Skip to content

110 add suspendmode support#111

Open
iObject wants to merge 8 commits into
masterfrom
110-add-suspendmode-support
Open

110 add suspendmode support#111
iObject wants to merge 8 commits into
masterfrom
110-add-suspendmode-support

Conversation

@iObject

@iObject iObject commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

iObject added 5 commits June 19, 2026 16:54
- Run beforeViewSuspend before the view is hidden on the
  clearStackOnResolve path (previously the active keepAlive view was
  hidden before the hook fired, breaking the documented ordering)
- Default unrecognized/missing suspendMode values to offscreen in
  hideView so a view is never left on-screen-but-hidden
- Add RecordingView test component and ordering regression tests
  covering both the suspendView and clearStackOnResolve suspend paths
- closeView: drop the redundant up-front hide (it was immediately
  overwritten by the post-hook removal). The view now stays visible
  during _beforeViewClose — consistent with suspendView and the
  forward-nav close path — and is destroyed once the hook resolves.
  Add an isNode guard mirroring suspendView.
- Sample/README: route the beforeViewSuspend fade resolution through a
  single idempotent resolveSuspendPromise() helper, called from the
  animation observer and on re-entry, so an interrupted fade can never
  leave the awaited promise dangling and stall navigation.
keepAliveViewTarget renders behind viewTarget, so a keepAlive view left
visible (suspendMode "visible") bled through behind the active view.

- Add moveViewToKeepAlive helper that always hides + parks the view
  off-screen before reparenting into keepAliveViewTarget, regardless of
  suspendMode. Use it from suspendView and the post-show closeViews loop.
  suspendMode now only governs in-place (viewTarget) suspension; showView
  restores visibility on resume.
- Warn at addRoutes when keepAlive is combined with suspendMode "visible"
  (no effect), without coercing the stored value.
- Add a regression test asserting a suspended keepAlive "visible" view is
  hidden and off-screen in keepAliveViewTarget.
- Document the in-place vs background distinction in the README.
@iObject iObject added the create-package create a temporary npm package on every commit label Jun 20, 2026
@iObject iObject linked an issue Jun 20, 2026 that may be closed by this pull request
@iObject iObject requested a review from Copilot June 20, 2026 00:31
@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new temporary npm package based on 8558e78. You can download it here or install it by running the following command:

npm install https://github.com/rokucommunity/sgRouter/releases/download/v0.0.0-packages/rokucommunity-sgrouter-0.1.3-110-add-suspendmode-support.20260620003119.tgz

Copilot AI 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.

Pull request overview

This PR adds view suspension customization and a new lifecycle hook to sgRouter so outgoing views can run work/animations before being hidden, and so routes can choose how a suspended view is hidden (offscreen/hidden/visible).

Changes:

  • Add suspendMode route option (offscreen default, hidden, visible) and implement it in Router hide/suspend behavior.
  • Add beforeViewSuspend / _beforeViewSuspend lifecycle hook and wire router suspension to await it.
  • Extend test coverage (including a new RecordingView test component) and update the sample Catalog screen to demonstrate a fade transition.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test-project/components/Screens/Catalog/CatalogScreen.xml Wraps content in a container + adds a fade animation definition.
test-project/components/Screens/Catalog/CatalogScreen.bs Drives fade-in on open/resume and fade-out in beforeViewSuspend (returns deferred promise).
test-project/components/Scene/MainScene/MainScene.bs Sets suspendMode: "visible" for /shows route to support layered transitions.
src/source/router.spec.bs Adds unit tests for suspendMode behavior and beforeViewSuspend ordering.
src/source/interfaces.bs Documents new suspendMode route option in the public interface.
src/components/View.xml Declares _beforeViewSuspend and beforeViewSuspend functions on base View.
src/components/View.bs Implements default beforeViewSuspend and internal _beforeViewSuspend wrapper.
src/components/Router.bs Adds suspendMode default/validation, suspendView lifecycle ordering, moveViewToKeepAlive, and new hideView semantics.
src/components/RecordingView.spec.xml Adds a test-only View subclass with suspendTrace field.
src/components/RecordingView.spec.bs Implements test-only hooks to record suspend ordering/visibility.
README.md Documents suspendMode and beforeViewSuspend including ordering guarantees and example usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/Router.bs
Comment thread src/components/Router.bs
Comment thread README.md Outdated
@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new temporary npm package based on 409af2c. You can download it here or install it by running the following command:

npm install https://github.com/rokucommunity/sgRouter/releases/download/v0.0.0-packages/rokucommunity-sgrouter-0.1.3-110-add-suspendmode-support.20260622184253.tgz

Copilot AI 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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Comment thread src/components/Router.bs
Comment on lines 806 to +810
if m.__router_activeView <> Invalid then
if NOT isActiveInCloseViews AND rodash.getBoolean(m.__router_activeView.route.routeConfig.keepAlive, "enabled") then
promisesToResolve.push(suspendView(m.__router_activeView))
if isActiveInCloseViews then
if NOT rodash.getBoolean(m.__router_activeView.route.routeConfig.keepAlive, "enabled") then
hideView(m.__router_activeView)
end if
Comment thread src/components/Router.bs
Comment on lines 879 to 882
end function).catch(function(error as Dynamic) as Dynamic
return promises.reject(error)
end function).toPromise()
end function
Comment on lines +83 to +86
function beforeViewSuspend(params = {} as Object) as Dynamic
print "BEFORE VIEW SUSPEND", params

' Resolve any prior pending suspend promise first so it can never dangle if a new
Comment on lines +97 to +102
sub onFadeAnimationStateChanged(event as Object)
if event.getData() = "stopped" then
print "VIEW SUSPEND ANIMATION COMPLETE, RESOLVING SUSPEND PROMISE"
resolveSuspendPromise()
end if
end sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-package create a temporary npm package on every commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add suspendMode support

3 participants