Skip to content

Support URL-encoded JSON state, accept file input, rename browseopen, and show help when no args#1

Merged
manabeai merged 1 commit into
masterfrom
codex/update-command-prefix-and-error-handling
Apr 30, 2026
Merged

Support URL-encoded JSON state, accept file input, rename browseopen, and show help when no args#1
manabeai merged 1 commit into
masterfrom
codex/update-command-prefix-and-error-handling

Conversation

@manabeai
Copy link
Copy Markdown
Owner

Motivation

  • Simplify and standardize input handling by dropping compressed v2./base64/gzip decoding and only supporting URL-encoded JSON state values.
  • Improve CLI UX so running rt with no arguments shows help rather than error, and rename the browse subcommand to a clearer open action.
  • Allow users to pass a file path containing the link/state value to the CLI for convenience.

Description

  • Replace v2./base64/gzip decoding with URL-decoded JSON handling in src/link_state.rs so state is treated as URL-encoded JSON only and decode_state just returns the URL-decoded string.
  • Add arg_required_else_help = true to the clap Cli definition and rename the Browse subcommand to Open in src/main.rs to make rt show help when invoked without arguments and to use rt open to open the editor URL.
  • Add resolve_input helper in src/lib.rs to detect when the link_or_state argument is a file path and read its (trimmed) contents, and introduce a ReadInputFile error variant for read failures.
  • Update tests in tests/cli.rs to reflect URL-encoded JSON inputs and add input_file_is_accepted to verify file-path input handling.
  • Update README.md examples to show URL-encoded JSON, the open subcommand, and file input usage.

Testing

  • Ran cargo test (unit and integration tests) after changes and all tests passed successfully.
  • Ran cargo build --release which completed successfully.
  • Updated and ran CLI integration tests in tests/cli.rs, including the new input_file_is_accepted test, which passed.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 011eae0e84

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/link_state.rs
}

let decoded =
urlencoding::decode(state).map_err(|err| LinkStateError::UrlDecode(err.to_string()))?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Decode URL state exactly once

When the input is a full URL, extract_state already returns a decoded query value via url.query_pairs(), but decode_state unconditionally applies urlencoding::decode again. This double-decoding breaks valid states that contain literal percent sequences: for example %25 in JSON becomes % after query parsing and then either errors (invalid URL encoding) or is transformed again (e.g. %2F -> /). As a result, some valid share links fail only in URL form while the same state string works directly.

Useful? React with 👍 / 👎.

@manabeai manabeai merged commit 8d2c695 into master Apr 30, 2026
6 checks passed
@manabeai manabeai deleted the codex/update-command-prefix-and-error-handling branch April 30, 2026 03:46
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.

1 participant