Live data from Hacker News

Show HN: Superblocks AI – AI coding assistant for internal apps

superblocks.com

51–60 of 66 posts

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#52
post #43

Earlier quoted context omitted.

I feel like I live in an alternate universe to this comment. Every engineer I know (devops, software, hell even datascience) is using GPT-4 or Copilot (especially Copilot with the new chat interface) and people, myself included, use it every day. Refactor this code for me, add a function that does X, why is Y failing, align this code with a different coding pattern, I cobbled together this React app, clean it up and…

Forgive the long reply, but I'm going to go ahead and "press X to doubt," because I have been trying to use both ChatGPT and Copilot, and the results are abysmal apart from anything but "write me a linked list" or "give me some React boilerplate." If you have examples of it working for you, please share them. Here's a very salient example of it not working for me: I spent about 1-2 days figuring this out, so it's def…

I don't write Rust but does this look (more) correct?

    extern crate winapi;

    use std::ptr::null_mut;
     use winapi::shared::guiddef::{CLSID, IID};
    use winapi::um::combaseapi::{CoInitialize, CoCreateInstance};
    use winapi::um::shobjidl_core::CLSID_ShellWindows;
    use winapi::um::winuser::GetForegroundWindow;
    use winapi::Interface;
    use winapi::shared::winerror::{HRESULT, SUCCEEDED};
    use winapi::um::exdisp::IWebBrowser2;
    use winapi::um::unknwnbase::IUnknown;
    use winapi::um::oleidl::IDispatch;
    use winapi::shared::wtypes::BSTR;
    use winapi::um::winnt::LPCWSTR;
    use winapi::shared::ntdef::VOID;
