Skip to content

feat: labeled-response (optimistic outgoing messages)#183

Merged
ValwareIRC merged 4 commits into
mainfrom
feat/labeled-response
May 11, 2026
Merged

feat: labeled-response (optimistic outgoing messages)#183
ValwareIRC merged 4 commits into
mainfrom
feat/labeled-response

Conversation

@ValwareIRC
Copy link
Copy Markdown
Contributor

Implements the IRCv3 labeled-response capability so we can show a sent message immediately in its destination buffer with a "pending" indicator, then let the server's echo authoritatively replace it with the real msgid / content / nick once it arrives. Mostly visible on slow connections, where the placeholder gives instant feedback without losing the safety net of waiting for the server to confirm.

Wire-protocol bits:

  • labeled-response added to ourCaps so the cap is auto-requested when the server advertises it (depends on batch, also in caps).
  • lib/labeledResponse.ts: makeLabel() + withLabel(prefix, label), returning a tag-prefix string that composes cleanly with the existing +reply= / +draft/reply= prefix path.
  • useMessageSending sends @<existing-tags>;label=<id> PRIVMSG ... when both labeled-response and echo-message are negotiated. Without echo-message there's no echo to acknowledge the placeholder so we keep the legacy code path; whispers also keep their existing flow because they don't have a 1:1 echo match.

State:

  • Message gains optional pendingLabel and status ("pending" | "failed"); regular received messages have neither field, so nothing changes for them.
  • Two new store actions: confirmPendingMessage(serverId, bufferId, label, updates) replaces the placeholder in place when the echo arrives, returning false on miss so callers can fall back to addMessage; failPendingMessage flips the status when the PENDING_TIMEOUT_MS (30s) timer fires.
  • CHANMSG, USERMSG (regular and multiline own-echo branches) now consult confirmPendingMessage before falling through to addMessage when mtags.label is present and the sender is the current user. msgid is recorded in processedMessageIds so any duplicate-echo guards keep working.

UI:

  • MessageItem applies opacity-60 + italic for status === "pending" and opacity-60 + line-through + red text for "failed". The rest of the row layout is unchanged so the placeholder simply "settles" into place when the echo lands.

Tests:

  • ChatArea test mock now stubs hasCapability(); useMessageSending calls it to gate the label path.

Implements the IRCv3 labeled-response capability so we can show a
sent message immediately in its destination buffer with a "pending"
indicator, then let the server's echo authoritatively replace it
with the real msgid / content / nick once it arrives.  Mostly visible
on slow connections, where the placeholder gives instant feedback
without losing the safety net of waiting for the server to confirm.

Wire-protocol bits:

  - labeled-response added to ourCaps so the cap is auto-requested
    when the server advertises it (depends on `batch`, also in caps).
  - lib/labeledResponse.ts: makeLabel() + withLabel(prefix, label),
    returning a tag-prefix string that composes cleanly with the
    existing `+reply=` / `+draft/reply=` prefix path.
  - useMessageSending sends `@<existing-tags>;label=<id> PRIVMSG ...`
    when both `labeled-response` and `echo-message` are negotiated.
    Without echo-message there's no echo to acknowledge the placeholder
    so we keep the legacy code path; whispers also keep their existing
    flow because they don't have a 1:1 echo match.

State:

  - Message gains optional `pendingLabel` and `status` ("pending" |
    "failed"); regular received messages have neither field, so
    nothing changes for them.
  - Two new store actions: confirmPendingMessage(serverId, bufferId,
    label, updates) replaces the placeholder in place when the echo
    arrives, returning false on miss so callers can fall back to
    addMessage; failPendingMessage flips the status when the
    PENDING_TIMEOUT_MS (30s) timer fires.
  - CHANMSG, USERMSG (regular and multiline own-echo branches) now
    consult confirmPendingMessage before falling through to
    addMessage when mtags.label is present and the sender is the
    current user.  msgid is recorded in processedMessageIds so any
    duplicate-echo guards keep working.

UI:

  - MessageItem applies opacity-60 + italic for status === "pending"
    and opacity-60 + line-through + red text for "failed".  The
    rest of the row layout is unchanged so the placeholder simply
    "settles" into place when the echo lands.

Tests:

  - ChatArea test mock now stubs hasCapability(); useMessageSending
    calls it to gate the label path.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 3, 2026

Warning

Rate limit exceeded

@ValwareIRC has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6f53630d-f524-435b-9be7-e98f1d1e4d2f

📥 Commits

Reviewing files that changed from the base of the PR and between a99ef91 and 3244851.

📒 Files selected for processing (8)
  • src/components/message/MessageItem.tsx
  • src/hooks/useMessageSending.ts
  • src/lib/irc/IRCClient.ts
  • src/lib/labeledResponse.ts
  • src/store/handlers/messages.ts
  • src/store/index.ts
  • src/types/index.ts
  • tests/components/ChatArea.test.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/labeled-response

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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

Pages Preview
Preview URL: https://feat-labeled-response.obsidianirc.pages.dev

Automated deployment preview for the PR in the Cloudflare Pages.

Comment thread src/types/index.ts
Comment on lines +171 to +180
// labeled-response: when the user sends a message with the
// labeled-response cap acked, we insert a local placeholder
// immediately and wait for the server's echo to match it back.
// `pendingLabel` is the label tag value we attached on send, set
// only on the local placeholder until the echo arrives.
pendingLabel?: string;
// labeled-response: lifecycle state of an outgoing message.
// - "pending": placeholder awaiting server echo
// - "failed": no echo / FAIL arrived in the timeout window
// undefined => normal received message (no pending lifecycle).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many comments jesus

matheusfillipe
matheusfillipe previously approved these changes May 4, 2026
@ValwareIRC ValwareIRC merged commit f38029a into main May 11, 2026
4 checks passed
@ValwareIRC ValwareIRC deleted the feat/labeled-response branch May 11, 2026 20:34
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.

2 participants