Skip to content

feat: add snippets to github files#2

Open
ntindle wants to merge 47 commits intomainfrom
snippets-impl
Open

feat: add snippets to github files#2
ntindle wants to merge 47 commits intomainfrom
snippets-impl

Conversation

@ntindle
Copy link
Copy Markdown
Member

@ntindle ntindle commented May 28, 2025

Co-Authored-By: Claude 81847+claude@users.noreply.github.com

Co-Authored-By: Claude <81847+claude@users.noreply.github.com>
@qodo-code-review
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Error Handling

The getGithubSnippetContent function returns undefined when the URL is invalid, but throws errors for other cases. This inconsistency could lead to unexpected behavior in the component that uses this function.

export const getGithubSnippetContent = async (url: string, snippetTag: string, context: GithubRuntimeContext) => {
    const urlObject = splitGithubUrl(url);
    if (!urlObject) {
        return;
    }
Potential Bug

The extractSnippetSection function trims each line when checking for markers, but returns the untrimmed lines. This could lead to inconsistent whitespace handling if markers are indented in the source file.

const extractSnippetSection = (content: string, snippetTag: string) => {
    const lines = content.split('\n');
    const startMarker = `--8<-- [start:${snippetTag}]`;
    const endMarker = `--8<-- [end:${snippetTag}]`;

    let startIndex = -1;
    let endIndex = -1;

    for (let i = 0; i < lines.length; i++) {
        const line = lines[i].trim();
        if (line.includes(startMarker)) {
            startIndex = i + 1; // Start from the line after the marker
        } else if (line.includes(endMarker) && startIndex !== -1) {
            endIndex = i; // End at the line before the marker
            break;
        }
    }

    if (startIndex === -1 || endIndex === -1) {
        return null; // Snippet tag not found
    }

    return lines.slice(startIndex, endIndex).join('\n');
};
Missing Validation

The snippetBlock component allows submitting with an empty snippetTag, but later requires it for fetching content. This could lead to confusing error messages for users.

if (!url || !snippetTag) {
    return (
        <block>
            <input
                label="GitHub URL"
                element={<textinput placeholder="https://github.com/owner/repo/blob/main/file.js" />}
                onValueChange={{
                    action: 'updateUrl',
                    url: { bind: 'value' },
                }}
                value={url}
            />
            <input
                label="Snippet Tag"
                element={<textinput placeholder="BaseOAuthExample" />}
                onValueChange={{
                    action: 'updateSnippetTag',
                    snippetTag: { bind: 'value' },
                }}
                value={snippetTag}
            />
        </block>
    );
}

ntindle and others added 27 commits May 28, 2025 13:43
Co-Authored-By: Claude <81847+claude@users.noreply.github.com>
* Add support for multiple environments

* Changeset

* Fix
* Add support for referencing secrets from 1Password

* Format
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-Authored-By: Claude <81847+claude@users.noreply.github.com>
Co-Authored-By: Claude <81847+claude@users.noreply.github.com>
Co-Authored-By: Claude <81847+claude@users.noreply.github.com>
Co-Authored-By: Claude <81847+claude@users.noreply.github.com>
Co-Authored-By: Claude <81847+claude@users.noreply.github.com>
* Start

* Auth and configuration

* Implement auth

* Create or update webhook

* Start ingestion of tickets

* Dont push empty conversations

* Set url for conversations

* Handle webhooks

* Migrate to latest version of CF runtime

* Start intercom

* Cleanup

* Format

* Fix TS error

* Format

* Fix check command

* Improve check to use test env

* Fix check not running in env

* Publish as v2

* Fix webhook and team listing

* Fix request

* Format

* Add config for staging

* Update configs

* Install op

* Auth 1password

* Update descriptions

* Test it with credentials

* Try running signin

* Try again

* Fix env
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* withLaunchDarkly

* changeset

* refactor
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* WIP: Bucket integration

* scripts

* bun lock

* format

* WIP

* target: site

* use unsigned instead of public

* use unsigned instead of public

* bun lock

* fix lock

* undo vscode settings change

* update bun lock

* Use component for Bucket integration configuration flow (GitbookIO#837)

Use component for Bucket configuration flow

* Use renamed adaptive schema endpoint (GitbookIO#841)

* fix bun lock

* bun lock

* update package lock

* assets

* changeset

---------

Co-authored-by: spastorelli <spastorelli@users.noreply.github.com>
* WIP: Bucket integration

* scripts

* bun lock

* format

* WIP

* target: site

* use unsigned instead of public

* use unsigned instead of public

* bun lock

* fix lock

* undo vscode settings change

* update bun lock

* WIP

* WIP

* WIP: LD

* bun lock

* bun.lock

* assets

* changeset

* fix package versions

* fix api call
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
taranvohra and others added 19 commits June 11, 2025 12:05
…okIO#852)

* Add initial state when adaptive content is not enabled

* skip if not enabled

* changeset
* Use installation api token while fetching site during render

* changeset
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…missing project key input (GitbookIO#860)

* Fix LaunchDarkly config missing project key input

* Fix LD API call Authorization header

* Add changeset
* Use box/vstack layout for bucket config too

* Add changeset
* Add Unify analytics integration for GitBook sites

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add bun.lock

* Fix Unify integration domain from unify.ai to unifygtm.com

The `unify` integration is using a content-src of `unify.ai`. The correct domain is `unifygtm.com` and more specifically `cdn.unifygtm.com`. Fix this, then add it to a git commit and push.

Update content security policy to use the correct Unify domains:
- Change script-src from api.unify.ai/unify.ai to cdn.unifygtm.com/unifygtm.com
- Update img-src and connect-src accordingly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Format + changeset

---------

Co-authored-by: Claude <noreply@anthropic.com>
* Update Unify assets.

* changeset
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants