Skip to content

Commit eebc445

Browse files
committed
pr 4
1 parent 0e10473 commit eebc445

33 files changed

Lines changed: 2798 additions & 4794 deletions

coderd/apidoc/docs.go

Lines changed: 54 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 50 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,10 @@ type Options struct {
251251
SSHConfig codersdk.SSHConfigResponse
252252

253253
HTTPClient *http.Client
254-
// ChatSubscribeFn provides cross-replica subscription merging.
255-
// Set by enterprise for HA deployments. Nil in AGPL single-replica.
256-
ChatSubscribeFn chatd.SubscribeFn
254+
// ChatStreamPartsDialer dials remote chat stream parts.
255+
// Set by enterprise for HA deployments. Nil uses chatd's local
256+
// in-process channel dialer.
257+
ChatStreamPartsDialer chatd.StreamPartsDialer
257258
// ChatProviderAPIKeys overrides deployment-derived provider keys.
258259
// Test harnesses use this to route chat models to local providers.
259260
ChatProviderAPIKeys *chatprovider.ProviderAPIKeys
@@ -816,7 +817,7 @@ func New(options *Options) *API {
816817
Logger: options.Logger.Named("chatd"),
817818
Database: options.Database,
818819
ReplicaID: api.ID,
819-
SubscribeFn: options.ChatSubscribeFn,
820+
StreamPartsDialer: options.ChatStreamPartsDialer,
820821
MaxChatsPerAcquire: int32(maxChatsPerAcquire), //nolint:gosec // maxChatsPerAcquire is clamped to int32 range above.
821822
ProviderAPIKeys: providerAPIKeys,
822823
AllowBYOK: options.DeploymentValues.AI.BridgeConfig.AllowBYOK.Value(),
@@ -1340,6 +1341,7 @@ func New(options *Options) *API {
13401341
r.Get("/prompts", api.getChatUserPrompts)
13411342
r.Route("/stream", func(r chi.Router) {
13421343
r.Get("/", api.streamChat)
1344+
r.Get("/parts", api.streamChatParts)
13431345
r.Get("/desktop", api.watchChatDesktop)
13441346
r.Get("/git", api.watchChatGit)
13451347
})

coderd/exp_chats.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7958,3 +7958,23 @@ func (api *API) getChatDebugRun(rw http.ResponseWriter, r *http.Request) {
79587958

79597959
httpapi.Write(ctx, rw, http.StatusOK, db2sdk.ChatDebugRunDetail(run, steps))
79607960
}
7961+
7962+
// EXPERIMENTAL: this endpoint is experimental and is subject to change.
7963+
//
7964+
// @Summary Stream chat parts via WebSockets
7965+
// @ID stream-chat-parts-via-websockets
7966+
// @Security CoderSessionToken
7967+
// @Tags Chats
7968+
// @Produce json
7969+
// @Param chat path string true "Chat ID" format(uuid)
7970+
// @Success 200 {object} codersdk.ChatStreamEvent
7971+
// @Router /api/experimental/chats/{chat}/stream/parts [get]
7972+
// @x-apidocgen {"skip": true}
7973+
// @Description Experimental: this endpoint is subject to change.
7974+
func (api *API) streamChatParts(rw http.ResponseWriter, r *http.Request) {
7975+
ctx := r.Context()
7976+
chat := httpmw.ChatParam(r)
7977+
if err := api.chatDaemon.ServeStreamPartsAuthorized(rw, r, chat); err != nil {
7978+
api.Logger.Named("chat_stream_parts").Debug(ctx, "chat stream parts closed", slog.Error(err))
7979+
}
7980+
}

coderd/pubsub/chatstreamnotify.go

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)