Skip to content

Make ircs:// links work#62

Merged
ValwareIRC merged 10 commits into
mainfrom
fix-linting-errors
Sep 28, 2025
Merged

Make ircs:// links work#62
ValwareIRC merged 10 commits into
mainfrom
fix-linting-errors

Conversation

@ValwareIRC
Copy link
Copy Markdown
Contributor

@ValwareIRC ValwareIRC commented Sep 28, 2025

This PR fixes persistent linting parse errors in ChatArea.tsx, adds comprehensive IRC link handling functionality, and updates the biome configuration:

Linting Fixes:

  • Removing problematic IRC link handling code that was causing parse errors
  • Fixing syntax issues in MessageItem component by properly structuring conditional returns for system messages, action messages, and regular messages
  • Adding missing imports (useEffect, useRef, useState, ircColors, uuidv4, platform, custom hooks)
  • Reorganizing imports for better consistency
  • Minor formatting fixes

IRC Link Handling:

  • Parse IRC URLs with robust handling of channels in pathname (/chan1,chan2) or hash (#chan1,chan2)
  • Extract nick and password from URL query parameters (?nick=user&password=pass)
  • Clean trailing punctuation from URLs in chat text (handles common chat formatting)
  • Open the 'Connect to server' modal with pre-filled server details instead of auto-connecting
  • Users can review and confirm connection details before connecting
  • Provides the same user experience as clicking IRC servers in the discover tab

Biome Configuration Updates:

  • Update @biomejs/biome from 2.2.0 to 2.2.4 to match CI version
  • Update biome.json schema version to 2.2.4
  • Run biome migrate to fix configuration format
  • Format all files according to current biome rules

The codebase now passes all lint checks and provides comprehensive IRC URL support that handles real-world IRC link formats and provides a safe, user-controlled connection experience.

- Remove problematic IRC link handling code that was causing parse errors
- Fix syntax issues in MessageItem component by properly structuring conditional returns
- Add missing imports (useEffect, useRef, useState, ircColors, uuidv4, platform, hooks)
- Reorganize imports for better consistency
- Clean up import organization
- Fix EnhancedLinkWrapper component formatting
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 28, 2025

Warning

Rate limit exceeded

@ValwareIRC has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 10 seconds before requesting another review.

⌛ 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.

📥 Commits

Reviewing files that changed from the base of the PR and between f126034 and a0893f4.

📒 Files selected for processing (1)
  • src/components/layout/ChatArea.tsx (7 hunks)

Walkthrough

EnhancedLinkWrapper and MessageItem signatures were extended to accept an optional onIrcLinkClick callback; link clicks for irc:// and ircs:// are intercepted and routed via that callback. ChatArea implements handleIrcLinkClick which parses IRC URLs and dispatches store actions (connect/joinChannel). Dev tooling versions (biome/@biomejs) were bumped.

Changes

Cohort / File(s) Summary of Changes
Chat-area components (single file edits)
src/components/layout/ChatArea.tsx
Added onIrcLinkClick?: (url: string) => void to EnhancedLinkWrapper and MessageItem component signatures; wired an onClick handler to intercept irc:// and ircs:// links and call the callback; updated MessageItem render paths to pass the callback through for message content, replies, and system content.
ChatArea handler + store integration
src/components/layout/ChatArea.tsx
Added handleIrcLinkClick in ChatArea: parses irc:///ircs:// URLs, calls store actions connect and joinChannel, and logs errors on failure; passes handler down as onIrcLinkClick.
Tooling config
biome.json, package.json
Bumped Biome schema and devDependency @biomejs/biome from 2.2.0 → 2.2.4; no behavioral code changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant ELW as EnhancedLinkWrapper
  participant Msg as MessageItem
  participant Chat as ChatArea
  participant Store

  User->>ELW: Click irc:// or ircs:// link
  ELW->>ELW: detect scheme, preventDefault()
  ELW->>Msg: call onIrcLinkClick(url)
  Msg->>Chat: forward onIrcLinkClick(url)
  Chat->>Store: connect(parsedServer)
  Chat->>Store: joinChannel(parsedChannel)
  Note right of Store: log errors if actions fail
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • adding link rendering component #56 — Prior edits to EnhancedLinkWrapper/MessageItem and initial IRC/IRCS detection; this PR extends that work with callback wiring and store integration.

Suggested reviewers

  • matheusfillipe

Poem

A rabbit nudges links with care,
irc:// whispers in the air.
I stop the hop, I call the guide,
connect and join — no page to glide.
Hops and channels, carrot pride 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Make ircs:// links work” concisely and accurately summarizes the primary change of the pull request, which is to enable support for irc:// and ircs:// URL handling in the client. It is brief, clear, and directly reflects the main feature implemented without extraneous details or vague language.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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.

@ValwareIRC ValwareIRC changed the title Fix linting errors in ChatArea.tsx Make ircs:// links work Sep 28, 2025
@github-actions
Copy link
Copy Markdown

Pages Preview
Preview URL: https://fix-linting-errors.obsidianirc.pages.dev

Automated deployment preview for the PR in the Cloudflare Pages.

- Implement handleIrcLinkClick function to connect to IRC servers from irc:// and ircs:// links
- Update MessageItem component to accept onIrcLinkClick prop
- Pass handleIrcLinkClick to all EnhancedLinkWrapper components in MessageItem
- Fix parseInt radix warning in linting
- Update biome.json schema version to 2.2.4
- Run biome migrate to fix configuration format
- Format all files according to current biome rules
- Change IRC link clicks to open the 'Connect to server' modal with pre-filled server details
- Remove automatic connection logic
- Add toggleAddServerModal to useStore destructuring
- Parse IRC URL and populate modal with host, port, and current username
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/layout/ChatArea.tsx (1)

122-131: Anchor handler: use currentTarget.href and stop propagation

Avoid relying on closure index and ensure parent handlers don’t double-handle clicks.

Apply:

-              onClick={(e) => {
-                if (
-                  (matches[index].startsWith("ircs://") ||
-                    matches[index].startsWith("irc://")) &&
-                  onIrcLinkClick
-                ) {
-                  e.preventDefault();
-                  onIrcLinkClick(matches[index]);
-                }
-              }}
+              onClick={(e) => {
+                const href = (e.currentTarget as HTMLAnchorElement).href;
+                if (
+                  (href.startsWith("ircs://") || href.startsWith("irc://")) &&
+                  onIrcLinkClick
+                ) {
+                  e.preventDefault();
+                  e.stopPropagation();
+                  onIrcLinkClick(href);
+                }
+              }}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8a3c09 and fd420cf.

📒 Files selected for processing (1)
  • src/components/layout/ChatArea.tsx (7 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/layout/ChatArea.tsx (2)
src/lib/ircUtils.tsx (1)
  • mircToHtml (167-279)
src/lib/ircClient.ts (2)
  • connect (79-144)
  • joinChannel (165-189)
🔇 Additional comments (8)
src/components/layout/ChatArea.tsx (8)

95-99: Prop plumbing looks good

Introducing onIrcLinkClick here is clean and optional; no concerns.


184-192: MessageItem prop addition is consistent

Optional onIrcLinkClick threaded correctly through props.


220-223: System message wrapping LGTM

Wrapping system content with EnhancedLinkWrapper enables IRC link handling uniformly.


360-363: Reply preview link handling LGTM

Passing onIrcLinkClick through keeps behavior consistent in reply blocks.


365-367: Primary message link handling LGTM

Main message content is wrapped correctly.


432-434: Store methods are correctly selected

connect/joinChannel exposure from the store reads well.


1158-1159: Wiring onIrcLinkClick to MessageItem LGTM

Propagation looks correct.


439-468: Ensure channel joins occur only after IRC registration completes
I didn’t find any handlers for 001/RPL_WELCOME or an onRegistered event—please verify that joinChannel(server.id, channel) is invoked only after the registration event (e.g., post-001 or your store’s “registered” event) to avoid “451 You have not registered” errors.

Comment thread src/components/layout/ChatArea.tsx Outdated
- Parse IRC URLs with proper handling of channels in pathname or hash
- Extract nick and password from URL query parameters
- Reuse existing server connections to avoid duplicates
- Clean trailing punctuation from URLs in chat text
- Connect directly instead of opening modal for better UX
- Fix linting issues with void return in forEach callback
- Update @biomejs/biome from 2.2.0 to 2.2.4 in package.json
- Update biome.json schema version to 2.2.4
- Run biome migrate to update configuration
- Format all files to match CI expectations
- Remove automatic connection logic from IRC link clicks
- Open the 'Connect to server' modal with pre-filled server details
- Add toggleAddServerModal back to useStore destructuring
- Make handleIrcLinkClick synchronous since no async operations
- Fix default ports (6697 for ircs, 6667 for irc)
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd420cf and f126034.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • biome.json (1 hunks)
  • package.json (1 hunks)
  • src/components/layout/ChatArea.tsx (7 hunks)
✅ Files skipped from review due to trivial changes (2)
  • biome.json
  • package.json
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/layout/ChatArea.tsx (3)
src/lib/ircUtils.tsx (1)
  • mircToHtml (167-279)
src/hooks/useTabCompletion.ts (1)
  • useTabCompletion (31-154)
src/lib/ircClient.ts (2)
  • connect (79-144)
  • joinChannel (165-189)
🔇 Additional comments (1)
src/components/layout/ChatArea.tsx (1)

478-479: Don’t pass false into the password slot

ircClient.connect is defined as connect(host, port, nickname, password?, _saslAccountName?, _saslPassword?) (see src/lib/ircClient.ts). Supplying false as the fourth argument makes the client skip the PASS command, and the real password lands in the SASL placeholder, so auth-protected links can’t succeed. Call connect with the parsed password directly (and only supply SASL args if you have them).

-      const server =
-        existing ?? (await connect(host, port, nick, false, password, "", ""));
+      const server =
+        existing ?? (await connect(host, port, nick, password));

Comment thread src/components/layout/ChatArea.tsx
Copy link
Copy Markdown
Contributor

@matheusfillipe matheusfillipe left a comment

Choose a reason for hiding this comment

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

In general not super happy that we are handling irc/ircs and assuming it would be ws and wss respectively. Mixed feelings about that but since idk the native TCP will even work fine to merge.

const urlObj = new URL(sanitized);
const host = urlObj.hostname;
const scheme = urlObj.protocol.replace(":", "");
const port = urlObj.port
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.

How do we distinct TCP from websocket... when it is stupported if it is ever supported. Technically we are connecting to ws://irc.something.com or wss://irc.something.com, because the default irc ports would be 6667 and 6697. If we say the native clients should support these urls they probably should use the TCP ones when that is supported, as most urls like this would have a TCP one but not necessarily websocket. Uff not sure what to do here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think when we support TCP we can change the default to be 6697, but for now this is fine as a default, and usually the port would be specified in the URL anyway so we could go by that when specified

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.

But the web version will never support TCP, is only the native, and if native URL handling is different from web is weird. We could have a bouncer but still the web version should run without a bouncer...

Comment on lines +440 to +470
const handleIrcLinkClick = (rawUrl: string) => {
// Tolerate trailing punctuation in chat text
const sanitized = rawUrl.trim().replace(/[),.;:]+$/, "");
const urlObj = new URL(sanitized);
const host = urlObj.hostname;
const scheme = urlObj.protocol.replace(":", "");
const port = urlObj.port
? Number.parseInt(urlObj.port, 10)
: scheme === "ircs"
? 443
: 8000;

// Channels may be in pathname (/chan1,chan2) or in hash (#chan1,chan2)
const rawChannelStr =
urlObj.pathname.length > 1
? urlObj.pathname.slice(1)
: urlObj.hash.startsWith("#")
? urlObj.hash.slice(1)
: "";
const channels = rawChannelStr
.split(",")
.filter(Boolean)
.map((c) => decodeURIComponent(c))
.map((c) =>
c.startsWith("#") ||
c.startsWith("&") ||
c.startsWith("+") ||
c.startsWith("!")
? c
: `#${c}`,
);
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.

This adds a lot of business logic for the url parser that should be not part of the ChatArea.tsx, this could be a separated thing that can be tested independently with a few test cases. Specially for cases that are easy and testable like this it is easy to add unit tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. Later!

@ValwareIRC ValwareIRC merged commit ad0f69a into main Sep 28, 2025
4 checks passed
zocram4cc pushed a commit to zocram4cc/ObsidianIRC that referenced this pull request Feb 17, 2026
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