fix: wire up CLI session display in sidebar (3 frontend gaps) (#58)
The backend CLI session bridge (PR #56) was complete but the frontend never connected to it: 1. css class never applied -- el.className never included 'cli-session' so the gold border and 'cli' badge CSS was dead code. Fixed: append ' cli-session' when s.is_cli_session is true. 2. import never triggered -- click handler always called loadSession() directly, never POST /api/session/import_cli. Fixed: for CLI sessions, call import_cli first (idempotent -- safe to call on every click), then fall through to loadSession() which now finds the imported copy. 3. profile filter silently hid CLI sessions -- filter required s.profile === S.activeProfile, but CLI sessions may have profile=null if the SQLite DB has no profile column. Fixed: CLI sessions always pass the filter (s.is_cli_session || s.profile === S.activeProfile). Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
This commit is contained in:
@@ -118,7 +118,7 @@ function renderSessionListFromCache(){
|
||||
// Filter by active profile (unless "All profiles" is toggled on)
|
||||
// Server backfills profile='default' for legacy sessions, so every session has a profile.
|
||||
// Show only sessions tagged to the active profile; 'All profiles' toggle overrides.
|
||||
const profileFiltered=_showAllProfiles?allMatched:allMatched.filter(s=>s.profile===S.activeProfile);
|
||||
const profileFiltered=_showAllProfiles?allMatched:allMatched.filter(s=>s.is_cli_session||s.profile===S.activeProfile);
|
||||
// Filter by active project
|
||||
const projectFiltered=_activeProject?profileFiltered.filter(s=>s.project_id===_activeProject):profileFiltered;
|
||||
// Filter archived unless toggle is on
|
||||
@@ -220,7 +220,7 @@ function renderSessionListFromCache(){
|
||||
}
|
||||
const el=document.createElement('div');
|
||||
const isActive=S.session&&s.session_id===S.session.session_id;
|
||||
el.className='session-item'+(isActive?' active':'')+(isActive&&S.session&&S.session._flash?' new-flash':'')+(s.archived?' archived':'');
|
||||
el.className='session-item'+(isActive?' active':'')+(isActive&&S.session&&S.session._flash?' new-flash':'')+(s.archived?' archived':'')+(s.is_cli_session?' cli-session':'');
|
||||
if(isActive&&S.session&&S.session._flash)delete S.session._flash;
|
||||
const rawTitle=s.title||'Untitled';
|
||||
const tags=(rawTitle.match(/#[\w-]+/g)||[]);
|
||||
@@ -368,6 +368,12 @@ function renderSessionListFromCache(){
|
||||
_clickTimer=setTimeout(async()=>{
|
||||
_clickTimer=null;
|
||||
if(_renamingSid) return;
|
||||
// For CLI sessions, import into WebUI store first (idempotent)
|
||||
if(s.is_cli_session){
|
||||
try{
|
||||
await api('/api/session/import_cli',{method:'POST',body:JSON.stringify({session_id:s.session_id})});
|
||||
}catch(e){ /* import failed -- fall through to read-only view */ }
|
||||
}
|
||||
await loadSession(s.session_id);renderSessionListFromCache();
|
||||
if(typeof closeMobileSidebar==='function')closeMobileSidebar();
|
||||
}, 220);
|
||||
|
||||
Reference in New Issue
Block a user