---
id: TASK-62
title: Tab bar persistence + iframe loading/error states
status: Done
assignee: []
created_date: '2026-02-26 02:19'
updated_date: '2026-02-26 02:19'
labels:
  - bugfix
  - shell
  - iframe
dependencies:
  - TASK-61
priority: high
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Fix two issues from the iframe shell rollout: (1) tab bar was resetting to a single tab on every page navigation — now persists in localStorage, (2) iframed standalone apps that aren't running showed a blank page — now shows spinner + 12s timeout error panel with retry/open-directly actions. Also converts rSwag to iframe shell (missed in TASK-61).
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tabs persist across full-page navigations via localStorage
- [x] #2 Opening a new rApp adds it as a tab alongside existing ones
- [x] #3 Closing active tab navigates to first remaining tab
- [x] #4 Iframe shows loading spinner while standalone app loads
- [x] #5 12s timeout shows error panel if standalone app unreachable
- [x] #6 Error panel has Retry button and Open Directly link
- [x] #7 rSwag module converted to iframe shell
- [x] #8 CommunitySync merges with localStorage tabs when connected
<!-- AC:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Rewrote tab bar initialization in `server/shell.ts` to use `localStorage` keyed per space (`rspace_tabs_{spaceSlug}`). Previously `tabBar.setLayers([defaultLayer])` was called with only the current module on every page load, wiping all previous tabs. Now reads from localStorage first, adds the current module if missing, and persists before rendering.\n\nAdded loading/error states to `renderIframeShell()`: spinner overlay during load, 12s timeout that shows an error panel with the module name, domain that failed, Retry button, and Open Directly link. Iframe fades in on successful load.\n\nConverted `modules/swag/mod.ts` to use `renderIframeShell` with `swag.mycofi.earth` (missed in TASK-61).\n\nCommit: `fa6a2ce` — merged to main.
<!-- SECTION:FINAL_SUMMARY:END -->
