import { IDisposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import { IRange } from "../../../../editor/common/core/range.js"; import { IFeedbackPullRequest } from "../../../../platform/agentHost/common/meta/agentFeedbackAnnotations.js"; import { ISession, ISessionFileChange } from "../../../services/sessions/common/session.js"; import { Event, URI } from "../../../sessions.web.main.internal.js"; import { ICodeReviewSuggestion } from "../../codeReview/browser/codeReviewService.js"; import { IAgentFeedbackContext } from "./agentFeedbackEditorUtils.js"; import { AgentFeedbackKind, AgentFeedbackState, IAgentFeedback } from "./agentFeedbackModel.js"; import { IAgentFeedbackChangeEvent, IAgentFeedbackCommentRevealEvent, IAgentFeedbackAddedEvent, IAgentFeedbackConvertedEvent, IAgentFeedbackReplyAddedEvent, IAgentFeedbackSubmittedEvent, IAcceptFeedbackOptions, INavigableSessionComment, IAgentFeedbackNavigationBearing, ISubmitFeedbackOptions } from "./agentFeedbackService.js"; export declare const IAgentFeedbackService: import("../../../../platform/instantiation/common/instantiation.js").ServiceIdentifier; export interface IAgentFeedbackService { readonly _serviceBrand: undefined; readonly onDidChangeFeedback: Event; readonly onDidChangeFeedbackVisibility: Event; readonly onDidChangeNavigation: Event; readonly onDidRevealSessionComment: Event; /** Fired when {@link getFeedbackSessionResource} may resolve differently. */ readonly onDidChangeFeedbackScope: Event; /** * The feedback scope of the active session view: the active session itself, * or {@link AGENT_FEEDBACK_NEW_SESSION_RESOURCE} while it is undefined or * uncreated. Unlike {@link getFeedbackSessionResource} this is not * file-scoped, so it always resolves to a scope. */ readonly activeFeedbackSessionResource: IObservable; /** Fired when a new user-authored feedback item is added. */ readonly onDidAddFeedback: Event; /** Fired when an external review comment is converted into agent feedback. */ readonly onDidConvertFeedback: Event; /** Fired when a reply is appended to an existing feedback thread. */ readonly onDidAddReply: Event; /** Fired when feedback items are submitted to the agent. */ readonly onDidSubmitFeedback: Event; /** * Add a feedback item for the given session. {@link kind} (defaults to * {@link AgentFeedbackKind.UserReview}) classifies the origin of the * feedback. {@link state} (defaults * to {@link AgentFeedbackState.Accepted}) sets the initial lifecycle state * and selects which lifecycle event is fired. */ addFeedback(sessionResource: URI, resourceUri: URI, range: IRange, text: string, suggestion?: ICodeReviewSuggestion, context?: IAgentFeedbackContext, sourcePRReviewCommentId?: string, kind?: AgentFeedbackKind, state?: AgentFeedbackState, sourcePullRequest?: IFeedbackPullRequest, sourcePRReviewCommentAuthor?: string): IAgentFeedback; /** * Accept a feedback item that is currently in the * {@link AgentFeedbackState.Created} state, transitioning it to * {@link AgentFeedbackState.Accepted} so it becomes submittable and is * attached to the chat input. * * When {@link IAcceptFeedbackOptions.revealToAgent} is set, the item is * additionally flagged as pending reveal to the agent so the * `viewUnreviewedComments` server tool returns exactly the comments the user * chose to reveal for that invocation. */ acceptFeedback(sessionResource: URI, feedbackId: string, options?: IAcceptFeedbackOptions): void; /** * Remove a single feedback item. */ removeFeedback(sessionResource: URI, feedbackId: string): void; /** * Update the text of an existing feedback item. */ updateFeedback(sessionResource: URI, feedbackId: string, newText: string): void; /** Backfill missing PR-review source details without replacing known values. */ updateFeedbackSourcePullRequest(sessionResource: URI, feedbackId: string, sourcePullRequest: IFeedbackPullRequest, sourcePRReviewCommentAuthor?: string): void; /** * Mark an existing feedback item as resolved. Resolving moves the item to * {@link AgentFeedbackState.Resolved}; un-resolving returns it to * {@link AgentFeedbackState.Submitted}. */ setFeedbackResolved(sessionResource: URI, feedbackId: string, resolved: boolean): void; /** * Append a reply to an existing feedback item, making it part of the same * comment thread. */ addReply(sessionResource: URI, feedbackId: string, replyText: string): void; /** * Get all feedback items for a session. */ getFeedback(sessionResource: URI): readonly IAgentFeedback[]; /** Whether feedback for this session is owned by an Agent Host annotations channel. */ isAgentHostSession(sessionResource: URI): boolean; /** Show resolved feedback items in editor comment surfaces for this window. */ showFeedbackInEditor(sessionResource: URI, feedbackIds: readonly string[]): void; /** Hide a resolved feedback item that was explicitly shown in editor comment surfaces. */ hideFeedbackInEditor(sessionResource: URI, feedbackId: string): void; /** Get resolved feedback item ids that were explicitly shown in editor comment surfaces. */ getVisibleResolvedFeedbackIds(sessionResource: URI): ReadonlySet; /** * Whether {@link getFeedback} reflects the authoritative item set for the * session. For agent-host sessions this is `false` until the session's * annotations snapshot has been received; for other sessions it is always * `true`. Callers that seed feedback from another source must wait for this * to avoid acting on a transiently-empty list. */ hasLoadedFeedback(sessionResource: URI): boolean; /** * Resolve the session that owns the given file resource. Returns the * session that was active when the file's editor was first opened; if the * file has never been tracked, falls back to the currently active session. * Returns `undefined` when the file is not eligible for feedback (an * output-channel resource) or when there is no created session to scope to. */ getSessionForFile(resourceUri: URI): ISession | undefined; /** File changes for the focused chat in the given session. */ getChatChanges(sessionResource: URI): readonly ISessionFileChange[]; /** * Resolve the feedback scope shown for a file in the current session view, or * `undefined` when the file is out of scope. */ getFeedbackSessionResource(resourceUri: URI): URI | undefined; registerFeedbackResourceScope(resourceUri: URI, sessionResource: URI): IDisposable; /** * Resolve the most recently updated session that has feedback for a given resource. */ getMostRecentSessionForResource(resourceUri: URI): URI | undefined; /** * Set the navigation anchor to a specific feedback item, open its editor, and fire a navigation event. */ revealFeedback(sessionResource: URI, feedbackId: string): Promise; /** * Open an editor for the given session comment (feedback or code-review) at its range * and set it as the navigation anchor. */ revealSessionComment(sessionResource: URI, commentId: string, resourceUri: URI, range: IRange): Promise; /** * Navigate to next/previous feedback item in a session. */ getNextFeedback(sessionResource: URI, next: boolean): IAgentFeedback | undefined; getNextNavigableItem(sessionResource: URI, items: readonly T[], next: boolean): T | undefined; setNavigationAnchor(sessionResource: URI, itemId: string | undefined): void; /** * Get the current navigation bearings for a session. */ getNavigationBearing(sessionResource: URI, items?: readonly INavigableSessionComment[]): IAgentFeedbackNavigationBearing; /** * Clear all feedback items for a session (e.g., after sending). */ clearFeedback(sessionResource: URI): void; /** * Mark all accepted feedback items for the session as submitted, firing * {@link onDidSubmitFeedback} with the per-kind counts of the items that * were submitted. Agent-host sessions move the items to * {@link AgentFeedbackState.Submitted} so they stay visible until the agent * resolves them; other providers have no such agent loop, so the items move * straight to {@link AgentFeedbackState.Resolved}. No-op when there are no * accepted items. */ markFeedbackSubmitted(sessionResource: URI, feedbackIds?: readonly string[]): void; /** * Submit the currently accumulated accepted feedback for the session to the * agent and mark those items as submitted. Waits for the session's chat model to be loaded * into a chat widget, then resolves once the request has been accepted by that widget — which, * while another request is in progress, means it was queued rather than sent. Returns whether * the feedback was submitted. */ submitFeedback(sessionResource: URI, options?: ISubmitFeedbackOptions): Promise; /** * Add a feedback item and then submit the feedback. Waits for the * attachment to be updated in the chat widget before submitting. */ addFeedbackAndSubmit(sessionResource: URI, resourceUri: URI, range: IRange, text: string, suggestion?: ICodeReviewSuggestion, context?: IAgentFeedbackContext, sourcePRReviewCommentId?: string, kind?: AgentFeedbackKind): Promise; }