Navigating to a second page inside an App drops wid/t, so AnnaAppRuntime.connect() fails (and ?lang collides with the host locale)

Environment: anna.partners dashboard, Chrome 156 on Windows 11, @anna-ai/cli v0.1.63 (app-schema / dispatcher 0.32.0), SDK from /static/anna-apps/_sdk/latest/index.js. UI-only App (static-spa, no Executa), App ID 748.

What happens
My App has a second HTML page in the bundle (desk/game.html) and moves to it with location.assign(). On that page, and again when coming back to index.html, AnnaAppRuntime.connect() throws:

[anna-sdk] missing wid/t URL parameters

connect() only reads wid and t from location.search. Any in-app navigation that builds a new query string loses them. The page then runs with no host: storage reads return the defaults, so the user sees an empty or reset App. Saves fail, so no data is lost, but it looks like data loss.

Steps to reproduce

  1. Bundle index.html and page2.html, and have both call AnnaAppRuntime.connect().
  2. In index.html: location.assign('page2.html?foo=1').
  3. page2.html fails to connect.

Two more traps once you carry the URL over

  • Stale token: the t in the iframe URL is the token from when the window opened. The SDK keeps the refreshed one in runtime.token (updated on auth.refresh), but the URL still holds the original. In the dev harness the token TTL is about 30 s. I haven’t measured it in production, but a page switch minutes later should use runtime.token, not the URL value.
  • lang collision: the host puts lang=en-US on the URL and the SDK reads it into runtime.locale. My game pages used ?lang=vi for their own language. After returning, the App read vi as the host locale and switched its UI language.

Workaround
Keep every host key, swap in the latest token, and use App-specific key names:

// own keys = the App's params; everything else on the URL belongs to Anna
function pageQuery(search, own, token) {
  const q = new URLSearchParams(search);
  for (const k of ['view', 'tab', 'game', 'back', 'glang']) q.delete(k);
  if (token) q.set('t', token);
  for (const [k, v] of Object.entries(own)) if (v) q.set(k, v);
  return q.toString();
}
location.assign('page2.html?' + pageQuery(location.search, { glang: 'vi' }, runtime.token));

Suggestions

  • Document that wid, t, theme, themeMode and lang are host-owned URL keys that must survive in-app navigation.
  • Add an SDK helper, e.g. runtime.pageUrl(path, params), that carries them over with the current token.
  • Alternatively, let connect() fall back to credentials kept in sessionStorage per wid, so a plain location.assign keeps working.