1
0
Fork 0

fix(profile): handle blank dossier excerpt updates

Accept null content in updatePersonalExcerpt/updateIntelExcerpt and store
null when the submitted excerpt is empty instead of an empty Lexical state,
skipping the max-length check for blank submissions.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Jason Fraley 2026-09-06 05:36:54 -04:00
parent 33174572cc
commit db02be7ce9

View file

@ -180,7 +180,7 @@ async function findProfileOwner(
export async function updatePersonalExcerpt(input: { export async function updatePersonalExcerpt(input: {
profileId: number; profileId: number;
content: LexicalStateValue; content: LexicalStateValue | null;
}): Promise<ActionResult> { }): Promise<ActionResult> {
try { try {
const { payload, user } = await authenticate(); const { payload, user } = await authenticate();
@ -194,7 +194,8 @@ export async function updatePersonalExcerpt(input: {
return { success: false, error: "You can only edit your own personal excerpt." }; return { success: false, error: "You can only edit your own personal excerpt." };
} }
if (lexicalPlaintextLength(input.content) > PERSONAL_EXCERPT_MAX_LENGTH) { const blank = !input.content || lexicalPlaintextLength(input.content) === 0;
if (!blank && lexicalPlaintextLength(input.content) > PERSONAL_EXCERPT_MAX_LENGTH) {
return { return {
success: false, success: false,
error: `Personal excerpt must be ${PERSONAL_EXCERPT_MAX_LENGTH} characters or fewer.`, error: `Personal excerpt must be ${PERSONAL_EXCERPT_MAX_LENGTH} characters or fewer.`,
@ -204,7 +205,7 @@ export async function updatePersonalExcerpt(input: {
await payload.update({ await payload.update({
collection: "profiles", collection: "profiles",
id: input.profileId, id: input.profileId,
data: { dossier: { personalExcerpt: input.content } }, data: { dossier: { personalExcerpt: blank ? null : input.content } },
overrideAccess: true, overrideAccess: true,
}); });
@ -225,7 +226,7 @@ export async function updatePersonalExcerpt(input: {
export async function updateIntelExcerpt(input: { export async function updateIntelExcerpt(input: {
profileId: number; profileId: number;
content: LexicalStateValue; content: LexicalStateValue | null;
}): Promise<ActionResult> { }): Promise<ActionResult> {
try { try {
const { payload, user } = await authenticate(); const { payload, user } = await authenticate();
@ -240,7 +241,8 @@ export async function updateIntelExcerpt(input: {
return { success: false, error: "Profile not found." }; return { success: false, error: "Profile not found." };
} }
if (lexicalPlaintextLength(input.content) > INTEL_EXCERPT_MAX_LENGTH) { const blank = !input.content || lexicalPlaintextLength(input.content) === 0;
if (!blank && lexicalPlaintextLength(input.content) > INTEL_EXCERPT_MAX_LENGTH) {
return { return {
success: false, success: false,
error: `Intelligence record must be ${INTEL_EXCERPT_MAX_LENGTH} characters or fewer.`, error: `Intelligence record must be ${INTEL_EXCERPT_MAX_LENGTH} characters or fewer.`,
@ -250,7 +252,7 @@ export async function updateIntelExcerpt(input: {
await payload.update({ await payload.update({
collection: "profiles", collection: "profiles",
id: input.profileId, id: input.profileId,
data: { dossier: { intelExcerpt: input.content } }, data: { dossier: { intelExcerpt: blank ? null : input.content } },
overrideAccess: true, overrideAccess: true,
}); });