Skip to content

Conversation

@Dimillian
Copy link
Owner

Motivation

  • Reduce the monolithic ViewModel responsibilities by extracting text setup and processing into dedicated helpers.
  • Improve readability and testability of text-related logic by breaking large functions into smaller, focused pieces.
  • Provide a stable API for the editor view to bind to text state via a Binding instead of direct NSMutableAttributedString mutation.
  • Add unit tests to validate core text processing behavior in isolation.

Description

  • Extracted text state into StatusEditor.TextState (Editor/TextState.swift) holding statusText, mentionString, urlLengthAdjustments, suggestion range and backup text.
  • Introduced StatusEditor.TextService (Editor/TextService.swift) that encapsulates initial text setup, insertion/replacement helpers, and processText logic (highlights, URL handling, suggestions).
  • Refactored StatusEditor.ViewModel to use textState + textService, added statusTextBinding for the editor view, and replaced large text manipulation functions with small delegating methods like updateStatusText and applyTextChanges.
  • Updated EditorView to use the new statusTextBinding and added a StatusKit test target with TextServiceTests that exercise hashtag suggestion, suggestion reset, URL length adjustment, and initial reply mention generation.

Testing

  • Added StatusKitTests/TextServiceTests.swift with unit tests for TextService behaviors including suggestion detection and URL length adjustments.
  • Added a StatusKit test target in Packages/StatusKit/Package.swift so tests are discoverable by the package test runner.
  • No automated tests were executed in this environment, so no pass/fail results are available here.
  • Tests are written to be run via the normal Xcode / Swift Package Manager test workflows (e.g. xcodebuild or swift test).

Codex Task

Introduces new test cases for hashtag suggestions, mention normalization, legacy quote formatting, and share extension text handling in TextServiceTests. Also refactors test helpers to support additional parameters and imports UniformTypeIdentifiers for share extension tests.
@Dimillian Dimillian merged commit ae534b8 into main Dec 29, 2025
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants