Skip to content

docs: tidy code comments in package/src - #3884

Merged
isekovanic merged 2 commits into
V10from
docs/v10-tidy-code-comments
Oct 21, 2026
Merged

isekovanic merged 2 commits into
V10from
docs/v10-tidy-code-comments

Conversation

@oliverlaz

Copy link
Copy Markdown
Member

🎯 Goal

Tidy the code and doc comments in package/src (SDK source and ai-components; tests and mock-builders are out of scope) so they describe what the code does today, keep only what is non-obvious, and stop contradicting the code. This is a comment-only change: no behavior change.

πŸ›  Implementation details

  • Present tense only. Removed history ("previously", "no longer", "used to", "formerly", "as in vX", migration notes), review and issue IDs, section banners, ASCII diagrams, em-dashes and "deliberately / explicitly" filler. Generic code stays generic.
  • Terser. Comment lines in scope went from 6,666 to 4,600 across 893 files (436 files changed). Doc blocks of 13 or more lines went from 59 to 29.
  • Wrong comments fixed (about 120). Every claim was checked against the code. Examples: the SQLCipher note on getOfflineDbEncryptionKey said a missing flag is "silently ignored" while the code throws SQLCIPHER_BUILD_MISSING; buildThumbnailGrid's examples were swapped; getDurationLabelFromDuration said seconds but takes milliseconds; @returns on the sqlite query helpers said string but they return [sql, params]; the language.* names were credited to @stream-io/i18n instead of stream-chat.
  • Public API docs. Any exported function with a doc block now has @param (dot notation for object fields), @returns when it returns a value and @throws when it throws. Existing tags were kept. Internals (non-exported, private, @internal) are prose only.
  • Commented-out code removed in 7 files (VictoryChart, SendUp, the vega-lite schema, flatten-nodes, MessageComposer, GiphyChip, theme).
  • Never touched: code, string literals, TODO/FIXME lines, eslint-disable and @ts-* directives, the lines carrying @deprecated / @internal / @example / @default / @overrideType, and generated code.
  • Two files outside package/src: package/{native,expo}-package/src/native/NativeAIDictation.ts got the same comment fix as src/ai-components/native-specs/NativeAIDictation.ts, because validate-entry-isolation requires the three copies to be identical.
  • Base: cut from V10 (not stacked on another PR). The PR targets V10, not develop.

🎨 UI Changes

None.

πŸ§ͺ Testing

How "comment-only" was verified:

  • A script compares the token stream of every file in scope (types, JSX text and string literals included, comments excluded) against V10. It is identical for all files except three, which are expected consequences of removing commented-out code: VictoryChart.tsx and vega-lite/schema.ts (prettier collapsed the victory-native import and the MarkName enum onto one line, dropping a trailing comma) and SendUp.tsx (the empty JSX expression {} that held a commented-out <Circle />).
  • The same script checks that non-comment lines, TODO/FIXME lines and directive counts are identical. It was validated with negative controls (changed string, type, operator, deleted line, stray whitespace, JSX text, edited TODO, renamed @deprecated, reworded @ts-*) that it flags.
  • yarn lint, yarn build, yarn typecheck and yarn test:unit (2,209 tests) pass.

What reviewers should look for:

  • Comments that are still wrong. Claims that could not be verified against the repo were kept trimmed rather than invented: the Expo audio defaults in types.ts, the React Native 0.87 and TS2589 / TS2883 notes, the iOS UITextView caching note, the FlashList onViewableItemsChanged note and the Android pinch-to-pan handoff.
  • A "why" that should have stayed (a timing, ordering or platform constraint whose removal could cause a bug).
  • Public docs that are now too terse, or still too long: Streami18n, i18n/runtimeDefaults.ts and the Chat props are the largest remaining blocks.

Not changed here (follow-ups): @default tags that disagree with the code (attachmentPickerBottomSheetHeight, attachmentSelectionBarHeight, allowConcurrentAudioPlayback), @example ./X.md pointers to files that do not exist, and the code issues noticed while reading.

β˜‘οΈ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch (targets V10, see above)
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios (comment-only change)
    • SampleApp iOS and Android
    • Expo iOS and Android

Rewrite the code and doc comments of the SDK source and ai-components in the present tense and keep
only what is non-obvious. Fix comments that disagreed with the code, add missing @param/@returns
tags to documented public functions, and remove commented-out code. No behavior change.
@oliverlaz
oliverlaz requested review from isekovanic and szuperaz and removed request for isekovanic October 21, 2026 05:58
The errors thrown by the `useXContext()` hooks linked to the removed
`basics/hello_stream_chat` page, which now returns 404. Link to the current
core-components / ui-components pages instead, and name the component that
actually provides each context:

- `useAttachmentPickerContext`: Channel (provided in ChannelShell), not OverlayProvider
- `useMessageListItemContext`: MessageList (no `MessageListItem` component exists)
- `useCreatePollContentContext`: CreatePoll, which wraps CreatePollContent in the provider

Also assert the messages of the hooks the suite did not cover.
@Stream-SDK-Bot

Copy link
Copy Markdown
Contributor

SDK Size

title develop branch diff status
js_bundle_size 2036 KB 2018 KB -18378 B πŸš€
ai_components_size 130 KB 130 KB 0 B 🟒

@oliverlaz
oliverlaz added this pull request to stack #3886 October 21, 2026 06:38
@isekovanic
isekovanic merged commit 59a09b1 into V10 Oct 21, 2026
2 checks passed
@isekovanic
isekovanic deleted the docs/v10-tidy-code-comments branch October 21, 2026 12:09
isekovanic added a commit that referenced this pull request Oct 21, 2026
## 🎯 Goal

