Skip to content

fix: filter partial form fields and fix centered text in scroll mode#674

Open
torlando-tech wants to merge 6 commits into
mainfrom
fix/nomadnet-partial-fields-and-centering
Open

fix: filter partial form fields and fix centered text in scroll mode#674
torlando-tech wants to merge 6 commits into
mainfrom
fix/nomadnet-partial-fields-and-centering

Conversation

@torlando-tech
Copy link
Copy Markdown
Owner

Summary

  • Partial field filtering: PartialManager.buildFormDataJson now only forwards form fields declared by each partial's fieldNames list, matching NomadNet TUI's __get_partial_request_data() behavior. "*" = all fields, empty list = none. Prevents undeclared fields (e.g. password inputs) from leaking to unrelated partial endpoints.
  • Scroll-mode centering: Centered/right-aligned lines in MONOSPACE_SCROLL mode now use exact viewport width (fillMaxWidth + TextAlign) so text actually centers instead of left-aligning with widthIn(min=).
  • Test update: MicronParserTest.backtick before link with formatting now uses a real-world NomadNet node index line with trailing text after a styled link.

Test plan

  • Browse a NomadNet page with partials that declare specific fields — verify only those fields are forwarded
  • Browse a page with centered text in scroll mode — verify it actually centers
  • Run :micron:testDebugUnitTest — updated parser test passes

🤖 Generated with Claude Code

PartialManager now only forwards form fields declared by each partial's
field list, matching NomadNet TUI's __get_partial_request_data behavior.
"*" forwards all fields; an empty list forwards none. This prevents
undeclared fields (e.g. password inputs) from leaking to unrelated
partial endpoints.

MicronComposables scroll-mode centering fix: centered/right-aligned
lines now use exact viewport width (fillMaxWidth + TextAlign) instead of
min-width, so text actually centers rather than left-aligning.

Updated MicronParserTest to use a real-world NomadNet node index line
with trailing text after a styled link.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread app/src/main/java/com/lxmf/messenger/nomadnet/PartialManager.kt
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 13, 2026

Greptile Summary

This PR fixes two independent bugs and updates a related test. The field-filtering change in PartialManager prevents undeclared form fields from leaking to unrelated partial endpoints, matching NomadNet TUI behaviour. The link-establishment rewrite in rns_api.py adds retry logic and a defensive getattr chain for the per-hop timeout constant (addressing previously flagged issues).

  • PartialManager.kt: fieldNames is stored on PartialState and passed through every fetch path; buildFormDataJson now filters to only declared fields ("*" = all, empty = none).
  • python/rns_api.py: Single-shot link establishment replaced with a 3-attempt retry loop; ESTABLISHMENT_TIMEOUT_PER_HOP is now read via a safe getattr chain with a hard-coded 6s fallback.
  • MicronParserTest.kt: Parser test updated to a real-world NomadNet link format with a colon-prefixed destination and trailing plain text.

Confidence Score: 5/5

Safe to merge — all three changes are narrow, well-scoped fixes with no new failure modes introduced.

The field-filtering logic in PartialManager is straightforward and mirrors a well-understood reference implementation. The link-retry rewrite in rns_api.py directly resolves both previously flagged concerns: the AttributeError on ESTABLISHMENT_TIMEOUT_PER_HOP is now guarded by a getattr chain, and the single-shot establishment is replaced with a bounded retry loop. The test update reflects a real-world input and its assertions are correct. No regressions or new unsafe paths were identified.

No files require special attention.

Important Files Changed

Filename Overview
app/src/main/java/com/lxmf/messenger/nomadnet/PartialManager.kt Adds fieldNames to PartialState and threads it through all fetch paths; buildFormDataJson now filters form fields to only those declared by the partial, matching NomadNet TUI semantics.
python/rns_api.py Replaces single-shot link establishment with a retry loop (up to 3 attempts); resolves the previously flagged AttributeError risk via a defensive getattr chain for ESTABLISHMENT_TIMEOUT_PER_HOP.
micron/src/test/java/com/lxmf/messenger/micron/MicronParserTest.kt Updates the backtick before link with formatting test to use a real-world NomadNet link with a colon-prefixed destination and trailing text; assertions adjusted accordingly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[fetchAndUpdate called\nwith allowedFields] --> B{allowedFields\ncontains '*'?}
    B -- Yes --> C[Use all form fields]
    B -- No --> D{allowedFields\nempty?}
    D -- Yes --> E[No fields / return null]
    D -- No --> F[Filter keys present\nin allowedFields]
    C --> G{filtered\nempty?}
    F --> G
    G -- Yes --> E
    G -- No --> H[Build JSONObject\nand send to partial endpoint]

    subgraph rns_api [Link Establishment Retry Loop]
        I[attempt 1..3] --> J{remaining\n< 5s?}
        J -- Yes --> K[Break — deadline exhausted]
        J -- No --> L[Create RNS.Link\nwait up to min\nper_attempt_base, remaining-5s\nor 5s min]
        L --> M{link.status\n== ACTIVE?}
        M -- Yes --> N[Return active link]
        M -- No --> O{reason == 0x03\nDESTINATION_CLOSED?}
        O -- Yes --> P[Return error:\nConnection closed by node]
        O -- No --> Q[Teardown & retry]
        Q --> I
        K --> R[Return error:\nConnection timed out]
    end
Loading

Reviews (6): Last reviewed commit: "chore(greptile): iteration 3 — applied 1..." | Re-trigger Greptile

torlando-tech and others added 2 commits March 13, 2026 18:32
Link establishment now retries up to 3 times when the single RNS link
request packet is lost (same single-shot-no-retry issue as request_path).
Each attempt waits up to the per-hop timeout before tearing down and
retrying. Destination-closed (0x03) is treated as permanent and not
retried.

Reverts the scroll-mode centering change from the previous commit — it
caused long lines (ASCII art) to word-wrap instead of scrolling
horizontally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address Greptile review findings:

- PartialManager: preserve fieldNames in onSuccess and onFailure
  PartialState constructors so reloads retain field filtering.
  Refactor buildFormDataJson to use when-expression, reducing return
  count from 4 to 3 (fixes detekt ReturnCount).

- rns_api.py: capture link_established and link_closed_reason via
  default args in retry loop closures to prevent late-firing callbacks
  from a prior iteration corrupting the next iteration's state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sentry
Copy link
Copy Markdown
Contributor

sentry Bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 0% with 41 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
python/rns_api.py 0.00% 41 Missing ⚠️

📢 Thoughts on this report? Let us know!

torlando-agent Bot and others added 3 commits May 8, 2026 02:20
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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