fix: correct webui profile switching state — v0.50.150 (PR #849 by @migueltavares)
Three related profile-switching fixes: - Always persist hermes_profile=default cookie when switching back to default (was being cleared with max-age=0, causing fallback to process-global profile) - Replace undefined updateWorkspaceChip() with syncTopbar() in the sessionInProgress branch of switchToProfile() - Make sidebar/dropdown active-profile rendering prefer S.activeProfile client state when available, with safe fallback Tests: 1854 passing.
This commit is contained in:
@@ -202,10 +202,10 @@ class TestWorkspaceChipAfterProfileSwitch(unittest.TestCase):
|
||||
"""Verify that switchToProfile() applies the profile default workspace
|
||||
to the new session when a conversation is in progress (fixes #424)."""
|
||||
|
||||
def test_workspace_chip_updated_after_profile_switch(self):
|
||||
def test_topbar_synced_after_profile_switch(self):
|
||||
"""After await newSession(false) in the sessionInProgress branch,
|
||||
the code must call updateWorkspaceChip() so the chip reflects the
|
||||
new profile's default workspace instead of showing 'No active workspace'."""
|
||||
the code must call syncTopbar() so the profile/workspace chips reflect
|
||||
the new profile's default workspace."""
|
||||
# Find the sessionInProgress block
|
||||
idx = PANELS_JS.find('if (sessionInProgress)')
|
||||
self.assertGreater(idx, -1, "sessionInProgress branch must exist in panels.js")
|
||||
@@ -217,13 +217,13 @@ class TestWorkspaceChipAfterProfileSwitch(unittest.TestCase):
|
||||
self.assertIn('await newSession(false)', block,
|
||||
"sessionInProgress branch must call await newSession(false)")
|
||||
|
||||
# The fix: updateWorkspaceChip() must be called after newSession(false)
|
||||
# The fix: syncTopbar() must be called after newSession(false)
|
||||
pos_new_session = block.find('await newSession(false)')
|
||||
pos_update_chip = block.find('updateWorkspaceChip()')
|
||||
self.assertGreater(pos_update_chip, -1,
|
||||
"updateWorkspaceChip() must be called in the sessionInProgress branch")
|
||||
self.assertGreater(pos_update_chip, pos_new_session,
|
||||
"updateWorkspaceChip() must be called AFTER newSession(false)")
|
||||
pos_sync_topbar = block.find('syncTopbar()')
|
||||
self.assertGreater(pos_sync_topbar, -1,
|
||||
"syncTopbar() must be called in the sessionInProgress branch")
|
||||
self.assertGreater(pos_sync_topbar, pos_new_session,
|
||||
"syncTopbar() must be called AFTER newSession(false)")
|
||||
|
||||
def test_profile_default_workspace_applied_to_new_session(self):
|
||||
"""After newSession(false) the code must assign S._profileDefaultWorkspace
|
||||
@@ -248,19 +248,19 @@ class TestWorkspaceChipAfterProfileSwitch(unittest.TestCase):
|
||||
"The sessionInProgress branch must call /api/session/update "
|
||||
"to persist the new workspace after newSession(false)")
|
||||
|
||||
def test_update_workspace_chip_before_render_session_list(self):
|
||||
"""updateWorkspaceChip() should be called before renderSessionList()
|
||||
so the chip is correct when the UI re-renders."""
|
||||
def test_sync_topbar_before_render_session_list(self):
|
||||
"""syncTopbar() should be called before renderSessionList()
|
||||
so the chips are correct when the UI re-renders."""
|
||||
idx = PANELS_JS.find('if (sessionInProgress)')
|
||||
self.assertGreater(idx, -1)
|
||||
block = PANELS_JS[idx:idx + 1000]
|
||||
|
||||
pos_chip = block.find('updateWorkspaceChip()')
|
||||
pos_sync = block.find('syncTopbar()')
|
||||
pos_render = block.find('await renderSessionList()')
|
||||
self.assertGreater(pos_chip, -1, "updateWorkspaceChip() must exist in block")
|
||||
self.assertGreater(pos_sync, -1, "syncTopbar() must exist in block")
|
||||
self.assertGreater(pos_render, -1, "renderSessionList() must exist in block")
|
||||
self.assertLess(pos_chip, pos_render,
|
||||
"updateWorkspaceChip() must be called before renderSessionList()")
|
||||
self.assertLess(pos_sync, pos_render,
|
||||
"syncTopbar() must be called before renderSessionList()")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user