MCPcopy Index your code
hub / github.com/coder/coder / getWorkspaceConnLocked

Method getWorkspaceConnLocked

coderd/x/chatd/chatd.go:955–972  ·  view source on GitHub ↗

getWorkspaceConnLocked returns the cached connection when it still matches the current workspace. When the workspace changed, it clears the stale cached state and returns the release func for the caller to run after unlocking.

()

Source from the content-addressed store, hash-verified

953// cached state and returns the release func for the caller to run after
954// unlocking.
955func (c *turnWorkspaceContext) getWorkspaceConnLocked() (workspacesdk.AgentConn, func()) {
956 if c.conn == nil {
957 return nil, nil
958 }
959
960 chatSnapshot := c.currentChatSnapshot()
961 if nullUUIDEqual(c.cachedWorkspaceID, chatSnapshot.WorkspaceID) {
962 return c.conn, nil
963 }
964
965 agentRelease := c.releaseConn
966 c.agent = database.WorkspaceAgent{}
967 c.agentLoaded = false
968 c.conn = nil
969 c.releaseConn = nil
970 c.cachedWorkspaceID = uuid.NullUUID{}
971 return nil, agentRelease
972}
973
974// isAgentUnreachable reports whether the given agent row's
975// status is disconnected or timed out. It uses timestamp

Callers 1

getWorkspaceConnMethod · 0.95

Calls 2

currentChatSnapshotMethod · 0.95
nullUUIDEqualFunction · 0.85

Tested by

no test coverage detected