Skip to content

Extend story publish to include sessions - #41

Merged
TerkaSlan merged 5 commits into
mainfrom
publish-stories-with-sessions
Aug 15, 2025
Merged

Extend story publish to include sessions#41
TerkaSlan merged 5 commits into
mainfrom
publish-stories-with-sessions

Conversation

@TerkaSlan

@TerkaSlan TerkaSlan commented Aug 14, 2025

Copy link
Copy Markdown
Collaborator

Description

The goal of this change is to support the public share of sessions in addition to stories. Sessions shared with stories now get their public session URL that one can share + copy-paste into https://molstar.org/mol-view-stories/builder.

Solution

  • in addition to mvsj|mvsx data + metadata, /story now expects a "session" (mvstory) component
    • these are required as FormData (replaced suboptimal base64 for mvsx)
  • public access endpoint for story-sessions: /api/story/{id}/session-data
    • on GET, a .mvstories binary file is downloaded
  • added loadSessionFromUrl in addition to loadSession (from session id)
    • this prepares /builder to accept public sessions which are potentially hosted anywhere with CORS enabled (not necessarily on the storage tied to our backend)
  • adjusted the modal to contain info about the published story and session:
image

Backward Compatibility

  • stories published in the old format still work for READ and UPDATE, in case of UPDATE they're converted to the new format (i.e., with sessions)
  • new stories are only created in the new format

Testing

  • Added 6 new tests for the functionality
  • All scenarios (mvsj, mvsx, happy path, update old format, read old format) tested on local deployment
  • loadSessionFromUrl won't work as hardcoded to https://molstar.org/mol-view-stories/builder unless we merge + deploy these changes:
https://molstar.org/mol-view-stories/builder/?session-url=<public url>)

but:
http://localhost:3000/builder/?session-url=http%3A%2F%2Flocalhost%3A5000%2Fapi%2Fstory%2F95e233ca%2Fsession-data works

Actions

  • Added description of changes to the [Unreleased] section of CHANGELOG.md

@TerkaSlan
TerkaSlan requested a review from dsehnal August 14, 2025 07:09
Comment thread src/app/state/save-dialog-actions.ts Outdated
}

async function saveStoryWithJSON(
async function saveStoryWithFormData(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
async function saveStoryWithFormData(
async function saveStory(

Comment on lines 29 to +32
const sessionId = searchParams.get('sessionId');
const sessionUrl = searchParams.get('sessionUrl');
const templateName = searchParams.get('template');
const sessionType = searchParams.get('type') as 'session' | 'story' | null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const sessionId = searchParams.get('sessionId');
const sessionUrl = searchParams.get('sessionUrl');
const templateName = searchParams.get('template');
const sessionType = searchParams.get('type') as 'session' | 'story' | null;
const sessionId = searchParams.get('session-id'); // please rename this across the app. The - version looks nicer
const publishedSessionId = searchParams.get('published-session-id');
const sessionUrl = searchParams.get('session-url'); // we could allow loading from any hosted session with CORS
const templateName = searchParams.get('template');

Comment thread src/components/story-builder/index.tsx Outdated
Comment on lines +34 to +37
if (sessionUrl) {
loadSessionFromUrl(sessionUrl);
return;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (sessionUrl) {
loadSessionFromUrl(sessionUrl);
return;
}
const url = sessionUrl ?? resolvePublishedSessionUrl(publishedSessionId );
if (url) {
loadSessionFromUrl(url);
// TODO: clear session-url and published-session-i
return;
}

Comment thread src/components/story-builder/index.tsx Outdated
Comment on lines +44 to +52
if (sessionType) {
try {
const url = new URL(window.location.href);
url.searchParams.delete('type');
window.history.replaceState({}, '', url.toString());
} catch (error) {
console.warn('Failed to clear type param:', error);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (sessionType) {
try {
const url = new URL(window.location.href);
url.searchParams.delete('type');
window.history.replaceState({}, '', url.toString());
} catch (error) {
console.warn('Failed to clear type param:', error);
}
}

@dsehnal dsehnal mentioned this pull request Aug 13, 2025
68 tasks

@dsehnal dsehnal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, feel free to merge when ready

@TerkaSlan
TerkaSlan merged commit f8cf9ee into main Aug 15, 2025
6 checks passed
@TerkaSlan
TerkaSlan deleted the publish-stories-with-sessions branch August 15, 2025 05:56
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