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

Method finalizeSuccessfulTurnStatusLabelWithAfterFunc

coderd/x/chatd/chatd.go:9658–9682  ·  view source on GitHub ↗
(
	ctx context.Context,
	chat database.Chat,
	status database.ChatStatus,
	runResult runChatResult,
	logger slog.Logger,
	afterFinalize func(context.Context, string),
)

Source from the content-addressed store, hash-verified

9656}
9657
9658func (p *Server) finalizeSuccessfulTurnStatusLabelWithAfterFunc(
9659 ctx context.Context,
9660 chat database.Chat,
9661 status database.ChatStatus,
9662 runResult runChatResult,
9663 logger slog.Logger,
9664 afterFinalize func(context.Context, string),
9665) {
9666 // This helper runs during processChat cleanup, while processChat is
9667 // still counted in p.inflight. Do not take inflightMu here because
9668 // drainInflight holds it while waiting.
9669 p.inflight.Go(func() {
9670 finalizeCtx := context.WithoutCancel(ctx)
9671 statusLabel := p.generateFinalTurnStatusLabel(finalizeCtx, chat, status, runResult, logger)
9672 logger.Debug(finalizeCtx, "generated chat turn status label",
9673 slog.F("chat_id", chat.ID),
9674 slog.F("status", status),
9675 slog.F("label_length", len(statusLabel)),
9676 )
9677
9678 p.updateLastTurnSummary(finalizeCtx, chat, chat.UpdatedAt, statusLabel, logger)
9679
9680 afterFinalize(finalizeCtx, statusLabel)
9681 })
9682}
9683
9684func (p *Server) generateFinalTurnStatusLabel(
9685 ctx context.Context,

Calls 3

updateLastTurnSummaryMethod · 0.95
GoMethod · 0.80

Tested by

no test coverage detected