use std::ffi::OsString; use std::os::windows::ffi::OsStringExt;

     // Helper function to convert a wide string to a Rust string
     wide_to_string(wide: &[u16]) -> String {
    OsString::from_wide(&wide)
        .to_string_lossy()
        .into_owned()
}

    // Helper function to convert BSTR to Rust String
    fn bstr_to_string(bstr: BSTR) -> String {
    unsafe {
        let length = winapi::um::oleauto::SysStringLen(bstr) as usize;
        let slice = std::slice::from_raw_parts(bstr, length);
        wide_to_string(slice)
    }
}

   fn main() {
    unsafe {
        // Initialize COM
        let hr = CoInitialize(null_mut());

        if SUCCEEDED(hr) {
            let mut shell_windows_ptr: *mut IUnknown = null_mut();
            let shell_windows_iid: IID = IShellWindows::uuidof();
            let shell_windows_clsid: CLSID = CLSID_ShellWindows;

            // Create IShellWindows instance
            let hr = CoCreateInstance(
                &shell_windows_clsid,
                null_mut(),
                winapi::um::combaseapi::CLSCTX_ALL,
                &shell_windows_iid,
                &mut shell_windows_ptr as *mut _ as _,
            );

            if SUCCEEDED(hr) {
                let shell_windows_dispatch: &IDispatch = &*(shell_windows_ptr as *mut IDispatch);

                let hwnd = GetForegroundWindow() as LPCWSTR;

                // Get Item of IShellWindows
                let mut result = null_mut();
                let mut params = winapi::um::oaidl::DISPPARAMS {
                    cArgs: 1,
                    cNamedArgs: 0,
                    rgvarg: &mut winapi::um::oaidl::VARIANTARG {
                        n1: winapi::um::oaidl::VARIANTARG_0 {
                            n2: winapi::um::oaidl::VARIANTARG_0_0 {
                                vt: winapi::um::oaidl::VT_I4 as u16,
                                wReserved1: 0,
                                wReserved2: 0,
                                wReserved3: 0,
                                n3: winapi::um::oaidl::VARIANTARG_0_0_0 {
                                    lVal: hwnd as _,
                                }
                            }
                        }
                    },
                    rgdispidNamedArgs: null_mut(),
                };

                shell_windows_dispatch.Invoke(
                    winapi::um::exdisp::DISPID_ISHELLWINDOWS_ITEM,
                    &winapi::shared::guiddef::IID_NULL,
                    winapi::um::winnls::LOCALE_USER_DEFAULT,
                    winapi::um::oaidl::DISPATCH_METHOD,
                    &mut params,
                    &mut result,
                    null_mut(),
                    null_mut(),
                );

                // Convert result to IWebBrowser2
                let web_browser2: &IWebBrowser2 = &*(result.pdispVal as *mut IWebBrowser2);

                // Get LocationURL property of IWebBrowser2
                let mut location_url: BSTR = null_mut();
                web_browser2.get_LocationURL(&mut location_url);

                let path = bstr_to_string(location_url);

                println!("Path: {}", path);
            } else {
                println!("Failed to create IShellWindows instance.");
            }
        } else {
            println!("Failed to initialize COM.");
        }
    }
    extern crate winapi;
use std::ptr::null_mut; use winapi::shared::guiddef::{CLSID, IID}; use winapi::um::combaseapi::{CoInitialize, CoCreateInstance}; use winapi::um::shobjidl_core::CLSID_ShellWindows; use winapi::um::winuser::GetForegroundWindow; use winapi::Interface; use winapi::shared::winerror::{HRESULT, SUCCEEDED}; use winapi::um::exdisp::IWebBrowser2; use winapi::um::unknwnbase::IUnknown; use winapi::um::oleidl::IDispatch; use winapi::shared::wtypes::BSTR; use winapi::um::winnt::LPCWSTR; use winapi::shared::ntdef::VOID; use std::ffi::OsString; use std::os::windows::ffi::OsStringExt;

// Helper function to convert a wide string to a Rust string fn wide_to_string(wide: &[u16]) -> String { OsString::from_wide(&wide) .to_string_lossy() .into_owned() }

// Helper function to convert BSTR to Rust String fn bstr_to_string(bstr: BSTR) -> String { unsafe { let length = winapi::um::oleauto::SysStringLen(bstr) as usize; let slice = std::slice::from_raw_parts(bstr, length); wide_to_string(slice) } }

fn main() { unsafe { // Initialize COM let hr = CoInitialize(null_mut());

        if SUCCEEDED(hr) {
            let mut shell_windows_ptr: *mut IUnknown = null_mut();
            let shell_windows_iid: IID = IShellWindows::uuidof();
            let shell_windows_clsid: CLSID = CLSID_ShellWindows;

            // Create IShellWindows instance
            let hr = CoCreateInstance(
                &shell_windows_clsid,
                null_mut(),
                winapi::um::combaseapi::CLSCTX_ALL,
                &shell_windows_iid,
                &mut shell_windows_ptr as *mut _ as _,
            );

            if SUCCEEDED(hr) {
                let shell_windows_dispatch: &IDispatch = &*(shell_windows_ptr as *mut IDispatch);

                let hwnd = GetForegroundWindow() as LPCWSTR;

                // Get Item of IShellWindows
                let mut result = null_mut();
                let mut params = winapi::um::oaidl::DISPPARAMS {
                    cArgs: 1,
                    cNamedArgs: 0,
                    rgvarg: &mut winapi::um::oaidl::VARIANTARG {
                        n1: winapi::um::oaidl::VARIANTARG_0 {
                            n2: winapi::um::oaidl::VARIANTARG_0_0 {
                                vt: winapi::um::oaidl::VT_I4 as u16,
                                wReserved1: 0,
                                wReserved2: 0,
                                wReserved3: 0,
                                n3: winapi::um::oaidl::VARIANTARG_0_0_0 {
                                    lVal: hwnd as _,
                                }
                            }
                        }
                    },
                    rgdispidNamedArgs: null_mut(),
                };

                shell_windows_dispatch.Invoke(
                    winapi::um::exdisp::DISPID_ISHELLWINDOWS_ITEM,
                    &winapi::shared::guiddef::IID_NULL,
                    winapi::um::winnls::LOCALE_USER_DEFAULT,
                    winapi::um::oaidl::DISPATCH_METHOD,
                    &mut params,
                    &mut result,
                    null_mut(),
                    null_mut(),
                );

                // Convert result to IWebBrowser2
                let web_browser2: &IWebBrowser2 = &*(result.pdispVal as *mut IWebBrowser2);

                // Get LocationURL property of IWebBrowser2
                let mut location_url: BSTR = null_mut();
                web_browser2.get_LocationURL(&mut location_url);

                let path = bstr_to_string(location_url);

                println!("Path: {}", path);
            } else {
                println!("Failed to create IShellWindows instance.");
            }
        } else {
            println!("Failed to initialize COM.");
        }
    }
   }
 }

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#53
post #43

