MCPcopy Index your code
hub / github.com/docker/docker-agent / UpdateSessionTitle

Method UpdateSessionTitle

pkg/server/session_manager.go:857–877  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
857func (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.

Callers

nothing calls this directly

Calls 5

LoadMethod · 0.80
UpdateSessionMethod · 0.65
GetSessionMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected