HarperFast / HarperFast/studio

Visual schema editor flattens interior indentation in multi-line """…""" descriptions

Open
#1,480 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5
Forks
4
Avg merge
1d 8h
Merged PRs (30d)
40

Description

## Background

Follow-up from the [PR #1468 review](https://github.com/HarperFast/studio/pull/1468#pullrequestreview) (thanks @kriszyp for flagging). This predates that PR — not a regression from it — but the PR slightly widened the blast radius, so capturing it here.

## Problem

When the visual schema editor regenerates an edited table, [`appendCommentLines`](https://github.com/HarperFast/studio/blob/stage/src/features/instance/applications/lib/schema/serializeSchema.ts) (formerly `indentCommentLines`) strips **all** leading whitespace from every interior line of a comment/description block before reapplying the canonical indent:

```js
const line = rawLine.replace(/\r$/, '').replace(/^[ \t]+/, '');
lines.push(line ? `${indent}${line}` : '');
```

For a multi-line GraphQL description (`"""…"""`) this flattens intentionally-deeper indentation — e.g. nested markdown lists or code fences inside the docstring — down to the single canonical indent. The per-line strip exists to stop indentation from *compounding* on each edit (that fix is correct); the issue is it can't tell "structural indent to normalize" from "intentional interior indent to preserve."

Since PR #1468, `trailingComments` also route through this helper, so trailing description blocks are affected too, not just field-leading ones.

## Impact

- Only affects tables that get **edited** in the visual editor (unedited tables round-trip verbatim).
- Cosmetic — no data/semantic loss; the description text survives, only its interior indentation is normalized.

## Possible direction

Preserve indentation *relative* to the block's own minimum indent instead of stripping to zero: compute the common leading-whitespace prefix across the block's lines, strip only that, then apply the canonical indent — so relative nesting is retained while compounding is still prevented.

## Pointers

- `src/features/instance/applications/lib/schema/serializeSchema.ts` — `appendCommentLines`
- Existing round-trip/idempotency coverage: `serializeSchema.test.ts` (the `"""` description tests)

Contributor guide

Open the contributing guide

Research direction

Start in src/features/instance/applications/lib/schema/serializeSchema.ts at appendCommentLines, then read the existing triple-quoted description cases in serializeSchema.test.ts. Run the round-trip and idempotency tests first. Done means edited descriptions retain intentional relative indentation while repeated serialization does not compound indentation, including trailing descriptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.