2026-07-28 02:50:02 +03:00
|
|
|
import type { Session } from '@opencode-ai/sdk/v2';
|
2026-08-13 22:00:15 +03:00
|
|
|
import { isReviewSession } from '@/lib/sessionReviewMetadata';
|
2026-07-28 02:50:02 +03:00
|
|
|
|
|
|
|
|
export const resolveChatPromptReadOnly = (
|
|
|
|
|
session: Session | null | undefined,
|
|
|
|
|
allowPromptingSubagentSessions: boolean,
|
|
|
|
|
readOnly: boolean,
|
|
|
|
|
): boolean => {
|
2026-08-13 22:00:15 +03:00
|
|
|
// Review sessions are independent conversations even if an older server or
|
|
|
|
|
// cached record still carries parentID. Their explicit metadata is the
|
|
|
|
|
// authority; only the surface itself may make them read-only.
|
|
|
|
|
if (isReviewSession(session)) {
|
|
|
|
|
return readOnly;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-28 02:50:02 +03:00
|
|
|
if (session?.parentID) {
|
|
|
|
|
return !allowPromptingSubagentSessions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return readOnly;
|
|
|
|
|
};
|