Skip to content

Flatten multi-line note content into single-line next actions#60

Merged
tavva merged 1 commit into
mainfrom
fix/multiline-next-action-from-note
Jun 29, 2026
Merged

Flatten multi-line note content into single-line next actions#60
tavva merged 1 commit into
mainfrom
fix/multiline-next-action-from-note

Conversation

@tavva

@tavva tavva commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Problem

Processing a note inbox item to a next action could write the action across multiple lines, breaking the one-action-per-line invariant. It only showed up when the item had a (source) link.

Root cause

The (source) link was a co-symptom, not the cause. Both come from the inbox item being a note rather than a line:

  • getNoteItems stores a note's entire raw file content as the item content (line items are trimmed to a single line; notes are not).
  • That becomes EditableItem.original.
  • deleteInboxItem returns a [[...|source]] wikilink only for note items — hence the correlation with the source link.
  • When the action field isn't edited, resolveFinalNextActions falls back to [item.original], and the multi-line content is written verbatim as - [ ] <multi-line text> (source).

Fix

resolveFinalNextActions now collapses each resolved action to a single line via a flattenToSingleLine helper (split on newlines, trim each line, drop blanks, join with a space). This is the single chokepoint every write path (next-actions-file, create-project, add-to-project, someday-file) reads actions from, so the invariant holds everywhere.

Testing

  • Added a failing-then-passing test: "flattens multi-line note content into a single-line next action".
  • Full suite: 920 tests pass. Build clean.

https://claude.ai/code/session_01L6PM2wwRPN7BDUDcB3N6kw

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of saved “next action” text so multi-line entries are stored as a single line.
    • Prevented line breaks, extra spacing, and blank lines from appearing in persisted action text.
  • Tests

    • Added coverage for persisting multi-line note content to ensure it is flattened correctly before saving.

Note inbox items keep their full raw file content as the item's
original text. When processed without editing the action field, that
multi-line content was written verbatim as a next action, embedding
newlines and breaking the one-action-per-line invariant. The bug only
appeared alongside a (source) link because both originate from
note-type items.

Collapse each resolved next action to a single line at the point all
write paths read from, so the invariant holds everywhere.

Claude-Session: https://claude.ai/code/session_01L6PM2wwRPN7BDUDcB3N6kw
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4dccc90d-2644-43f2-8133-a6ad0e32630d

📥 Commits

Reviewing files that changed from the base of the PR and between 869f53d and 7e807c1.

📒 Files selected for processing (2)
  • src/inbox-item-persistence.ts
  • tests/inbox-item-persistence.test.ts

📝 Walkthrough

Walkthrough

Adds a flattenToSingleLine local helper in src/inbox-item-persistence.ts that trims, filters, and joins multi-line text into a single space-separated line. resolveFinalNextActions now maps this helper over all resolved next-action strings. A new test verifies that multi-line original text is flattened before being passed to addToNextActionsFile.

Changes

Multi-line next-action normalization

Layer / File(s) Summary
flattenToSingleLine helper and resolveFinalNextActions update
src/inbox-item-persistence.ts, tests/inbox-item-persistence.test.ts
Adds flattenToSingleLine which splits on newlines, trims and drops blank segments, then joins with spaces. Maps it over all actions in resolveFinalNextActions. New test asserts addToNextActionsFile receives a single-line string when original contains newlines.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hops through fields of text,
Where newlines hide and spaces vex.
With one swift trim and join in line,
The actions flow in neat design.
No breaks remain — just clean content! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: flattening multi-line note content into single-line next actions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/multiline-next-action-from-note

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tavva
tavva merged commit 4c08d43 into main Jun 29, 2026
8 checks passed
@tavva
tavva deleted the fix/multiline-next-action-from-note branch June 29, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant