Documentation
¶
Overview ¶
Package statuscomment posts agent start/completion status comments on issues and pull requests via the forge abstraction.
Unlike internal/sticky, which manages persistent bot comments that accumulate history across multiple runs (e.g. review output), statuscomment manages transient lifecycle markers: a start comment created when the agent begins, then updated or replaced on completion (including cancellation). The two packages share the HTML-marker convention but have different lifecycles and placement heuristics.
Index ¶
- func ReconcileOrphaned(ctx context.Context, client forge.Client, owner, repo string, number int, ...) error
- type ClientFactory
- type Notifier
- func (n *Notifier) HasClientFactory() bool
- func (n *Notifier) InvokeClientFactory(ctx context.Context) (forge.Client, error)
- func (n *Notifier) PostCompletion(ctx context.Context, description, status string) error
- func (n *Notifier) PostStart(ctx context.Context, description string) error
- func (n *Notifier) SetClientFactory(f ClientFactory)
- func (n *Notifier) SetWarnFunc(f func(string, ...any))
- type TerminationReason
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReconcileOrphaned ¶ added in v0.18.0
func ReconcileOrphaned(ctx context.Context, client forge.Client, owner, repo string, number int, runID, runURL, sha string, reason TerminationReason) error
ReconcileOrphaned finds and finalizes a status comment that was left in "Started" state because the process was hard-killed (SIGKILL, OOM, etc.) before the deferred PostCompletion call could run.
It searches for a comment matching the run's HTML marker (<!-- fullsend:agent-status:<runID> -->) that has not yet reached a terminal state. Terminal states are detected by the <!-- fullsend:status:terminal --> tag, which is included in both completion and interrupted comment bodies. If found in a non-terminal state, it updates the comment to "Interrupted" and tags it as terminal.
This function is designed to be called from an out-of-process cleanup mechanism (e.g., a GitHub Actions post-job step) that runs even when the fullsend process is killed. It does not require a Notifier instance since the process that created it is gone.
Returns an error if runID contains characters outside [a-zA-Z0-9_-].
Types ¶
type ClientFactory ¶ added in v0.18.0
ClientFactory returns a fresh forge.Client. It is called before each API operation so the underlying token is never stale.
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier manages status comment lifecycle for a single agent run.
func New ¶
func New(client forge.Client, cfg config.StatusNotificationConfig, owner, repo string, number int, runURL, sha, runID string) *Notifier
New creates a Notifier. The runID is embedded in the HTML marker comment so multiple concurrent runs on the same issue don't collide. It panics if runID contains characters outside [a-zA-Z0-9_-].
func (*Notifier) HasClientFactory ¶ added in v0.18.0
HasClientFactory reports whether a client factory has been configured.
func (*Notifier) InvokeClientFactory ¶ added in v0.19.0
InvokeClientFactory calls the configured factory and returns the result. Useful for verifying factory wiring in tests without triggering API calls.
func (*Notifier) PostCompletion ¶
PostCompletion posts or edits a completion comment. status should be "success", "failure", or "cancelled".
Placement follows three rules:
- If the agent posted output after the start comment (a bot-authored comment that is not a status marker), the start comment is updated in place — the agent's output is the visible forward signal and a separate end comment would be redundant.
- If no agent output was posted and the start comment is still the last entry on the timeline, the start comment is updated in place.
- Otherwise (other activity pushed past the start, but no agent output), a new completion comment is posted so the user sees the result while reading forward.
func (*Notifier) SetClientFactory ¶ added in v0.18.0
func (n *Notifier) SetClientFactory(f ClientFactory)
SetClientFactory sets a factory that mints a fresh forge.Client before each API operation. When set, the static client passed to New is only used if the factory is nil.
func (*Notifier) SetWarnFunc ¶
SetWarnFunc sets a function called for non-fatal warnings (e.g. API errors during fail-open operations). Defaults to a no-op.
type TerminationReason ¶ added in v0.18.0
type TerminationReason string
TerminationReason describes why the agent process was terminated.
const ( ReasonTerminated TerminationReason = "terminated" ReasonCancelled TerminationReason = "cancelled" )