Desktop AI App Debugging: From Developer Mode to Request Verification

    This guide explains how to debug a desktop AI client by recording environment details, enabling developer mode, configuring a local proxy and certificates, adjusting logs, and verifying authentication and streaming requests. It includes practical commands for macOS, Linux, and Windows, along with safety, cleanup, and redaction practices for debugging sessions.

    Debugging a desktop AI application requires a controlled environment, a visible request path, and clear verification steps. The entry point for developer mode can change between client versions, and official documentation or screenshots may be outdated. Record the environment before starting so that later reproductions map to the same setup.

    1. Confirm the Environment and Versions

    Before debugging, record three items: the client version, the operating system and version, and the proxy tool and version. Add these details to the team’s debugging notes so that any issue can be reproduced against the same environment.

    The client’s “About” page usually shows the version number. If the client supports command-line parameters, you can also query the version that way. In this article, Client Settings refers to the location of developer-related options in the client. The exact name depends on the client version; refer to the official documentation for that version.

    Use a template like this:

    1. Client version: <fill in>
    2. Operating system: <fill in>
    3. Proxy tool and version: <for example, output of mitmproxy --version>
    4. Test account: <record account type only; do not record passwords>
    5. Recorded at: <fill in>

    You can check the proxy tool version with mitmproxy --version.

    2. Enable Developer Mode

    1. Sign out of the current account to avoid existing sessions affecting configuration loading. Use a test account or a dedicated test environment. Do not use a personal or production account.
    2. Open Client Settings, find the section related to developer, diagnostics, or advanced options, and enable developer mode.
    3. Fully quit the client process, then start it again so the configuration takes effect.
    4. After restarting, confirm two things: a developer-related panel appears in the interface, and a new file is created in the log directory.

    If the panel does not appear, first check for residual processes. Residual processes can prevent the new configuration from loading. On macOS and Linux, run pgrep -fl <app-name>. On Windows PowerShell, run:

    1. Get-Process | Where-Object {$_.ProcessName -like '*<app-name>*'}

    After confirming the PID of the residual process, terminate it. On macOS and Linux, run kill <PID>. On Windows, run Stop-Process -Id <PID>. Avoid pkill -f <app-name> because it may terminate other programs with the same name, such as another tool or a service from another project. Using the GUI is safer; prefer Task Manager or Activity Monitor.

    If the log directory does not have write permission, log files will be empty. On macOS and Linux, use ls -ld <log-directory> to check the owner and make sure the current user has write permission.

    3. Configure the Proxy, Certificate, and Logs

    3.1 Install and Start the Proxy

    The following example uses the open-source tool mitmproxy. Install it using the method described in the official documentation, such as Homebrew on macOS or pip install mitmproxy. After installation, confirm the executable with mitmproxy --version. Version requirements are defined by the official documentation.

    Start a proxy that listens only on the local machine:

    1. mitmproxy --listen-host 127.0.0.1 --listen-port 8888

    Graphical tools such as Charles and Fiddler work on the same principle. Set the listening address and port to 127.0.0.1 and 8888. For specific operations, refer to the documentation for the tool you use.

    Confirm that the port is listening:

    • macOS or Linux: lsof -iTCP:8888 -sTCP:LISTEN. You should see a line containing LISTEN. If lsof is unavailable, use ss -ltnp | grep 8888.
    • Windows PowerShell: Get-NetTCPConnection -LocalPort 8888 -State Listen. You should see one record. You can also use netstat -ano | findstr :8888; look for a record in LISTENING state.

    Then test local connectivity:

    • macOS or Linux: nc -vz 127.0.0.1 8888. The expected output contains succeeded. If nc is unavailable, use python3 -c "import socket; socket.create_connection(('127.0.0.1', 8888), timeout=3); print('succeeded')".
    • Windows PowerShell: Test-NetConnection 127.0.0.1 -Port 8888. The expected value of TcpTestSucceeded is True.

    If the port is already in use, mitmproxy will fail to start and report an error. Use the listening commands above to find the process using the port. Confirm that it is not a service you need to keep, then handle it accordingly, or switch to another port such as 8889 and update all subsequent configuration. If the connectivity test fails, check whether the local firewall blocks connections to the loopback address.

    3.2 Make the Client Use the Proxy

    In the proxy options under Client Settings, enter http://127.0.0.1:8888. This affects only that client, has the smallest scope, and should be preferred.

    If the client has no graphical option, try specifying the proxy through environment variables:

    • macOS or Linux: export HTTPS_PROXY=http://127.0.0.1:8888
    • Windows PowerShell: $env:HTTPS_PROXY="http://127.0.0.1:8888"

    Environment variables apply only to processes started in the same terminal. Applications launched from the graphical interface may not inherit environment variables from the terminal, so verify against actual capture results. The check is simple: trigger a request. If no corresponding record appears in the mitmproxy interface, the client is not using the proxy.

    Setting a system proxy affects all programs on the machine that use the system proxy, which is a much larger scope than a single client. Restore the original settings promptly after use.

    3.3 Trust the Proxy Certificate

    Decrypting HTTPS traffic requires the system or application to trust the proxy’s CA certificate. mitmproxy’s default certificate is located at ~/.mitmproxy/mitmproxy-ca-cert.pem. Importing a certificate causes all programs on the machine that trust it to accept certificates issued by the proxy. This carries higher security risk than ordinary configuration, so follow these rules:

    • Use it only in your own test environment. Do not use it against other people’s services or on daily work devices.
    • Before importing the certificate, confirm that the device does not store important personal or work credentials.
    • After testing, immediately remove the certificate from the system trust store. On macOS, run sudo security remove-trusted-cert -d ~/.mitmproxy/mitmproxy-ca-cert.pem. On Windows, remove the certificate named mitmproxy in the certificate management tool. On Linux, remove it according to the distribution’s certificate management method.

    Some clients use certificate pinning. Even after importing the proxy certificate, traffic cannot be decrypted. In that case, consult the client documentation and confirm the official debugging method. Do not modify the client program, replace its installation files, or use tools that bypass pinning. Doing so may violate the software license and may weaken the client’s security mechanisms.

    3.4 Configure the Bypass List

    A system proxy bypass list usually includes local addresses such as localhost. If the test target is a model service running on the local machine, remove that service’s address from the bypass list; otherwise, traffic will not go through the proxy.

    Adjust only the target service address. Do not remove all of localhost or 127.0.0.1 from the bypass list, or other local service communication will also be proxied. After testing, restore the original bypass list.

    3.5 Adjust the Log Level and Locate Logs

    Set the log level to detailed or verbose in Client Settings. Log locations vary by client. The following are common directory conventions; the actual path depends on the client:

    • macOS: ~/Library/Logs/<app-name>/
    • Windows: %APPDATA%\<app-name>\logs\
    • Linux: ~/.config/<app-name>/logs/

    If you are unsure of the path, look for log files modified within the last ten minutes. On macOS and Linux, run find ~ -name "*.log" -mmin -10 2>/dev/null. This command works with both BSD find on macOS and GNU find on Linux, but searching the entire home directory may be slow. Narrow the starting path to ~/Library/Logs or ~/.config. On Windows PowerShell, run:

    1. Get-ChildItem $env:APPDATA -Recurse -Filter *.log | Sort-Object LastWriteTime -Descending | Select-Object -First 10

    Detailed logs may contain request headers, prompts, and user content. Do not send these files directly to others. Redact them before sharing.

    3.6 Back Up Before Changing Configuration

    Before editing a configuration file directly, back up the original file:

    • macOS or Linux: cp <config-file> <config-file>.bak
    • Windows PowerShell: Copy-Item <config-file> <config-file>.bak

    After editing, validate the JSON format with python3 -m json.tool <config-file> > /dev/null. If the command reports no error, the format is valid. If the client fails to start, restore the backup and check the error messages in the logs.

    4. Verify Requests and Troubleshoot

    4.0 Verification Checklist

    After completing the configuration in the previous sections, check each item in the table below. The commands apply to macOS or Linux; Windows users can use the corresponding PowerShell commands above.

    Check Command or action Expected output Failure判断 Redaction and recovery
    Proxy listening lsof -iTCP:8888 -sTCP:LISTEN A LISTEN record appears No output means the proxy is not running or the port is occupied No recovery needed after checking
    Local connectivity nc -vz 127.0.0.1 8888 Output contains succeeded Connection refused; check the firewall and proxy process None
    Request enters proxy Send a test message in the client At least two records appear in the mitmproxy interface No records; check the client proxy settings or environment variables Clean up capture records afterward
    Authentication request Check the status code of the first request Status code is 200 or the success code defined by the service documentation 401 means invalid or expired credentials; 403 means insufficient permission Hide the Authorization header value when recording
    Inference request Check the status code of the second request Status code is 200 and the response body has content 5xx means a server error; 429 means rate limiting; timeout means a network or service issue Hide prompts and response content
    Streaming end Inspect the end of the streaming response The end marker defined by the service documentation appears No end marker for a long time or the connection is interrupted means the streaming response is incomplete Keep only timestamps and error codes
    Log generation Check the latest file in the log directory A log line containing the current request time appears An empty file means you should check directory write permission Redact before sharing

    4.1 Confirm Whether the Authentication Request Is Normal

    Trigger an operation that requires a model response, such as sending a test message. At least two records should appear in the proxy panel: one authentication request and one inference request. Check each item below:

    • Whether the request method and URL match the service documentation, such as a POST method and the correct path.
    • Whether the Authorization header exists and whether its format is Bearer <token>. A missing header usually means the client did not read the credentials.
    • Whether Content-Type matches the service documentation. A common value is application/json.
    • Whether the request body fields are complete, such as the model name, message list, and streaming switch. If required fields are missing, the server usually returns 400.

    Use the status code to determine the result:

    • 200: The request succeeded.
    • 401: The credentials are invalid, expired, or incorrectly formatted. Sign in again with the test account and confirm that the token has no extra spaces or line breaks.
    • 403: The account does not have permission to access the model or feature.
    • 429: Requests are too frequent. Wait and retry, and check for duplicate requests.
    • 5xx: Server error. Record the request time and error code, then contact the service provider.
    • Timeout: First check whether the network and proxy are working, then determine whether the server response is slow.

    If you need to verify the service endpoint directly with a command, put the token in an environment variable to avoid writing it into command history or scripts:

    1. export API_TOKEN="<test-account token>"
    2. curl -sS -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" "<service-url>"

    After testing, run unset API_TOKEN to clear the environment variable.

    4.2 Determine Whether the Streaming Response Is Complete

    A streaming response returns data in multiple chunks. To determine whether it is complete, check the following three points:

    1. Whether the response header Content-Type is text/event-stream, or whether Transfer-Encoding: chunked is used. This should match the service documentation.
    2. Whether data chunks arrive continuously without long pauses. Each chunk usually starts with data:.
    3. Whether an end marker appears at the end of the response, such as data: [DONE], or a field containing a completion reason, such as finish_reason.

    If the response disconnects midway and no end marker appears, the streaming response is incomplete. Troubleshoot in this order:

    • Check whether the network is stable and whether the proxy has timeout settings.
    • Check whether the client automatically retries after receiving an error, and whether the retry includes the correct credentials.
    • Search the logs for the last record before the disconnect and confirm the error code and time.

    To test a streaming endpoint directly, use the following command. The -N option disables buffering so you can observe data arriving chunk by chunk:

    1. curl -N -sS -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" -d '{"stream": true, "messages": [{"role": "user", "content": "test"}]}' "<service-url>"

    The field names in the request body depend on the service documentation. The output is only for checking the format. Do not copy the full response to public places.

    If the client supports reconnection, confirm whether it resumes from the breakpoint after reconnecting or sends a complete request again. Duplicate requests may occur, so verify them in the logs.