Skip to content

osc9283 and term bg#1959

Merged
sawka merged 5 commits intomainfrom
sawka/osc9283-and-bg
Feb 14, 2025
Merged

osc9283 and term bg#1959
sawka merged 5 commits intomainfrom
sawka/osc9283-and-bg

Conversation

@sawka
Copy link
Member

@sawka sawka commented Feb 14, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2025

Warning

Rate limit exceeded

@sawka has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 44 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 9150a7f and 142350b.

📒 Files selected for processing (2)
  • frontend/app/block/blockframe.tsx (2 hunks)
  • frontend/app/view/term/termwrap.ts (2 hunks)

Walkthrough

The pull request modifies background handling and OSC command functionality across both command-line and frontend components. In the command-line interface, the background-setting logic has been updated to use a flag for clearing backgrounds and a new identifier for managing opacity changes. On the frontend side, the previous multi-step URL processing for background styles has been streamlined by removing functions such as processBackgroundUrls and encodeFileURL, and consolidating the logic into a single function called computeBgStyleFromMeta. This function is now imported and used in multiple components to compute background styles from metadata. Additionally, two OSC command handler functions, handleOscWaveCommand and handleOsc7Command, have been introduced to process specific OSC messages related to wave commands and directory updates. Utility enhancements in the waveutil.ts file now support these changes by providing centralized background URL processing and style computation.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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: 0

🧹 Nitpick comments (4)
frontend/util/waveutil.ts (1)

13-68: Consider additional handling for tilde paths and log redaction
This function thoroughly checks for unsafe URLs. However, note that "~" might also indicate a user's home directory, which isn't expanded here. Also consider redacting or removing potentially sensitive file paths from console logs to avoid unintended data exposure.

cmd/wsh/cmd/wshcmd-setbg.go (1)

93-95: Avoid duplicating meta["bg:*"] assignment
Currently, meta["bg:*"] is also assigned around line 103. Consider consolidating this logic to reduce duplication.

frontend/app/view/term/termwrap.ts (2)

47-99: Enhance error handling for better debugging.

The error handling could be improved to provide more context about the failure points.

Apply this diff to enhance error handling:

 function handleOscWaveCommand(data: string, blockId: string, loaded: boolean): boolean {
     if (!loaded) return false;
-    if (!data || data.length === 0) return false;
+    if (!data || data.length === 0) {
+        console.warn("OSC 9283: Empty data received");
+        return false;
+    }

     // Expected formats:
     // "setmeta;{JSONDATA}"
     // "setmeta;[wave-id];{JSONDATA}"
     const parts = data.split(";");
-    if (parts[0] !== "setmeta") return false;
+    if (parts[0] !== "setmeta") {
+        console.warn("OSC 9283: Invalid command format, expected 'setmeta'");
+        return false;
+    }

     let jsonPayload: string;
     let waveId: string | undefined;
     if (parts.length === 2) {
         jsonPayload = parts[1];
     } else if (parts.length >= 3) {
         waveId = parts[1];
         jsonPayload = parts.slice(2).join(";");
     } else {
+        console.warn("OSC 9283: Invalid number of parts in command");
         return false;
     }

     let meta: any;
     try {
         meta = JSON.parse(jsonPayload);
     } catch (e) {
-        console.error("Invalid JSON in OSC command:", e);
+        console.error("OSC 9283: Invalid JSON payload:", e, "Raw payload:", jsonPayload);
         return false;
     }

101-124: Improve path handling and error reporting.

The path handling could be more robust, and error handling could be enhanced for better debugging.

Apply this diff to improve path handling and error reporting:

 function handleOsc7Command(data: string, blockId: string, loaded: boolean): boolean {
     if (!loaded) {
+        console.debug("OSC 7: Command ignored, not loaded");
         return false;
     }
     if (data == null || data.length == 0) {
+        console.warn("OSC 7: Empty path received");
         return false;
     }
+    let path = data;
     if (data.startsWith("file://")) {
-        data = data.substring(7);
-        const nextSlashIdx = data.indexOf("/");
+        path = data.substring(7);
+        const nextSlashIdx = path.indexOf("/");
         if (nextSlashIdx == -1) {
+            console.warn("OSC 7: Invalid file:// URL format, missing path component");
             return false;
         }
-        data = data.substring(nextSlashIdx);
+        path = path.substring(nextSlashIdx);
     }
+    // Normalize path separators
+    path = path.replace(/\\/g, "/");
     setTimeout(() => {
         fireAndForget(() =>
             services.ObjectService.UpdateObjectMeta(WOS.makeORef("block", blockId), {
-                "cmd:cwd": data,
+                "cmd:cwd": path,
             })
         );
     }, 0);
     return true;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66249a0 and 9150a7f.

📒 Files selected for processing (6)
  • cmd/wsh/cmd/wshcmd-setbg.go (2 hunks)
  • frontend/app/app-bg.tsx (1 hunks)
  • frontend/app/block/blockframe.tsx (2 hunks)
  • frontend/app/view/term/term.tsx (2 hunks)
  • frontend/app/view/term/termwrap.ts (2 hunks)
  • frontend/util/waveutil.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Build for TestDriver.ai
🔇 Additional comments (9)
frontend/util/waveutil.ts (3)

2-2: Potential license identifier mismatch
It looks like there's an "s" appended to "Apache-2.0" on line 2. Please verify if "Apache-2.0s" is intentional or if it's a typographical error.


8-11: Function looks good
The encodeFileURL function is straightforward and appears correct.


70-88: Logic for computeBgStyleFromMeta is clear
No issues found in this function.

frontend/app/app-bg.tsx (2)

4-4: No concerns


16-16: Confirm default opacity
Are you sure you want 50% as the default background opacity for new tabs?

cmd/wsh/cmd/wshcmd-setbg.go (1)

172-175: Logic for resolving blockArg is correct
No issues found here.

frontend/app/view/term/termwrap.ts (1)

195-201: LGTM!

The OSC handler registration is correctly implemented, with proper parameter passing and function binding.

frontend/app/block/blockframe.tsx (1)

27-27: LGTM!

The changes improve code reusability by utilizing the shared computeBgStyleFromMeta utility function for background style computation.

Also applies to: 579-582

frontend/app/view/term/term.tsx (1)

30-30: LGTM!

The changes correctly implement background styling for the terminal view:

  • Reuses the shared computeBgStyleFromMeta utility function.
  • Properly positions the background div with correct z-index.
  • Prevents interference with pointer events.

Also applies to: 1074-1078

@sawka sawka merged commit c53c3d0 into main Feb 14, 2025
6 of 7 checks passed
@sawka sawka deleted the sawka/osc9283-and-bg branch February 14, 2025 21:31
xxyy2024 pushed a commit to xxyy2024/waveterm_aipy that referenced this pull request Jun 24, 2025
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