UpdateSessionTitle updates the title for a session. If the session is actively running, it also updates the in-memory session object to prevent subsequent runtime saves from overwriting the title.
(ctx context.Context, sessionID, title string)
| 855 | // If the session is actively running, it also updates the in-memory session |
| 856 | // object to prevent subsequent runtime saves from overwriting the title. |
| 857 | func (sm *SessionManager) UpdateSessionTitle(ctx context.Context, sessionID, title string) error { |
| 858 | sm.mux.Lock() |
| 859 | defer sm.mux.Unlock() |
| 860 | |
| 861 | // If session is actively running, update the in-memory session object directly. |
| 862 | // This ensures the runtime's saveSession won't overwrite our manual edit. |
| 863 | if rt, ok := sm.runtimeSessions.Load(sessionID); ok && rt.session != nil { |
| 864 | rt.session.Title = title |
| 865 | slog.DebugContext(ctx, "Updated title for active session", "session_id", sessionID, "title", title) |
| 866 | return sm.sessionStore.UpdateSession(ctx, rt.session) |
| 867 | } |
| 868 | |
| 869 | // Session is not actively running, load from store and update |
| 870 | sess, err := sm.sessionStore.GetSession(ctx, sessionID) |
| 871 | if err != nil { |
| 872 | return err |
| 873 | } |
| 874 | |
| 875 | sess.Title = title |
| 876 | return sm.sessionStore.UpdateSession(ctx, sess) |
| 877 | } |
| 878 | |
| 879 | // generateTitle generates a title for a session using the sessiontitle package. |
| 880 | // The generated title is stored in the session and persisted to the store. |
nothing calls this directly
no test coverage detected