Earlier quoted context omitted.

Forgive the long reply, but I'm going to go ahead and "press X to doubt," because I have been trying to use both ChatGPT and Copilot, and the results are abysmal apart from anything but "write me a linked list" or "give me some React boilerplate." If you have examples of it working for you, please share them. Here's a very salient example of it not working for me: I spent about 1-2 days figuring this out, so it's def…

Thanks for including this example. It helps me understand what you mean. ChatGPT is not really equipped to do this level of code design because there are too many steps for it to handle at once. It can handle your instructions if it could first write a detailed design spec, then write code and unit tests, then run them, read the compiler output, and iteratively make changes. IOW, this would require a purpose-built so…

> ChatGPT is not really equipped to do this level of code design because there are too many steps for it to handle at once

There's no code design going on here. My solution was literally just going through like 100 StackOverflow answers & Microsoft's god-awful documentation to get the 50 lines of code that does what I need it to do.

In fact, this is precisely what I'd hope ChatGPT would be good for. Most of my final code is simply copy-pasted from SO/example repos/official docs. He's the correct function (comments added by me so I'll know wtf this is meant to do when I look at it again in 3 months).

    fn get_context_path() -> Result {
        unsafe {
            // Init COM libraries in this thread
            CoInitializeEx(Some(ptr::null()), COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)?;

            // CabinetWClass is the Explorer window class
            let class = s!("CabinetWClass");
            let topmost_explorer = FindWindowA(class, None);
            let foreground_window = GetForegroundWindow();

            // Breadcrumbs IFF topmost window is an explorer window
            if topmost_explorer == foreground_window {
                let windows: IShellWindows = CoCreateInstance(&ShellWindows, None, CLSCTX_LOCAL_SERVER)?;
                let unk_enum = windows._NewEnum()?;
                let enum_variant: IEnumVARIANT = unk_enum.cast::()?;

                // Iterate through all IShellWindows
                loop {
                    let mut fetched = 0;
                    let mut var: [VARIANT; 1] = [VARIANT::default(); 1];
                    let hr = enum_variant.Next(&mut var, &mut fetched);

                    // No more windows?
                    if hr == S_FALSE || fetched == 0 {
                        break;
                    }

                    // Not an IDispatch interface?
                    if var[0].Anonymous.Anonymous.vt != VT_DISPATCH {
                        continue;
                    }

                    // We should be able to turn an IShellWindow into an IShellBrowser
                    let shell_browser: IShellBrowser = IUnknown_QueryService(
                        var[0]
                            .Anonymous
                            .Anonymous
                            .Anonymous
                            .pdispVal
                            .as_ref()
                            .unwrap(),
                        &SID_STopLevelBrowser,
                    )?;
                    let shell_window = shell_browser.GetWindow()?;

                    // NOTE: The window we're matching with is actually the shell's parent
                    // Given that windows can be tabbed, we want to make sure the parent is the top
                    if GetParent(shell_window) == topmost_explorer {
                        let shell_view = shell_browser.QueryActiveShellView()?;

                        // Do some COM finagling, including a QueryInterface cast,
                        // until we get the folder path we're looking at
                        let folder_view: IFolderView = shell_view.cast::()?;
                        let folder: IPersistFolder2 = folder_view.GetFolder::()?;
                        let curr_folder = folder.GetCurFolder()?;

                        // NOTE: This fails on non SYSPATH paths (e.g. "Home" or "Recent")
                        let path = SHGetNameFromIDList(curr_folder, SIGDN_FILESYSPATH)?;
                        let result = path.to_string()?;

                        // To figure out what path we're on (e.g. what tab is active), we try to match the
                        // parent title with the folder
                        // FIXME: Unless using full paths as titles, we can have ambiguities here
                        let mut title: [u16; 512] = [0; 512];
                        let len = GetWindowTextW(topmost_explorer, &mut title);
                        let title = String::from_utf16_lossy(&title[..len as usize]);

                        // We found the proper tab (child)
                        if result.contains(&title) {
                            // Cleanup COM & return path result
                            CoUninitialize();
                            return Ok(result);
                        // Must be another one (or something went wrong)
                        } else {
                            continue;
                        }
                    }
                }
            }
            // Cleanup COM & fallback to blank string
            CoUninitialize();
            return Ok(String::from(""));
        }
    }

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#54
post #46
post #43

Earlier quoted context omitted.

Forgive the long reply, but I'm going to go ahead and "press X to doubt," because I have been trying to use both ChatGPT and Copilot, and the results are abysmal apart from anything but "write me a linked list" or "give me some React boilerplate." If you have examples of it working for you, please share them. Here's a very salient example of it not working for me: I spent about 1-2 days figuring this out, so it's def…

I get a lot of mileage out of GPT, so let me see if I can explain. I wouldn't ask GPT/Copilot to do what you asked. After using them for a while you start to get an intuitive sense of what's easy and what's hard for them to do, and your specific example is indeed too difficult to get GPT to do properly. They have the biggest utility for me for stuff that I would ask a junior programmer to do - like a new grad. The re…

It’s great at simple tedious stuff.

It’s useful for average things and concepts we might be unfamiliar with.

It’s of limited use, if not utterly useless, for most things a senior would have a hard time wrapping their head around.

And where it really shines, is when adapting an answer you’d otherwise look for on Google to your code, context, and constraints.

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#55
post #16

This is neat, but, as with all projects in this vein, I fail to see the real value add. We've had ML-powered code generation for several years now (Copilot released publicly in late 2021), and apart from a cute novelty, there's no real use case I've found. ( Maybe except for generating tests, but when dealing with a novel code base, the models really can't figure out dependency injection, mocks, weird edge cases I'd…

AI code generation is not yet ready for a full-blown apps, but it works well on smaller well-defined functions. For example, Nekton.ai asks the user to split the workflow into smaller steps, and automates it one by one.

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#56
post #27

Wow, a new low code app generator! And it even managed to shoehorn ChatGPT in! How exciting!

A lowcode app generator that "used" appsmith's open source project to build on, gamed hacker news to be on the top page once, has a new low code app generator with shoehorned chatgpt. ZIRP Hustle is real.

The architecture has diverged significantly from the Appsmith project (Apache 2.0 licensed) since forking the frontend canvas and evaluation code more than 2 years ago. Most of Superblocks is built from the ground up to optimize for performance, scalability and extensibility.

In terms of ChatGPT, Superblocks's goal is to develop a simple visual interface for creators to integrate AI into their workflow to build applications quickly. The platform makes it easy to verify, deploy, and monitor your changes, which would be difficult to do with just a chat interface.

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#57
post #43

Earlier quoted context omitted.

I feel like I live in an alternate universe to this comment. Every engineer I know (devops, software, hell even datascience) is using GPT-4 or Copilot (especially Copilot with the new chat interface) and people, myself included, use it every day. Refactor this code for me, add a function that does X, why is Y failing, align this code with a different coding pattern, I cobbled together this React app, clean it up and…

Forgive the long reply, but I'm going to go ahead and "press X to doubt," because I have been trying to use both ChatGPT and Copilot, and the results are abysmal apart from anything but "write me a linked list" or "give me some React boilerplate." If you have examples of it working for you, please share them. Here's a very salient example of it not working for me: I spent about 1-2 days figuring this out, so it's def…

The problem is that you are using it for a "deceptively difficult task" and not "a task I know how to do, or could easily look up, but would prefer not to". Looking at my ChatGPT history, some things I've used it for in the last week (all GPT-4):

* Formatting a huge confusing blob of python code, markdown, and json into something readable.

* Writing "boring" python functions needed to interface with AWS DynamoDB & S3.

* Going from 0 -> 1 on a side project creating printable QR codes that redirect to custom links with logging. (Literally gave me picture perfect step by step instructions here, as if it was reading off the AWS UI. The sole issue I had it helped me troubleshoot).

* JS tutoring.

* Integrating an unfamiliar authentication provider with a web app. It gave me boilerplate code that needed like 1-2 tweaks to work perfectly.

* Long winded architectural discussion giving me ideas on where to take internal libraries.

Other than that, I've actually found that the github copilot CLI is a fantastic tool I've been turning to more and more. There are so many CLI tools that I kinda sorta remember the flags for, and now I no longer have to munge about looking things up. Just earlier I needed some test api key and I just said "!! generate a random api key", and it immediately came back with "openssl rand -base64 32". That works, and saved me time googling it.

Also, your prompt here is pretty weak. For something complex you need to be very specific and give it explicit instructions on how to reason through the problem, explain it's thinking, etc. I find the more context I provide in the prompt, the better it performs. In particular leveraging the system prompt makes a big difference.

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#58

Earlier quoted context omitted.

I feel like I live in an alternate universe to this comment. Every engineer I know (devops, software, hell even datascience) is using GPT-4 or Copilot (especially Copilot with the new chat interface) and people, myself included, use it every day. Refactor this code for me, add a function that does X, why is Y failing, align this code with a different coding pattern, I cobbled together this React app, clean it up and…

It's not better then me. But I use it when I'm lazy, tired or at times drinking. And then it's really nice. At times it costs me too much time solving it's mistakes. But then it nails something perfectly and I'm impressed again.

> It's not better then me.

Where did anyone say it was?

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#59
post #43

Earlier quoted context omitted.

I feel like I live in an alternate universe to this comment. Every engineer I know (devops, software, hell even datascience) is using GPT-4 or Copilot (especially Copilot with the new chat interface) and people, myself included, use it every day. Refactor this code for me, add a function that does X, why is Y failing, align this code with a different coding pattern, I cobbled together this React app, clean it up and…

Forgive the long reply, but I'm going to go ahead and "press X to doubt," because I have been trying to use both ChatGPT and Copilot, and the results are abysmal apart from anything but "write me a linked list" or "give me some React boilerplate." If you have examples of it working for you, please share them. Here's a very salient example of it not working for me: I spent about 1-2 days figuring this out, so it's def…

Skill issue—use it for smaller functions or learn how to write better prompts, lots of resources.

Re: Show HN: Superblocks AI – AI coding assistant for internal apps

#60
post #21

At first was excited when I clicked the link. I think for some people, this is a fantastic solution. However, for me, what I was hoping it was/ one thing I'm still looking for: Feed in my whole repo to the GPT-4 API, train on it, and ask questions about the code base/ particular functions. Has anyone seen that?

My tool aider lets you ask GPT questions about a git repo, as well as letting you ask gpt to edit the code. Here's an example of exploring and then modifying an open source js repo: https://aider.chat/examples/2048-game.html Here's an article about how it does that: https://aider.chat/docs/ctags.html I think bloop is also good for searching and Q&A against code. I'm not sure if it will let you edit/modify the code th…

Your tool looks very impressive. Have you ever tried how well it works with Android app repos?
Post reply on HN