Fix the code issues and wrong strings found while tidying the comments
in #3884, which deliberately left them alone (comment-only change).
**Stacked on #3884**: merge that first, then retarget this PR to `V10`.

## πŸ›  Implementation details

Every item was verified against the code first; the behavior fixes each
come with a test that failed before the fix.

**Bugs fixed**
- **Markdown links** (`generateMarkdownText`): the conversion loop
restarted from the untrimmed text on every link, so only the last link
became a markdown link and the trim was lost. Links are now converted in
one pass, longest first, so `getstream.io` inside `getstream.io/chat` is
not wrapped twice.
- **Offline drafts** (`upsertDraft`): the result of
`queries.concat(...)` was discarded, so a draft's quoted and parent
messages were never stored, although `getDraft` reads the quoted message
back from `messages`.
- **AI markdown `onLink`**: a rejected `onLink` was logged and rethrown
inside a fire-and-forget `.catch`, causing an unhandled rejection. Now
only logged.
- **`parseJsonChart`**: invalid JSON threw a `SyntaxError` instead of
the documented "Unknown type" error.
- **`MessageActionList`**: destructive actions were given `length:
standardActions.length` (visible to custom `MessageActionListItem`
overrides).
- **Emoji middleware**: an emoji with no `native` and empty `skins`
threw a `TypeError`; such entries are now skipped (there is nothing to
insert).
- **`FileIcon`**: `.xlsb` used the `.xlam` MIME type and so showed the
generic icon; removed duplicate `.odt/.ott/.fodt`, `application/gzip`
and `video/webm` entries.
- Removed an unreachable `null` branch in `getReactionsForFilterSort`
and a dead `?? 0` in `hashStringToNumber`.

**Strings**
- **Permission alerts**: the shared `common.cameraPermission.text` /
`common.galleryPermission.text` copy was ungrammatical ("Device gallery
permissions is used to take photos or videos") and is fixed. The
image-only channel image flow gets its own keys,
`channelDetails.editImageSheet.cameraPermission.text` /
`.galleryPermission.text`, instead of saying "photos or videos".
- **`useMessagesContext` error**: named `MessageList` (the context comes
from `<Channel>` / `<Thread>`) and linked a docs page that now returns
404. It now names `Channel` and links the live Channel page (the other
context errors are fixed in #3884).
- Clearer warning when the attachment picker cannot open (it reports the
missing `snapToIndex`), an accurate label for the gallery's video
placeholder, and fixed docs for `previewVoiceRecording`, the
`useIsMountedRef` example and an `eslint-disable` description.
- `keys.ts` regenerated; the SampleApp German and Italian dictionaries
updated for the new and changed keys.

**⚠️ Breaking: removed props that were never read** (v10 is a breaking
release; listed in `ai-docs/v10-breaking-changes.md`)
- `ProgressControl`: `width` (the control measures its own width).
- `MessageActionList`: `dismissOverlay` (each item closes the overlay
itself). A custom list that needs it can read
`useMessageContext().dismissOverlay`.
- `MessageFlashList`: `inverted` (the FlashList is never inverted).

**Checked and left unchanged**
- **Live locations in `upsertChannels`**: the `forEach(async)` really
does drop the queries (they are never written today). A naive fix would
make it worse: `locations.messageId` has a foreign key to `messages`, so
a live location whose message is outside the stored window fails the
whole channel batch. This needs a decision (drop the foreign key with a
`dbVersion` bump, or write only locations whose message is stored).
- **Gallery gestures**: the pan `finalXPosition` sign (velocity-gated
paging, chosen in #3241) and the double-tap zoom-in `translateX` stay as
they are.
- Not bugs: `useRAFCoalescedValue` (a test now guards the re-enable
case), the duration units (the gallery and media items both pass
milliseconds), the pinch `scale < 1` branches (reachable on iOS) and the
read of `translateY.value` right after starting an animation (Reanimated
still returns the release position at that point).
- `asyncMessagesMinimumPressDuration` is read by `AudioRecordingButton`,
so it stays.

## 🎨 UI Changes

Only the permission alert copy.

## πŸ§ͺ Testing

- New or extended tests for every behavior fix: `upsertDraft` (real
SQLite), `generateMarkdownText`, `Markdown` (`onLink` rejection),
`charts`, `FileIcon`, `emojiControl`, `getTrimmedAttachmentTitle`,
`useRAFCoalescedValue`, `ImageGallery`, `ImageGalleryVideoControl`,
`MessageActionList`, `useEditChannelImage`, `filePickers`,
`useAttachmentPickerBottomSheet` and the context error messages.
- `yarn lint`, `yarn typecheck` (all workspaces), `yarn test:unit` and
`yarn build` pass.

## β˜‘οΈ Checklist

- [ ] I have signed the [Stream
CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform)
(required)
- [ ] PR targets the `develop` branch (stacked on #3884, then `V10`)
- [x] Documentation is updated
- [ ] New code is tested in main example apps, including all possible
scenarios
  - [ ] SampleApp iOS and Android
  - [ ] Expo iOS and Android

---------

Co-authored-by: Ivan Sekovanikj <ivan.sekovanikj@getstream.io>
@github-actions github-actions Bot mentioned this pull request Nov 6, 2026
6 tasks
@stream-ci-bot

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in version 10.0.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

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.

4 participants